summary refs log tree commit diff
path: root/synapse/storage/databases/main/devices.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2024-05-17 17:38:44 +0100
committerErik Johnston <erik@matrix.org>2024-05-17 17:38:44 +0100
commit689666c4ba2702852fe71d2959d3e8c67047a0fd (patch)
tree6d6bf89607909c2ec60fa76c48c292264973843f /synapse/storage/databases/main/devices.py
parentRevert "Improve perf of sync device lists" (#17207) (diff)
downloadsynapse-689666c4ba2702852fe71d2959d3e8c67047a0fd.tar.xz
Reduce work of calculating outbound device pokes
Diffstat (limited to 'synapse/storage/databases/main/devices.py')
-rw-r--r--synapse/storage/databases/main/devices.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/devices.py b/synapse/storage/databases/main/devices.py

index 8dbcb3f5a0..5bec9c9e5f 100644 --- a/synapse/storage/databases/main/devices.py +++ b/synapse/storage/databases/main/devices.py
@@ -2118,6 +2118,29 @@ class DeviceStore(DeviceWorkerStore, DeviceBackgroundUpdateStore): }, ) + async def mark_redundant_device_lists_pokes( + self, + user_id: str, + device_id: str, + room_id: str, + converted_upto_stream_id: int, + ) -> None: + """If we've calculated the outbound pokes for a given room/device list + update, mark any subsequent changes as already converted""" + + sql = """ + UPDATE device_lists_changes_in_room + SET converted_to_destinations = true + WHERE stream_id > ? AND user_id = ? and device_id = ? AND room_id = ?; + """ + + def mark_redundant_device_lists_pokes_txn(txn: LoggingTransaction) -> None: + txn.execute(sql, (converted_upto_stream_id, user_id, device_id, room_id)) + + return await self.db_pool.runInteraction( + "mark_redundant_device_lists_pokes", mark_redundant_device_lists_pokes_txn + ) + def _add_device_outbound_room_poke_txn( self, txn: LoggingTransaction,