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

Commit

Permalink
Linearize requests to fetch remote devices
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Sep 5, 2023
1 parent 94ca43f commit e05ccb5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions synapse/handlers/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ def __init__(self, hs: "HomeServer", device_handler: DeviceHandler):
self._notifier = hs.get_notifier()

self._remote_edu_linearizer = Linearizer(name="remote_device_list")
self._resync_linearizer = Linearizer(name="remote_device_resync")

# user_id -> list of updates waiting to be handled.
self._pending_updates: Dict[
Expand Down Expand Up @@ -1274,9 +1275,11 @@ async def multi_user_device_resync(
failed = set()
# TODO(Perf): Actually batch these up
for user_id in user_ids:
user_result, user_failed = await self._user_device_resync_returning_failed(
user_id
)
async with self._resync_linearizer.queue(user_id):
(
user_result,
user_failed,
) = await self._user_device_resync_returning_failed(user_id)
result[user_id] = user_result
if user_failed:
failed.add(user_id)
Expand Down

0 comments on commit e05ccb5

Please sign in to comment.