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

Commit a146784

Browse files
authored
Reduce DB load when forget on leave setting is disabled (#16668)
* Reduce DB load when forget on leave setting is disabled * Newsfile
1 parent 19dac97 commit a146784

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

changelog.d/16668.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reduce DB load when forget on leave setting is disabled.

synapse/handlers/room_member.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,9 +2111,14 @@ async def _unsafe_process(self) -> None:
21112111
self.pos = room_max_stream_ordering
21122112

21132113
if not self._hs.config.room.forget_on_leave:
2114-
# Update the processing position, so that if the server admin turns the
2115-
# feature on at a later date, we don't decide to forget every room that
2116-
# has ever been left in the past.
2114+
# Update the processing position, so that if the server admin turns
2115+
# the feature on at a later date, we don't decide to forget every
2116+
# room that has ever been left in the past.
2117+
#
2118+
# We wait for a short time so that we don't "tight" loop just
2119+
# keeping the table up to date.
2120+
await self._clock.sleep(0.5)
2121+
21172122
self.pos = self._store.get_room_max_stream_ordering()
21182123
await self._store.update_room_forgetter_stream_pos(self.pos)
21192124
return

0 commit comments

Comments
 (0)