From 44a326cd033eeeef0618b78ab56b33709bdd3170 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 10 Jul 2024 16:04:07 +0100 Subject: Fixup --- synapse/storage/databases/main/stream.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/synapse/storage/databases/main/stream.py b/synapse/storage/databases/main/stream.py index d6801accab..7a4b74e0a7 100644 --- a/synapse/storage/databases/main/stream.py +++ b/synapse/storage/databases/main/stream.py @@ -1224,14 +1224,16 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore): txn: LoggingTransaction, ) -> Dict[str, int]: sql = f""" - SELECT DISTINCT ON (room_id) room_id, stream_ordering FROM events - WHERE room_id = ? AND stream_ordering IS NOT NULL - ORDER BY room_id, stream_ordering DESC + SELECT MAX(stream_ordering) FROM events + WHERE room_id = ? """ txn.execute(sql, (room_id,)) - return {room_id: stream_ordering for room_id, stream_ordering in txn} + row = txn.fetchone() + if row: + return row[0] + return None return await self.db_pool.runInteraction( "get_rough_stream_ordering_for_room", get_rough_stream_ordering_for_room_txn -- cgit 1.4.1