diff options
author | Erik Johnston <erik@matrix.org> | 2017-03-24 14:44:49 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2017-03-24 14:44:49 +0000 |
commit | 2a28b79e04531f2630432e6a710db3ddc434ad8e (patch) | |
tree | 853e025f9ca0d8587c3c4d612572159f4f8b47bf | |
parent | Merge pull request #2062 from matrix-org/erikj/presence_replication (diff) | |
download | synapse-2a28b79e04531f2630432e6a710db3ddc434ad8e.tar.xz |
Batch sending of device list pokes
-rw-r--r-- | synapse/federation/transaction_queue.py | 1 | ||||
-rw-r--r-- | synapse/storage/devices.py | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/synapse/federation/transaction_queue.py b/synapse/federation/transaction_queue.py index d7ecefcc64..2c96475b2a 100644 --- a/synapse/federation/transaction_queue.py +++ b/synapse/federation/transaction_queue.py @@ -309,6 +309,7 @@ class TransactionQueue(object): # XXX: what's this for? yield run_on_reactor() + pending_pdus = [] while True: device_message_edus, device_stream_id, dev_list_id = ( yield self._get_new_device_messages(destination) diff --git a/synapse/storage/devices.py b/synapse/storage/devices.py index 6beeff8b00..53e36791d5 100644 --- a/synapse/storage/devices.py +++ b/synapse/storage/devices.py @@ -329,6 +329,7 @@ class DeviceStore(SQLBaseStore): SELECT user_id, device_id, max(stream_id) FROM device_lists_outbound_pokes WHERE destination = ? AND ? < stream_id AND stream_id <= ? AND sent = ? GROUP BY user_id, device_id + LIMIT 20 """ txn.execute( sql, (destination, from_stream_id, now_stream_id, False) @@ -339,6 +340,9 @@ class DeviceStore(SQLBaseStore): if not query_map: return (now_stream_id, []) + if len(query_map) >= 20: + now_stream_id = max(stream_id for stream_id in query_map.itervalues()) + devices = self._get_e2e_device_keys_txn( txn, query_map.keys(), include_all_devices=True ) |