From 52c9b81ae7769ef316750da35cf70352993ed222 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 24 Sep 2024 10:40:39 +0100 Subject: [PATCH 1/2] Never return negative bump stamp Fixes #17737 --- synapse/handlers/sliding_sync/__init__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/synapse/handlers/sliding_sync/__init__.py b/synapse/handlers/sliding_sync/__init__.py index 5206af22ec..9fcc68ff25 100644 --- a/synapse/handlers/sliding_sync/__init__.py +++ b/synapse/handlers/sliding_sync/__init__.py @@ -1063,6 +1063,22 @@ async def get_room_sync_data( if new_bump_stamp is not None: bump_stamp = new_bump_stamp + if bump_stamp < 0: + # We never want to send down negative stream orderings, as you can't + # sensibly compare positive and negative stream orderings (they have + # different meanings). + # + # A negative bump stamp here can only happen if the stream ordering + # of the membership event is negative (and there are no further bump + # stamps), which can happen if the server leaves and deletes a room, + # and then rejoins it. + # + # To deal with this, we just set the bump stamp to zero, which will + # shove this room to the bottom of the list. This is OK as the + # moment a new message happens in the room it will get put into a + # sensible order again. + bump_stamp = 0 + unstable_expanded_timeline = False prev_room_sync_config = previous_connection_state.room_configs.get(room_id) # Record the `room_sync_config` if we're `ignore_timeline_bound` (which means From 7e92fec42b8f7d47cf4ce14e398c79b259da6513 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 24 Sep 2024 10:43:03 +0100 Subject: [PATCH 2/2] Newsfile --- changelog.d/17748.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/17748.bugfix diff --git a/changelog.d/17748.bugfix b/changelog.d/17748.bugfix new file mode 100644 index 0000000000..dda8331f57 --- /dev/null +++ b/changelog.d/17748.bugfix @@ -0,0 +1 @@ +Fix bug in sliding sync where the server would incorrectly return a negative bump stamp, which caused Element X apps to stop syncing.