-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bust
_membership_stream_cache
cache when current state changes (#17732
) This is particularly a problem in a state reset scenario where the membership might change without a corresponding event. This PR is targeting a scenario where a state reset happens which causes room membership to change. Previously, the cache would just hold onto stale data and now we properly bust the cache in this scenario. We have a few tests for these scenarios which you can see are now fixed because we can remove the `FIXME` where we were previously manually busting the cache in the test itself. This is a general Synapse thing so by it's nature it helps out Sliding Sync. Fix #17368 Prerequisite for #17929 --- Match when are busting `_curr_state_delta_stream_cache`
- Loading branch information
1 parent
d0677dc
commit aab3672
Showing
8 changed files
with
88 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix membership caches not updating in state reset scenarios. |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,3 +255,28 @@ def test_max_pos(self) -> None: | |
|
||
# Unknown entities will return None | ||
self.assertEqual(cache.get_max_pos_of_last_change("[email protected]"), None) | ||
|
||
def test_all_entities_changed(self) -> None: | ||
""" | ||
`StreamChangeCache.all_entities_changed(...)` will mark all entites as changed. | ||
""" | ||
cache = StreamChangeCache("#test", 1, max_size=10) | ||
|
||
cache.entity_has_changed("[email protected]", 2) | ||
cache.entity_has_changed("[email protected]", 3) | ||
cache.entity_has_changed("[email protected]", 4) | ||
|
||
cache.all_entities_changed(5) | ||
|
||
# Everything should be marked as changed before the stream position where the | ||
# change occurred. | ||
self.assertTrue(cache.has_entity_changed("[email protected]", 4)) | ||
self.assertTrue(cache.has_entity_changed("[email protected]", 4)) | ||
self.assertTrue(cache.has_entity_changed("[email protected]", 4)) | ||
|
||
# Nothing should be marked as changed at/after the stream position where the | ||
# change occurred. In other words, nothing has changed since the stream position | ||
# 5. | ||
self.assertFalse(cache.has_entity_changed("[email protected]", 5)) | ||
self.assertFalse(cache.has_entity_changed("[email protected]", 5)) | ||
self.assertFalse(cache.has_entity_changed("[email protected]", 5)) |