From d9c9706c05a0f617e9de45434e53a4f363b40a0c Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 26 Mar 2026 11:28:35 -0500 Subject: [PATCH] Debug why we pad --- scripts-dev/complement.sh | 24 ++++++++++++------------ synapse/handlers/federation.py | 23 ++++++++++++++++++++++- synapse/handlers/pagination.py | 7 +++++++ 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/scripts-dev/complement.sh b/scripts-dev/complement.sh index cca87d42a9..db83e87ad2 100755 --- a/scripts-dev/complement.sh +++ b/scripts-dev/complement.sh @@ -274,18 +274,18 @@ main() { # We pick and choose the specific MSC's that Synapse supports. default_complement_test_packages=( ./tests/csapi - ./tests - ./tests/msc3874 - ./tests/msc3890 - ./tests/msc3391 - ./tests/msc3757 - ./tests/msc3930 - ./tests/msc3902 - ./tests/msc3967 - ./tests/msc4140 - ./tests/msc4155 - ./tests/msc4306 - ./tests/msc4222 + # ./tests + # ./tests/msc3874 + # ./tests/msc3890 + # ./tests/msc3391 + # ./tests/msc3757 + # ./tests/msc3930 + # ./tests/msc3902 + # ./tests/msc3967 + # ./tests/msc4140 + # ./tests/msc4155 + # ./tests/msc4306 + # ./tests/msc4222 ) # Export the list of test packages as a space-separated environment variable, so other diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index f173166be1..982f2a62fe 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -255,7 +255,8 @@ class FederationHandler: room_id=room_id, # Per the docstring, it's best to pad the `current_depth` by the # number of messages you plan to backfill from these points. - current_depth=current_depth + limit, + # current_depth=current_depth + limit, + current_depth=current_depth, # We only need to end up with 5 extremities combined with the # insertion event extremities to make the `/backfill` request # but fetch an order of magnitude more to make sure there is @@ -267,6 +268,25 @@ class FederationHandler: ) ] + all_backwards_extremities = [ + _BackfillPoint(event_id, depth, _BackfillPointType.BACKWARDS_EXTREMITY) + for event_id, depth in await self.store.get_backfill_points_in_room( + room_id=room_id, + current_depth=999999, + limit=50, + ) + ] + logger.info( + "asdf all_backwards_extremities=%s", + all_backwards_extremities, + ) + + logger.info( + "asdf current_depth=%s backwards_extremities=%s", + current_depth, + backwards_extremities, + ) + # we now have a list of potential places to backpaginate from. We prefer to # start with the most recent (ie, max depth), so let's sort the list. sorted_backfill_points: list[_BackfillPoint] = sorted( @@ -313,6 +333,7 @@ class FederationHandler: logger.debug( "_maybe_backfill_inner: all backfill points are *after* current depth. Trying again with later backfill points." ) + logger.info("asdf: backfill in the background") self.hs.run_as_background_process( "_maybe_backfill_inner_anyway_with_max_depth", self.maybe_backfill, diff --git a/synapse/handlers/pagination.py b/synapse/handlers/pagination.py index a55dcc78b0..6cc51123f9 100644 --- a/synapse/handlers/pagination.py +++ b/synapse/handlers/pagination.py @@ -566,6 +566,13 @@ class PaginationHandler: StreamKeyType.ROOM, leave_token ) + logger.info( + "asdf get_messages backfill=%s pagin_config.from_token=%s curr_topo=%s", + backfill, + pagin_config.from_token, + curr_topo, + ) + to_room_key = None if pagin_config.to_token: to_room_key = pagin_config.to_token.room_key