Commit graph

11 commits

Author SHA1 Message Date
Eric Eastwood
2864837b65 Allow new get_sync_room_ids_for_user implementation to work with multiple event persisters
Before, the problem scenario would get caught in one of the assertions because
we expect the to_token <= membership_snapshot_token or vice-versa but it's
possible the tokens are intertwined and neither is ahead of each other.
Especially since the `instance_map` in `membership_snapshot_token` is made up
from the `stream_ordering` of membership events at various stream positions
and processed on different instances (not current stream positions).

We get into trouble when stream positions are lagging between workers and our
now/`to_token` doesn't cleanly compare to `membership_snapshot_token`.

What we really want to assert is that the `to_token` <= the stream positions
at the time we asked for the room membership snapshot. Since
`get_rooms_for_local_user_where_membership_is()` doesn't return that
information, the closest we can get is to get the stream positions before we
ask for the room membership snapshot and consider that good enough to compare
against.
2024-06-04 19:50:12 -05:00
Eric Eastwood
3ce08925e3 Add test with multiple event persisters that fails the previous get_sync_room_ids_for_user implementation
The new implementation catches the problem with an assert
but I think it's possible to make it work as well.

```
SYNAPSE_POSTGRES=1 SYNAPSE_POSTGRES_USER=postgres SYNAPSE_TEST_LOG_LEVEL=INFO poetry run trial tests.handlers.test_sliding_sync.GetSyncRoomIdsForUserEventShardTestCase
```
2024-06-04 19:27:28 -05:00
Eric Eastwood
dfee21a1f4 Switch fixup order to fix edge case with newly_left rooms
Previously, we added back newly_left rooms and our second
fixup was removing them. We can just switch the order
of the fixups to solve this.
2024-06-04 18:29:14 -05:00
Eric Eastwood
3514aa0ff2 Add licensing headers 2024-06-03 22:49:27 -05:00
Eric Eastwood
35db057982 Add support for kicks 2024-06-03 22:47:01 -05:00
Eric Eastwood
950fd70948 Tweak comments 2024-05-28 15:51:05 -05:00
Eric Eastwood
37af87a563 Add test to make sure we don't confuse multiple rooms 2024-05-23 14:23:49 -05:00
Eric Eastwood
c82a084006 Update comments and test docstrings 2024-05-22 13:18:13 -05:00
Eric Eastwood
fd355f6b62 WIP 2024-05-21 17:37:46 -05:00
Eric Eastwood
fe48188f7d Handle more edge cases 2024-05-21 15:05:19 -05:00
Eric Eastwood
c826550524 Add some tests 2024-05-21 14:24:03 -05:00