mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-07 23:55:05 -04:00
Update all stream IDs after processing replication rows (#14723)
This creates a new store method, `process_replication_position` that is called after `process_replication_rows`. By moving stream ID advances here this guarantees any relevant cache invalidations will have been applied before the stream is advanced. This avoids race conditions where Python switches between threads mid way through processing the `process_replication_rows` method where stream IDs may be advanced before caches are invalidated due to class resolution ordering. See this comment/issue for further discussion: https://github.com/matrix-org/synapse/issues/14158#issuecomment-1344048703
This commit is contained in:
parent
c4456114e1
commit
db1cfe9c80
13 changed files with 95 additions and 20 deletions
|
@ -57,7 +57,22 @@ class SQLBaseStore(metaclass=ABCMeta):
|
|||
token: int,
|
||||
rows: Iterable[Any],
|
||||
) -> None:
|
||||
pass
|
||||
"""
|
||||
Used by storage classes to invalidate caches based on incoming replication data. These
|
||||
must not update any ID generators, use `process_replication_position`.
|
||||
"""
|
||||
|
||||
def process_replication_position( # noqa: B027 (no-op by design)
|
||||
self,
|
||||
stream_name: str,
|
||||
instance_name: str,
|
||||
token: int,
|
||||
) -> None:
|
||||
"""
|
||||
Used by storage classes to advance ID generators based on incoming replication data. This
|
||||
is called after process_replication_rows such that caches are invalidated before any token
|
||||
positions advance.
|
||||
"""
|
||||
|
||||
def _invalidate_state_caches(
|
||||
self, room_id: str, members_changed: Collection[str]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue