summary refs log tree commit diff
path: root/synapse/storage/devices.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-01-31 10:08:55 +0000
committerErik Johnston <erik@matrix.org>2017-01-31 10:08:55 +0000
commit05b9f48ee577f1cbdd5c5837f22c0d9cbe4c44cc (patch)
treed95d78c25e1671e51f471f00b43bfb8bdce24cda /synapse/storage/devices.py
parentDon't have such a large cache (diff)
downloadsynapse-05b9f48ee577f1cbdd5c5837f22c0d9cbe4c44cc.tar.xz
Fix clearing out old device list outbound pokes
Diffstat (limited to 'synapse/storage/devices.py')
-rw-r--r--synapse/storage/devices.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/synapse/storage/devices.py b/synapse/storage/devices.py
index f0353929da..e6fe67ee25 100644
--- a/synapse/storage/devices.py
+++ b/synapse/storage/devices.py
@@ -545,7 +545,7 @@ class DeviceStore(SQLBaseStore):
         (destination, user_id) tuple to ensure that the prev_ids remain correct
         if the server does come back.
         """
-        now = self._clock.time_msec()
+        yesterday = self._clock.time_msec() - 24 * 60 * 60 * 1000
 
         def _prune_txn(txn):
             select_sql = """
@@ -557,6 +557,9 @@ class DeviceStore(SQLBaseStore):
             txn.execute(select_sql)
             rows = txn.fetchall()
 
+            if not rows:
+                return
+
             delete_sql = """
                 DELETE FROM device_lists_outbound_pokes
                 WHERE ts < ? AND destination = ? AND user_id = ? AND stream_id < ?
@@ -565,11 +568,13 @@ class DeviceStore(SQLBaseStore):
             txn.executemany(
                 delete_sql,
                 (
-                    (now, row["destination"], row["user_id"], row["stream_id"])
+                    (yesterday, row[0], row[1], row[2])
                     for row in rows
                 )
             )
 
+            logger.info("Pruned %d device list outbound pokes", txn.rowcount)
+
         return self.runInteraction(
             "_prune_old_outbound_device_pokes", _prune_txn
         )