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

Commit

Permalink
Invalidate rooms for user caches when receiving membership events (#1…
Browse files Browse the repository at this point in the history
…4155)

This should fix a race where the event notification comes in over
replication before the state replication, leaving a window during
which a sync may get an incorrect list of rooms for the user.
  • Loading branch information
Fizzadar authored Oct 17, 2022
1 parent cd01a1d commit 2c2c3f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/14155.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Invalidate rooms for user caches on replicated event, fix sync cache race in synapse workers. Contributed by Nick @ Beeper (@fizzadar).
4 changes: 4 additions & 0 deletions synapse/storage/databases/main/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ def _invalidate_caches_for_event(
self._attempt_to_invalidate_cache(
"get_invited_rooms_for_local_user", (state_key,)
)
self._attempt_to_invalidate_cache(
"get_rooms_for_user_with_stream_ordering", (state_key,)
)
self._attempt_to_invalidate_cache("get_rooms_for_user", (state_key,))

if relates_to:
self._attempt_to_invalidate_cache("get_relations_for_event", (relates_to,))
Expand Down

0 comments on commit 2c2c3f8

Please sign in to comment.