-
Notifications
You must be signed in to change notification settings - Fork 299
Sliding Sync: Make sure we get up-to-date information from get_sliding_sync_rooms_for_user(...)
#17692
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
Sliding Sync: Make sure we get up-to-date information from get_sliding_sync_rooms_for_user(...)
#17692
Conversation
Make sure we get up-to-date information from `get_sliding_sync_rooms_for_user(...)`
@@ -483,6 +488,7 @@ def _invalidate_caches_for_room(self, room_id: str) -> None: | |||
self._attempt_to_invalidate_cache("get_room_version_id", (room_id,)) | |||
self._attempt_to_invalidate_cache("get_room_type", (room_id,)) | |||
self._attempt_to_invalidate_cache("get_room_encryption", (room_id,)) | |||
self._attempt_to_invalidate_cache("get_sliding_sync_rooms_for_user", None) |
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.
get_sliding_sync_rooms_for_user(...)
doesn't cache very well because we have to bust it whenever state in any room changes. Is it even worth caching it?
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.
The reason I discovered this in the first place is because I tried adding COALESCE(j.event_stream_ordering, m.event_stream_ordering)
for sorting and discovered that get_sliding_sync_rooms_for_user(...)
was returning a bunch of cached values. And busting the cache for any event sent on the homeserver just doesn't make sense to do.
But busting the cache when any state across the homeserver seems just as bad.
@@ -275,6 +275,9 @@ def _process_event_stream_row(self, token: int, row: EventsStreamRow) -> None: | |||
self._attempt_to_invalidate_cache( | |||
"get_room_encryption", (data.room_id,) | |||
) | |||
self._attempt_to_invalidate_cache( | |||
"get_sliding_sync_rooms_for_user", None | |||
) |
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.
Busting the cache wherever we bust it for get_room_encryption
already
@@ -1348,6 +1348,9 @@ def f(txn: LoggingTransaction) -> None: | |||
self._invalidate_cache_and_stream( | |||
txn, self.get_forgotten_rooms_for_user, (user_id,) | |||
) | |||
self._invalidate_cache_and_stream( | |||
txn, self.get_sliding_sync_rooms_for_user, (user_id,) | |||
) |
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.
Busting the cache whenever we bust the cache for did_forget
/get_forgotten_rooms_for_user
get_sliding_sync_rooms_for_user(...)
get_sliding_sync_rooms_for_user(...)
…ooms_for_user(...)`
}, | ||
} | ||
} | ||
response_body, from_token = self.do_sync(sync_body, tok=user1_tok) |
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.
Unrelated, just updating to use the do_sync
helper
@@ -831,6 +820,98 @@ def test_filter_regardless_of_membership_server_left_room(self) -> None: | |||
], | |||
) | |||
|
|||
def test_filter_is_encrypted_up_to_date(self) -> None: |
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.
New tests
Thanks for the review @erikjohnston 🐕 |
Make sure we get up-to-date information from
get_sliding_sync_rooms_for_user(...)
. We need to bust theget_sliding_sync_rooms_for_user
cache when the room encryption is updated and any other field that is used in the query.Follow-up to #17630
TODO
get_rooms_for_user
)encryption
(cross-referenceget_room_encryption
)forgotten
(cross-referencedid_forget
/get_forgotten_rooms_for_user
)Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)