summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2022-04-22 13:38:41 +0100
committerRichard van der Hoff <richard@matrix.org>2022-04-22 15:48:38 +0100
commit6e2140364b6a9255daf52b3c01e5449d2b485262 (patch)
tree1e5a8e072f09d13bdfc93eeeae5fd2ab7f9ab224
parentMove some filtering and sorting logic earlier (diff)
downloadsynapse-6e2140364b6a9255daf52b3c01e5449d2b485262.tar.xz
update some comments and logs
-rw-r--r--synapse/handlers/federation.py43
1 files changed, 26 insertions, 17 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py

index cad103d39f..9b1d4d9594 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py
@@ -188,8 +188,14 @@ class FederationHandler: ), key=lambda e: -int(e[1]), ) - - max_depth = sorted_extremeties_tuples[0][1] + logger.debug( + "_maybe_backfill_inner: room_id: %s: current_depth: %s, limit: %s, extrems (%d): %s", + room_id, + current_depth, + limit, + len(sorted_extremeties_tuples), + sorted_extremeties_tuples, + ) # If we're approaching an extremity we trigger a backfill, otherwise we # no-op. @@ -200,6 +206,11 @@ class FederationHandler: # chose more than one times the limit in case of failure, but choosing a # much larger factor will result in triggering a backfill request much # earlier than necessary. + # + # XXX: shouldn't we do this *after* the filter by depth below? Again, we don't + # care about events that have happened after our current position. + # + max_depth = sorted_extremeties_tuples[0][1] if current_depth - 2 * limit > max_depth: logger.debug( "Not backfilling as we don't need to. %d < %d - 2 * %d", @@ -216,27 +227,25 @@ class FederationHandler: # 2. we have likely previously tried and failed to backfill from that # extremity, so to avoid getting "stuck" requesting the same # backfill repeatedly we drop those extremities. - filtered_sorted_extremeties_tuples = [ - t for t in sorted_extremeties_tuples if int(t[1]) <= current_depth - ] - - logger.debug( - "room_id: %s, backfill: current_depth: %s, limit: %s, max_depth: %s, extrems (%d): %s filtered_sorted_extremeties_tuples: %s", - room_id, - current_depth, - limit, - max_depth, - len(sorted_extremeties_tuples), - sorted_extremeties_tuples, - filtered_sorted_extremeties_tuples, - ) - + # # However, we need to check that the filtered extremities are non-empty. # If they are empty then either we can a) bail or b) still attempt to # backfill. We opt to try backfilling anyway just in case we do get # relevant events. + # + filtered_sorted_extremeties_tuples = [ + t for t in sorted_extremeties_tuples if int(t[1]) <= current_depth + ] if filtered_sorted_extremeties_tuples: + logger.debug( + "_maybe_backfill_inner: extrems before current depth: %s", + filtered_sorted_extremeties_tuples, + ) sorted_extremeties_tuples = filtered_sorted_extremeties_tuples + else: + logger.debug( + "_maybe_backfill_inner: all extrems are *after* current depth. Backfilling anyway." + ) # We only want to paginate if we can actually see the events we'll get, # as otherwise we'll just spend a lot of resources to get redacted