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

Commit aa6d908

Browse files
committed
Update events/membership/state-delta stream change caches in EventsWorkerStore
This means the entire lifecycle of both the caches and ID generators for events are handled by the one class.
1 parent 3f5d899 commit aa6d908

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

synapse/storage/databases/main/events_worker.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@
6262
)
6363
from synapse.replication.slave.storage._slaved_id_tracker import SlavedIdTracker
6464
from synapse.replication.tcp.streams import BackfillStream
65-
from synapse.replication.tcp.streams.events import EventsStream
65+
from synapse.replication.tcp.streams.events import (
66+
EventsStream,
67+
EventsStreamCurrentStateRow,
68+
EventsStreamEventRow,
69+
)
6670
from synapse.storage._base import SQLBaseStore, db_to_json, make_in_list_sql_clause
6771
from synapse.storage.database import (
6872
DatabasePool,
@@ -334,7 +338,23 @@ def process_replication_rows(
334338
token: int,
335339
rows: Iterable[Any],
336340
) -> None:
341+
# Process event stream replication rows, handling both the ID generators from the events
342+
# worker store and the stream change caches in this store as the two are interlinked.
337343
if stream_name == EventsStream.NAME:
344+
for row in rows:
345+
if row.type == EventsStreamEventRow.TypeId:
346+
self._events_stream_cache.entity_has_changed(
347+
row.data.room_id, token
348+
)
349+
if row.data.type == EventTypes.Member:
350+
self._membership_stream_cache.entity_has_changed(
351+
row.data.state_key, token
352+
)
353+
if row.type == EventsStreamCurrentStateRow.TypeId:
354+
self._curr_state_delta_stream_cache.entity_has_changed(
355+
row.data.room_id, token
356+
)
357+
# Important that the ID gen advances after stream change caches
338358
self._stream_id_gen.advance(instance_name, token)
339359
elif stream_name == BackfillStream.NAME:
340360
self._backfill_id_gen.advance(instance_name, -token)

0 commit comments

Comments
 (0)