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/replication/slave/storage/devices.py | |
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/replication/slave/storage/devices.py')
-rw-r--r-- | synapse/replication/slave/storage/devices.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/synapse/replication/slave/storage/devices.py b/synapse/replication/slave/storage/devices.py index bf46cc4f8a..01a4f85884 100644 --- a/synapse/replication/slave/storage/devices.py +++ b/synapse/replication/slave/storage/devices.py @@ -61,23 +61,24 @@ class SlavedDeviceStore(EndToEndKeyWorkerStore, DeviceWorkerStore, BaseSlavedSto def process_replication_rows(self, stream_name, token, rows): if stream_name == DeviceListsStream.NAME: self._device_list_id_gen.advance(token) - for row in rows: - self._invalidate_caches_for_devices(token, row.user_id, row.destination) + self._invalidate_caches_for_devices(token, rows) elif stream_name == UserSignatureStream.NAME: + self._device_list_id_gen.advance(token) for row in rows: self._user_signature_stream_cache.entity_has_changed(row.user_id, token) return super(SlavedDeviceStore, self).process_replication_rows( stream_name, token, rows ) - def _invalidate_caches_for_devices(self, token, user_id, destination): - self._device_list_stream_cache.entity_has_changed(user_id, token) - - if destination: - self._device_list_federation_stream_cache.entity_has_changed( - destination, token - ) + def _invalidate_caches_for_devices(self, token, rows): + for row in rows: + if row.entity.startswith("@"): + self._device_list_stream_cache.entity_has_changed(row.entity, token) + self.get_cached_devices_for_user.invalidate((row.entity,)) + self._get_cached_user_device.invalidate_many((row.entity,)) + self.get_device_list_last_stream_id_for_remote.invalidate((row.entity,)) - self.get_cached_devices_for_user.invalidate((user_id,)) - self._get_cached_user_device.invalidate_many((user_id,)) - self.get_device_list_last_stream_id_for_remote.invalidate((user_id,)) + else: + self._device_list_federation_stream_cache.entity_has_changed( + row.entity, token + ) |