From 321f9ea68b4b87da91dc96c22f7c466a91d46c68 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 2 Nov 2021 17:27:04 -0500 Subject: Move back to the old get_backfill_events and simplify backfill. We now rely on the marker events to backfill the base insertion event which puts it as a insertion event extremity. This functionality was already in place (see `handle_marker_event`) and was an easy transition. This way, remote federated homeserver will have the insertion extremity to ask about in backfill and goes down the historical branch no problem because of the depth order and the rest of the DAG navigation happens as normal. Yay simplification! The key breakthrough was discussing all the ways we can find connected insertion events. https://docs.google.com/document/d/1KCEmpnGr4J-I8EeaVQ8QJZKBDu53ViI7V62y5BzfXr0/edit#bookmark=id.1hbt9acs963h The three options we came up were: - Find by insertion event prev_events (this is what we were doing before) - Find connected insertion events by depth - Find connected insertion events by the marker event - This made the most sense since we already backfill the insertion event when a marker event is processed (see `handle_marker_event`). - Gets rid of the extra insertion event lookup in backfill because we know it's already backfilled from the marker processing. - And gets rid of the extra federated lookup we added in this to PR to ask whether the homeserver requesting backfill already has the insertion event (deciding whether we fork to the history branch before we go down the "live" DAG) --- synapse/handlers/federation.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'synapse/handlers') diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index e7570310c5..21c615432a 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -1265,25 +1265,9 @@ class FederationHandler: # Synapse asks for 100 events per backfill request. Do not allow more. limit = min(limit, 100) - # events = await self.store.get_backfill_events(room_id, pdu_list, limit) - # logger.info( - # "old implementation backfill events=%s", - # [ - # "event_id=%s,depth=%d,body=%s,prevs=%s\n" - # % ( - # event.event_id, - # event.depth, - # event.content.get("body", event.type), - # event.prev_event_ids(), - # ) - # for event in events - # ], - # ) - - events = await self.get_backfill_events(origin, room_id, pdu_list, limit) + events = await self.store.get_backfill_events(room_id, pdu_list, limit) logger.info( - "new implementation backfill events(%d)=%s", - len(events), + "old implementation backfill events=%s", [ "event_id=%s,depth=%d,body=%s,prevs=%s\n" % ( @@ -1296,6 +1280,22 @@ class FederationHandler: ], ) + # events = await self.get_backfill_events(origin, room_id, pdu_list, limit) + # logger.info( + # "new implementation backfill events(%d)=%s", + # len(events), + # [ + # "event_id=%s,depth=%d,body=%s,prevs=%s\n" + # % ( + # event.event_id, + # event.depth, + # event.content.get("body", event.type), + # event.prev_event_ids(), + # ) + # for event in events + # ], + # ) + events = await filter_events_for_server(self.storage, origin, events) return events -- cgit 1.5.1