From a14678492eed5482312000bd7423f765680e4afc Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 29 Nov 2023 18:21:30 +0000 Subject: Reduce DB load when forget on leave setting is disabled (#16668) * Reduce DB load when forget on leave setting is disabled * Newsfile --- changelog.d/16668.misc | 1 + synapse/handlers/room_member.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 changelog.d/16668.misc diff --git a/changelog.d/16668.misc b/changelog.d/16668.misc new file mode 100644 index 0000000000..9ed004d6e4 --- /dev/null +++ b/changelog.d/16668.misc @@ -0,0 +1 @@ +Reduce DB load when forget on leave setting is disabled. diff --git a/synapse/handlers/room_member.py b/synapse/handlers/room_member.py index eddc2af9ba..00c2dd854d 100644 --- a/synapse/handlers/room_member.py +++ b/synapse/handlers/room_member.py @@ -2111,9 +2111,14 @@ class RoomForgetterHandler(StateDeltasHandler): self.pos = room_max_stream_ordering if not self._hs.config.room.forget_on_leave: - # Update the processing position, so that if the server admin turns the - # feature on at a later date, we don't decide to forget every room that - # has ever been left in the past. + # Update the processing position, so that if the server admin turns + # the feature on at a later date, we don't decide to forget every + # room that has ever been left in the past. + # + # We wait for a short time so that we don't "tight" loop just + # keeping the table up to date. + await self._clock.sleep(0.5) + self.pos = self._store.get_room_max_stream_ordering() await self._store.update_room_forgetter_stream_pos(self.pos) return -- cgit 1.4.1