This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Sync race cache invalidation fixes part 2#14156
Closed
Fizzadar wants to merge 5 commits into
Closed
Conversation
This removes the extra token check and also means we can check membership changes before the token that may get lost due to a stale cache value returned from `get_rooms_for_user`. This can then be used to work around a race between cache invalidation over replication and sync requests.
This avoids race conditions with cache invalidation over replication. Only called for membership changes between two syncs that also don't show up in the get rooms for user call and should thus be sufficiently rare that this doesn't materially impact database performance.
This ensures no race conditions with cache invalidation. Since init syncs are usually new devices or users this is unlikely to impact database performance.
| # If we have no since token (init sync), ensure any cached rooms for the user | ||
| # is first invalidated to avoid race conditions with invalidation-over-replication. | ||
| if not since_token: | ||
| self.store.get_rooms_for_user.invalidate((user_id,)) |
Member
There was a problem hiding this comment.
I'm really hesitant to do this without fully understanding where the inconsistencies are coming in, as per #14154 (comment). In particular, it's not obvious to me that invalidating just this cache won't lead to really weird inconsistencies.
Contributor
Author
There was a problem hiding this comment.
IIRC this specific change wasn't based on an issue we saw more expected races similar to the other changes here. Probably makes sense to undo this commit, although the invalidating of get_users_in_room probably presents similar inconsistencies. Let's discuss in the issue and come back to this.
Contributor
Author
|
This is now redundant after #14723. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See issue: #14154
More involved than the first fix, reviewable commit-by-commit. This essentially serves as a workaround for delayed cache invalidation by utilising the membership events we already pull as part of sync to identify any missing rooms.
Also has two always-invalidate cases for safety. I believe in both of these the frequency of them is so low that the extra invalidation won't be any performance impact.
Signed off by Nick @ Beeper (@Fizzadar).
Pull Request Checklist
(run the linters)