Reduce DB load when forget on leave setting is disabled (#16668)

* Reduce DB load when forget on leave setting is disabled

* Newsfile
pull/16719/head
Erik Johnston 2023-11-29 18:21:30 +00:00 committed by GitHub
parent 19dac97480
commit a14678492e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

1
changelog.d/16668.misc Normal file
View File

@ -0,0 +1 @@
Reduce DB load when forget on leave setting is disabled.

View File

@ -2111,9 +2111,14 @@ class RoomForgetterHandler(StateDeltasHandler):
self.pos = room_max_stream_ordering self.pos = room_max_stream_ordering
if not self._hs.config.room.forget_on_leave: if not self._hs.config.room.forget_on_leave:
# Update the processing position, so that if the server admin turns the # Update the processing position, so that if the server admin turns
# feature on at a later date, we don't decide to forget every room that # the feature on at a later date, we don't decide to forget every
# has ever been left in the past. # 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() self.pos = self._store.get_room_max_stream_ordering()
await self._store.update_room_forgetter_stream_pos(self.pos) await self._store.update_room_forgetter_stream_pos(self.pos)
return return