From 57383d4e25e0153c8a4498492e342b00824da6f1 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 21 Jul 2023 12:09:26 +0100 Subject: [PATCH 1/2] Resync stale devices in background This is so we don't block responding to federation transaction while we try and fetch the device lists. --- synapse/handlers/device.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py index 5d12a39e26a4..d73d9dca083d 100644 --- a/synapse/handlers/device.py +++ b/synapse/handlers/device.py @@ -1124,7 +1124,14 @@ async def _handle_device_updates(self, user_id: str) -> None: ) if resync: - await self.multi_user_device_resync([user_id]) + # We mark as stale up front in case we get restarted. + await self.store.mark_remote_users_device_caches_as_stale([user_id]) + run_as_background_process( + "_maybe_retry_device_resync", + self.multi_user_device_resync, + [user_id], + False, + ) else: # Simply update the single device, since we know that is the only # change (because of the single prev_id matching the current cache) From 3a4772392f60e5f9e011ebbbdf7aa24f6f3bdeee Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 21 Jul 2023 12:11:34 +0100 Subject: [PATCH 2/2] Newsfile --- changelog.d/15975.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/15975.bugfix diff --git a/changelog.d/15975.bugfix b/changelog.d/15975.bugfix new file mode 100644 index 000000000000..59738cca0ae7 --- /dev/null +++ b/changelog.d/15975.bugfix @@ -0,0 +1 @@ +Fix bug where resyncing stale device lists could block responding to federation transactions, and thus delay receiving new data from the remote server.