summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-03-01 10:21:30 +0000
committerErik Johnston <erik@matrix.org>2017-03-01 10:21:30 +0000
commit3365117151217f0ea96291aabce222f8b58bd850 (patch)
tree16c5254f094a69f90af5b2aa524bca5bb8c95fe1 /synapse/storage
parentDon't log unknown cache warnings in workers (diff)
downloadsynapse-3365117151217f0ea96291aabce222f8b58bd850.tar.xz
Clobber old device list stream entries
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/devices.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/synapse/storage/devices.py b/synapse/storage/devices.py
index 7b5903bf8e..f9ed18d2aa 100644
--- a/synapse/storage/devices.py
+++ b/synapse/storage/devices.py
@@ -546,6 +546,16 @@ class DeviceStore(SQLBaseStore):
                 host, stream_id,
             )
 
+        # Delete older entries in the table, as we really only care about
+        # when the latest change happened.
+        txn.executemany(
+            """
+            DELETE FROM device_lists_stream
+            WHERE user_id = ? AND device_id = ? AND stream_id < ?
+            """,
+            [(user_id, device_id, stream_id) for device_id in device_ids]
+        )
+
         self._simple_insert_many_txn(
             txn,
             table="device_lists_stream",