From 9b5ef68d3d2d25c7475f1bd526915911514dde65 Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Sun, 23 Oct 2022 21:29:55 +0100 Subject: [PATCH] Flag stream change cache after persisting events with new stream order This appears to have previously been done within the room depth handling and only for local events. --- synapse/storage/databases/main/events.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/synapse/storage/databases/main/events.py b/synapse/storage/databases/main/events.py index 6698cbf66495..20479eef0609 100644 --- a/synapse/storage/databases/main/events.py +++ b/synapse/storage/databases/main/events.py @@ -487,6 +487,14 @@ def _persist_events_txn( # NB: This function invalidates all state related caches self._update_current_state_txn(txn, state_delta_for_room, min_stream_order) + # Flag the stream change cache for this room if we added non-backfilled events + if max_stream_order > 0: + for event, _ in events_and_contexts: + assert event.internal_metadata.stream_ordering is not None + self.store._events_stream_cache.entity_has_changed( + event.room_id, event.internal_metadata.stream_ordering + ) + def _persist_event_auth_chain_txn( self, txn: LoggingTransaction, @@ -1046,6 +1054,9 @@ async def update_current_state( stream_id=stream_ordering, ) + # Flag the stream change cache for this room + self.store._events_stream_cache.entity_has_changed(room_id, stream_ordering) + def _update_current_state_txn( self, txn: LoggingTransaction,