-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bust _membership_stream_cache
cache when current state changes
#17732
base: develop
Are you sure you want to change the base?
Bust _membership_stream_cache
cache when current state changes
#17732
Conversation
def all_entities_changed(self, stream_pos: int) -> None: | ||
""" | ||
Mark all entities as changed. This is useful when the cache is invalidated and | ||
there may be some potential change for all of the entities. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: all_entities_changed(stream_pos)
: Does this concept make sense?
I don't think it makes sense to drop all of the keys as we're essentially not sure if something has changed so we have to update them to say "something might have changed but we don't know for sure". I think this is the way and is just "unfortunate for the membership caches"
@@ -219,6 +219,8 @@ def process_replication_rows( | |||
room_id = row.keys[0] | |||
members_changed = set(row.keys[1:]) | |||
self._invalidate_state_caches(room_id, members_changed) | |||
for user_id in members_changed: | |||
self._membership_stream_cache.entity_has_changed(user_id, token) # type: ignore[attr-defined] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda weird to just stick this here (same with the others in process_replication_rows
). Better way to organize this?
@@ -219,6 +219,8 @@ def process_replication_rows( | |||
room_id = row.keys[0] | |||
members_changed = set(row.keys[1:]) | |||
self._invalidate_state_caches(room_id, members_changed) | |||
for user_id in members_changed: | |||
self._membership_stream_cache.entity_has_changed(user_id, token) # type: ignore[attr-defined] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, tested this out with the tests in #17725 and these cache busting spots for current state don't pick up a state reset. Will need to look into this more
Bust
_membership_stream_cache
cache when current state changes. This is particularly a problem in a state reset scenario where the membership might change without a corresponding event.This is a general Synapse thing so by it's nature it helps out Sliding Sync.
Fix #17368
Dev notes
Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)