Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit a0cd8ae

Browse files
authored
Don't try and backfill the same room in parallel. (#10116)
If backfilling is slow then the client may time out and retry, causing Synapse to start a new `/backfill` before the existing backfill has finished, duplicating work.
1 parent c96ab31 commit a0cd8ae

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

changelog.d/10116.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug where the server would attempt to fetch the same history in the room from a remote server multiple times in parallel.

synapse/handlers/federation.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ def __init__(self, hs: "HomeServer"):
178178
self.room_queues = {} # type: Dict[str, List[Tuple[EventBase, str]]]
179179
self._room_pdu_linearizer = Linearizer("fed_room_pdu")
180180

181+
self._room_backfill = Linearizer("room_backfill")
182+
181183
self.third_party_event_rules = hs.get_third_party_event_rules()
182184

183185
self._ephemeral_messages_enabled = hs.config.enable_ephemeral_messages
@@ -1041,6 +1043,12 @@ async def maybe_backfill(
10411043
return. This is used as part of the heuristic to decide if we
10421044
should back paginate.
10431045
"""
1046+
with (await self._room_backfill.queue(room_id)):
1047+
return await self._maybe_backfill_inner(room_id, current_depth, limit)
1048+
1049+
async def _maybe_backfill_inner(
1050+
self, room_id: str, current_depth: int, limit: int
1051+
) -> bool:
10441052
extremities = await self.store.get_oldest_events_with_depth_in_room(room_id)
10451053

10461054
if not extremities:

0 commit comments

Comments
 (0)