1 files changed, 2 insertions, 2 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py
index 8908d5b5da..613b54cd1d 100644
--- a/synapse/storage/stream.py
+++ b/synapse/storage/stream.py
@@ -217,8 +217,8 @@ class StreamStore(SQLBaseStore):
" room_id = ?"
" AND not outlier"
" AND stream_ordering <= ?"
- " ORDER BY stream_ordering %s LIMIT ?"
- ) % (order,)
+ " ORDER BY topological_ordering %s, stream_ordering %s LIMIT ?"
+ ) % (order, order,)
txn.execute(sql, (room_id, to_id, limit))
rows = self.cursor_to_dict(txn)
|