fix(unread counts): a gappy sync shouldn't decrease the unread counts#6284
Open
fix(unread counts): a gappy sync shouldn't decrease the unread counts#6284
Conversation
This test exhibits an edge case: when a room event cache is shrunk (because of a gappy/limited sync), then the unread count might decrease, without the latest active read receipt changing.
A gappy sync may cause a linked chunk to shrink, waiting for callers to lazy-reload it again in the future. But, because the unread counts computation rely on the in-memory linked chunk, this means that the values computed for the unread count may be incorrect (and decrease). Fortunately, this situation is rather easy to detect, because the latest active read receipt doesn't change in this case, so we can first check that, and then manually readjust the unread counts, if they've decreased. Future work should trigger back-pagination in those cases, so the unread counts keeps on being precise, despite the gappy sync.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6284 +/- ##
=======================================
Coverage 89.90% 89.90%
=======================================
Files 374 374
Lines 102613 102624 +11
Branches 102613 102624 +11
=======================================
+ Hits 92250 92266 +16
+ Misses 6798 6789 -9
- Partials 3565 3569 +4 ☔ View full report in Codecov by Sentry. |
Merging this PR will degrade performance by 60.29%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | Restore session [memory store] |
111.9 ms | 281.8 ms | -60.29% |
Comparing bnjbvr/event-cache-shrink-unread-counts (030af23) with main (b6c4bca)
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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 code comments and commits descriptions :) This fixes a situation where a gappy sync could cause unread counts to decrease (because unread counts computation rely on the linked-chunk to be completely loaded up to the latest active read receipt).
CHANGELOG.mdfiles.Part of #4113