Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

A couple of replication fixes for device lists #4109

Merged
merged 3 commits into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/4109.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce replication traffic for device lists
4 changes: 2 additions & 2 deletions synapse/replication/tcp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def transport_kernel_read_buffer_size(protocol, read=True):
"",
["command", "name"],
lambda: {
(k[0], p.name,): count
(k, p.name,): count
for p in connected_connections
for k, count in iteritems(p.inbound_commands_counter)
},
Expand All @@ -667,7 +667,7 @@ def transport_kernel_read_buffer_size(protocol, read=True):
"",
["command", "name"],
lambda: {
(k[0], p.name,): count
(k, p.name,): count
for p in connected_connections
for k, count in iteritems(p.outbound_commands_counter)
},
Expand Down
6 changes: 5 additions & 1 deletion synapse/storage/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,14 @@ def get_all_device_list_changes_for_remotes(self, from_key, to_key):
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.
sql = """
SELECT stream_id, user_id, destination FROM device_lists_stream
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)
WHERE ? < stream_id AND stream_id <= ?
GROUP BY user_id, destination
"""
return self._execute(
"get_all_device_list_changes_for_remotes", None,
Expand Down