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(...)`
| 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.
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.
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.
| ) | ||
| self._attempt_to_invalidate_cache( | ||
| "get_sliding_sync_rooms_for_user", None | ||
| ) |
There was a problem hiding this comment.
Busting the cache wherever we bust it for get_room_encryption already
| ) | ||
| self._invalidate_cache_and_stream( | ||
| txn, self.get_sliding_sync_rooms_for_user, (user_id,) | ||
| ) |
There was a problem hiding this comment.
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.
Unrelated, just updating to use the do_sync helper
| ], | ||
| ) | ||
|
|
||
| def test_filter_is_encrypted_up_to_date(self) -> None: |
|
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_usercache 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
EventStoretoEventWorkerStore.".code blocks.(run the linters)