diff options
author | Erik Johnston <erik@matrix.org> | 2020-02-28 11:24:05 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2020-02-28 11:25:34 +0000 |
commit | 9ce4e344a808e15a36a2d9ea03b77ebfc6ac7fe2 (patch) | |
tree | 50df94a33c6d12b1129e89cbf63819f0c570091b /synapse/storage | |
parent | Change device lists stream to have one row per id. (diff) | |
download | synapse-9ce4e344a808e15a36a2d9ea03b77ebfc6ac7fe2.tar.xz |
Change device list replication to match new semantics.
Instead of sending down batches of user ID/host tuples, send down a row per entity (user ID or host).
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/data_stores/main/devices.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/synapse/storage/data_stores/main/devices.py b/synapse/storage/data_stores/main/devices.py index 3299607910..768afe7a6c 100644 --- a/synapse/storage/data_stores/main/devices.py +++ b/synapse/storage/data_stores/main/devices.py @@ -612,15 +612,18 @@ class DeviceWorkerStore(SQLBaseStore): combined list of changes to devices, and which destinations need to be poked. `destination` may be None if no destinations need to be poked. """ - # We do a group by here as there can be a large number of duplicate - # entries, since we throw away device IDs. + + # This query Does The Right Thing where it'll correctly apply the + # bounds to the inner queries. sql = """ - SELECT MAX(stream_id) AS stream_id, user_id, destination - FROM device_lists_stream - LEFT JOIN device_lists_outbound_pokes USING (stream_id, user_id, device_id) + SELECT stream_id, entity FROM ( + SELECT stream_id, user_id AS entity FROM device_lists_stream + UNION ALL + SELECT stream_id, destination AS entity FROM device_lists_outbound_pokes + ) AS e WHERE ? < stream_id AND stream_id <= ? - GROUP BY user_id, destination """ + return self.db.execute( "get_all_device_list_changes_for_remotes", None, sql, from_key, to_key ) |