Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Reduce DB load when forget on leave setting is disabled (#16668)
Browse files Browse the repository at this point in the history
* Reduce DB load when forget on leave setting is disabled

* Newsfile
  • Loading branch information
erikjohnston authored Nov 29, 2023
1 parent 19dac97 commit a146784
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/16668.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce DB load when forget on leave setting is disabled.
11 changes: 8 additions & 3 deletions synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -2111,9 +2111,14 @@ async def _unsafe_process(self) -> None:
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
Expand Down

0 comments on commit a146784

Please sign in to comment.