summary refs log tree commit diff
path: root/synapse/storage/databases
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2021-10-28 20:40:57 -0500
committerEric Eastwood <erice@element.io>2021-10-28 20:40:57 -0500
commit3e09d4900012a42c6cd9ff4e7cd352156ded0069 (patch)
treeec3ce4ef0060aa423b29c40fe6b6e1ca87c03512 /synapse/storage/databases
parentWIP: Don't include the event we branch from (diff)
downloadsynapse-3e09d4900012a42c6cd9ff4e7cd352156ded0069.tar.xz
Revert "WIP: Don't include the event we branch from"
This reverts commit 9a6d8faafe3c09d5f70767637a1f6fe1ff7d231a.
Diffstat (limited to 'synapse/storage/databases')
-rw-r--r--synapse/storage/databases/main/event_federation.py35
1 files changed, 13 insertions, 22 deletions
diff --git a/synapse/storage/databases/main/event_federation.py b/synapse/storage/databases/main/event_federation.py
index 779f3e8181..4a4d35f77c 100644
--- a/synapse/storage/databases/main/event_federation.py
+++ b/synapse/storage/databases/main/event_federation.py
@@ -1094,7 +1094,8 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
             if event_id in event_results:
                 continue
 
-            found_connected_historical_messages = False
+            event_results.add(event_id)
+
             if self.hs.config.experimental.msc2716_enabled:
                 # Try and find any potential historical batches of message history.
                 #
@@ -1116,9 +1117,7 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
                     connected_insertion_event_stream_ordering = row[1]
                     connected_insertion_event_id = row[2]
                     connected_insertion_event_type = row[3]
-
                     if connected_insertion_event_id not in event_results:
-                        found_connected_historical_messages = True
                         queue.put(
                             (
                                 -connected_insertion_event_depth,
@@ -1147,26 +1146,18 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
                         if row[2] not in event_results:
                             queue.put((-row[0], -row[1], row[2], row[3]))
 
-            # Only add the event_result itself if we didn't branch off on the history first
-            # TODO: How can we not branch off to the historical batch if
-            # the federated homeserver already has it backfilled? We
-            # can't make any requests here (no async stuff and should
-            # really only be database calls)
-            if not found_connected_historical_messages:
-                event_results.add(event_id)
-
-                txn.execute(
-                    connected_prev_event_query,
-                    (event_id, False, limit - len(event_results)),
-                )
-                prev_event_id_results = txn.fetchall()
-                logger.debug(
-                    "_get_backfill_events: prev_event_ids %s", prev_event_id_results
-                )
+            txn.execute(
+                connected_prev_event_query,
+                (event_id, False, limit - len(event_results)),
+            )
+            prev_event_id_results = txn.fetchall()
+            logger.debug(
+                "_get_backfill_events: prev_event_ids %s", prev_event_id_results
+            )
 
-                for row in prev_event_id_results:
-                    if row[2] not in event_results:
-                        queue.put((-row[0], -row[1], row[2], row[3]))
+            for row in prev_event_id_results:
+                if row[2] not in event_results:
+                    queue.put((-row[0], -row[1], row[2], row[3]))
 
         return event_results