Skip to content

Commit

Permalink
Fix error when out of servers to sync partial state with (matrix-org#…
Browse files Browse the repository at this point in the history
…13432)

so that we raise the intended error instead.

Signed-off-by: Sean Quah <seanq@matrix.org>
  • Loading branch information
squahtx authored and azmeuk committed Aug 8, 2022
1 parent 62dfc78 commit 94ffff1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/13432.bugfix
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 3 additions & 2 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1543,15 +1543,16 @@ async def _sync_partial_state_room(

# 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)
Expand Down

0 comments on commit 94ffff1

Please sign in to comment.