summary refs log tree commit diff
path: root/synapse/storage/databases
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2021-10-18 16:40:01 -0500
committerEric Eastwood <erice@element.io>2021-10-18 16:40:04 -0500
commit438e2226cca4ace0730faaca6b538384d6975dcc (patch)
tree0af37a4f1db753f9e61a8a3fb2fc6f2b0b21e2fe /synapse/storage/databases
parentScratch debugging why events appear out of order on remote homeservers (diff)
downloadsynapse-438e2226cca4ace0730faaca6b538384d6975dcc.tar.xz
Use OrderedDict to gurantee order returned is the same as we were building the list
We are using a Dict over a list to gurantee we don't duplicate the event if it's already in there.
I assume this is why we were using a Set before.
Diffstat (limited to 'synapse/storage/databases')
-rw-r--r--synapse/storage/databases/main/event_federation.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/synapse/storage/databases/main/event_federation.py b/synapse/storage/databases/main/event_federation.py
index c857158648..b9c48eea56 100644
--- a/synapse/storage/databases/main/event_federation.py
+++ b/synapse/storage/databases/main/event_federation.py
@@ -14,7 +14,7 @@
 import itertools
 import logging
 from queue import Empty, PriorityQueue
-from typing import Collection, Dict, Iterable, List, Optional, Set, Tuple
+from typing import Collection, Dict, Iterable, List, Optional, Set, OrderedDict, Tuple
 
 from prometheus_client import Counter, Gauge
 
@@ -1007,7 +1007,7 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
     def _get_backfill_events(self, txn, room_id, event_list, limit):
         logger.debug("_get_backfill_events: %s, %r, %s", room_id, event_list, limit)
 
-        event_results = set()
+        event_results = OrderedDict()
 
         # We want to make sure that we do a breadth-first, "depth" ordered
         # search.
@@ -1120,7 +1120,7 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
                     event_id,
                 )
 
-            event_results.add(event_id)
+            event_results[event_id] = event_id
 
             # Try and find any potential historical batches of message history.
             #
@@ -1181,7 +1181,7 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
                 if row[2] not in event_results:
                     queue.put((-row[0], -row[1], row[2]))
 
-        return event_results
+        return event_results.values()
 
     async def get_missing_events(self, room_id, earliest_events, latest_events, limit):
         ids = await self.db_pool.runInteraction(