summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-03-07 16:04:24 +0000
committerErik Johnston <erik@matrix.org>2019-03-07 16:04:24 +0000
commitd42b41544a3d8950f2a804703aa4ad311e9feddd (patch)
treecc3f0cf5fbbb45848bbb7422077de7edfcba83e2
parentMerge pull request #4824 from matrix-org/rav/docker_docs (diff)
downloadsynapse-d42b41544a3d8950f2a804703aa4ad311e9feddd.tar.xz
When re-syncing device lists reset the state
We keep track of what stream IDs we've seen so that we know what updates
we've handled or missed. If we re-sync we don't know if the updates
we've seen are included in the re-sync (there may be a race), so we
should reset the seen updates.
-rw-r--r--synapse/handlers/device.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py
index c09a7c6280..00f12ba40d 100644
--- a/synapse/handlers/device.py
+++ b/synapse/handlers/device.py
@@ -566,6 +566,10 @@ class DeviceListEduUpdater(object):
                 )
                 device_ids = [device["device_id"] for device in devices]
                 yield self.device_handler.notify_device_update(user_id, device_ids)
+
+                # We clobber the seen updates since we've re-synced from a given
+                # point.
+                self._seen_updates[user_id] = set([stream_id])
             else:
                 # Simply update the single device, since we know that is the only
                 # change (because of the single prev_id matching the current cache)
@@ -578,9 +582,9 @@ class DeviceListEduUpdater(object):
                     user_id, [device_id for device_id, _, _, _ in pending_updates]
                 )
 
-            self._seen_updates.setdefault(user_id, set()).update(
-                stream_id for _, stream_id, _, _ in pending_updates
-            )
+                self._seen_updates.setdefault(user_id, set()).update(
+                    stream_id for _, stream_id, _, _ in pending_updates
+                )
 
     @defer.inlineCallbacks
     def _need_to_do_resync(self, user_id, updates):