summary refs log tree commit diff
diff options
context:
space:
mode:
authorSean Quah <8349537+squahtx@users.noreply.github.com>2022-08-02 12:12:44 +0100
committerGitHub <noreply@github.com>2022-08-02 12:12:44 +0100
commit8d317f6da5aa2efc030990c7036cdb4f384c704a (patch)
treeea5bc747edfe816eb139dc935e2be253b2b73aa4
parentMerge branch 'master' into develop (diff)
downloadsynapse-8d317f6da5aa2efc030990c7036cdb4f384c704a.tar.xz
Fix error when out of servers to sync partial state with (#13432)
so that we raise the intended error instead.

Signed-off-by: Sean Quah <seanq@matrix.org>
-rw-r--r--changelog.d/13432.bugfix1
-rw-r--r--synapse/handlers/federation.py5
2 files changed, 4 insertions, 2 deletions
diff --git a/changelog.d/13432.bugfix b/changelog.d/13432.bugfix
new file mode 100644
index 0000000000..bb99616afc
--- /dev/null
+++ b/changelog.d/13432.bugfix
@@ -0,0 +1 @@
+Faster room joins: Fix error when running out of servers to sync partial state with, so that Synapse raises the intended error instead.
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index 1cf6cb32e3..57ad6e5dce 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -1543,15 +1543,16 @@ class FederationHandler:
 
         # Make an infinite iterator of destinations to try. Once we find a working
         # destination, we'll stick with it until it flakes.
+        destinations: Collection[str]
         if initial_destination is not None:
             # Move `initial_destination` to the front of the list.
             destinations = list(other_destinations)
             if initial_destination in destinations:
                 destinations.remove(initial_destination)
             destinations = [initial_destination] + destinations
-            destination_iter = itertools.cycle(destinations)
         else:
-            destination_iter = itertools.cycle(other_destinations)
+            destinations = other_destinations
+        destination_iter = itertools.cycle(destinations)
 
         # `destination` is the current remote homeserver we're pulling from.
         destination = next(destination_iter)