diff --git a/changelog.d/17295.bugfix b/changelog.d/17295.bugfix new file mode 100644 index 0000000000..4484253bb8 --- /dev/null +++ b/changelog.d/17295.bugfix @@ -0,0 +1 @@ +Fix edge case in `/sync` returning the wrong the state when using sharded event persisters. diff --git a/synapse/storage/databases/main/stream.py b/synapse/storage/databases/main/stream.py index 680014bad5..dd5f76dd53 100644 --- a/synapse/storage/databases/main/stream.py +++ b/synapse/storage/databases/main/stream.py @@ -931,8 +931,6 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore): # ordering of the operand queries but there is no actual gurantee that it # has this behavior in all scenarios so we need the extra `ORDER BY` at the # bottom. - # - # We're using the subquery syntax for SQLite compatibility. sql = """ SELECT * FROM ( SELECT instance_name, stream_ordering, topological_ordering, event_id diff --git a/tests/storage/test_stream.py b/tests/storage/test_stream.py index 7488eae0ee..2dd4083199 100644 --- a/tests/storage/test_stream.py +++ b/tests/storage/test_stream.py @@ -468,7 +468,7 @@ class GetLastEventInRoomBeforeStreamOrderingTestCase(HomeserverTestCase): self.assertEqual( last_event, event_response3["event_id"], - f"We expected {event_response3["event_id"]} but saw {last_event} which corresponds to" + f"We expected {event_response3['event_id']} but saw {last_event} which corresponds to " + str( { "event1": event_response1["event_id"], @@ -526,7 +526,7 @@ class GetLastEventInRoomBeforeStreamOrderingTestCase(HomeserverTestCase): self.assertEqual( last_event, event_response2["event_id"], - f"We expected {event_response2["event_id"]} but saw {last_event} which corresponds to" + f"We expected {event_response2['event_id']} but saw {last_event} which corresponds to " + str( { "event1": event_response1["event_id"],