summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-01-30 10:11:46 +0000
committerErik Johnston <erik@matrix.org>2017-01-30 10:14:25 +0000
commit76100203aba979e21f3831e3a675ae4e3d578ad4 (patch)
treeb60c7fa8d770e6c1c546cf276e977b8d894e3b88 /synapse/storage
parentAdd ts column to device_lists_outbound_pokes (diff)
downloadsynapse-76100203aba979e21f3831e3a675ae4e3d578ad4.tar.xz
Always use the latest stream_id, sent or unsent
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/devices.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/synapse/storage/devices.py b/synapse/storage/devices.py
index 89c7bc0cc0..d72f60d94b 100644
--- a/synapse/storage/devices.py
+++ b/synapse/storage/devices.py
@@ -280,14 +280,14 @@ class DeviceStore(SQLBaseStore):
         prev_sent_id_sql = """
             SELECT coalesce(max(stream_id), 0) as stream_id
             FROM device_lists_outbound_pokes
-            WHERE destination = ? AND user_id = ? AND sent = ?
+            WHERE destination = ? AND user_id = ? AND stream_id <= ?
         """
 
         results = []
         for user_id, user_devices in devices.iteritems():
-            # We bind literal True, as its database dependent how booleans are
-            # handled.
-            txn.execute(prev_sent_id_sql, (destination, user_id, True))
+            # The prev_id for the first row is always the last row before
+            # `from_stream_id`
+            txn.execute(prev_sent_id_sql, (destination, user_id, from_stream_id))
             rows = txn.fetchall()
             prev_id = rows[0][0]
             for device_id, device in user_devices.iteritems():