summary refs log tree commit diff
path: root/synapse/handlers/device.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2023-07-24 13:43:43 +0100
committerGitHub <noreply@github.com>2023-07-24 13:43:43 +0100
commit654902a7583d20d7e0b57dc4634fbe573ff99993 (patch)
tree3eea0bc1a8ec237d31308083130c2b188533c54c /synapse/handlers/device.py
parentBump click from 8.1.3 to 8.1.6 (#15984) (diff)
downloadsynapse-654902a7583d20d7e0b57dc4634fbe573ff99993.tar.xz
Resync stale devices in background (#15975)
This is so we don't block responding to federation transaction while we
try and fetch the device lists.
Diffstat (limited to 'synapse/handlers/device.py')
-rw-r--r--synapse/handlers/device.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py
index 5d12a39e26..d73d9dca08 100644
--- a/synapse/handlers/device.py
+++ b/synapse/handlers/device.py
@@ -1124,7 +1124,14 @@ class DeviceListUpdater(DeviceListWorkerUpdater):
                 )
 
             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)