summary refs log tree commit diff
path: root/synapse/handlers/user_directory.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-10-10 11:51:50 +0100
committerErik Johnston <erik@matrix.org>2019-10-10 11:51:50 +0100
commit9970f955ce1ab36d21f7824d9f1382ab1df778e5 (patch)
tree94f824e633ac9b9fab18171a67a6b94aec2839a9 /synapse/handlers/user_directory.py
parentNewsfile (diff)
parentFix races in room stats (and other) updates. (#6187) (diff)
downloadsynapse-9970f955ce1ab36d21f7824d9f1382ab1df778e5.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/patch_inner
Diffstat (limited to 'synapse/handlers/user_directory.py')
-rw-r--r--synapse/handlers/user_directory.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/synapse/handlers/user_directory.py b/synapse/handlers/user_directory.py

index e53669e40d..624f05ab5b 100644 --- a/synapse/handlers/user_directory.py +++ b/synapse/handlers/user_directory.py
@@ -138,21 +138,28 @@ class UserDirectoryHandler(StateDeltasHandler): # Loop round handling deltas until we're up to date while True: with Measure(self.clock, "user_dir_delta"): - deltas = yield self.store.get_current_state_deltas(self.pos) - if not deltas: + room_max_stream_ordering = self.store.get_room_max_stream_ordering() + if self.pos == room_max_stream_ordering: return + logger.debug( + "Processing user stats %s->%s", self.pos, room_max_stream_ordering + ) + max_pos, deltas = yield self.store.get_current_state_deltas( + self.pos, room_max_stream_ordering + ) + logger.info("Handling %d state deltas", len(deltas)) yield self._handle_deltas(deltas) - self.pos = deltas[-1]["stream_id"] + self.pos = max_pos # Expose current event processing position to prometheus synapse.metrics.event_processing_positions.labels("user_dir").set( - self.pos + max_pos ) - yield self.store.update_user_directory_stream_pos(self.pos) + yield self.store.update_user_directory_stream_pos(max_pos) @defer.inlineCallbacks def _handle_deltas(self, deltas):