summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erikj@element.io>2024-05-22 13:55:18 +0100
committerGitHub <noreply@github.com>2024-05-22 13:55:18 +0100
commitb71d2774388c90a68d71dd8d805556c8f62c92a1 (patch)
treefcc85d8ed6e18f6db16af4f3d50b9c8eca5f3ac2 /synapse/storage
parentUpdate Lemonldap-NG OIDC config (#17204) (diff)
downloadsynapse-b71d2774388c90a68d71dd8d805556c8f62c92a1.tar.xz
Reduce work of calculating outbound device pokes (#17211)
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/databases/main/devices.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/devices.py b/synapse/storage/databases/main/devices.py

index f4410b5c02..48384e238c 100644 --- a/synapse/storage/databases/main/devices.py +++ b/synapse/storage/databases/main/devices.py
@@ -2161,6 +2161,30 @@ 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 = ? AND NOT converted_to_destinations + """ + + 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,