Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Revert "WIP: Don't include the event we branch from"
Browse files Browse the repository at this point in the history
This reverts commit 9a6d8fa.
  • Loading branch information
MadLittleMods committed Oct 29, 2021
1 parent 9a6d8fa commit 3e09d49
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions synapse/storage/databases/main/event_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,8 @@ def _get_backfill_events(self, txn, room_id, event_list, limit):
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.
#
Expand All @@ -1116,9 +1117,7 @@ def _get_backfill_events(self, txn, room_id, event_list, limit):
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,
Expand Down Expand Up @@ -1147,26 +1146,18 @@ def _get_backfill_events(self, txn, room_id, event_list, limit):
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

Expand Down

0 comments on commit 3e09d49

Please sign in to comment.