mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-28 07:00:51 +03:00
Reduce work of calculating outbound device pokes (#17211)
This commit is contained in:
parent
a547b49773
commit
b71d277438
3 changed files with 32 additions and 0 deletions
1
changelog.d/17211.misc
Normal file
1
changelog.d/17211.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Reduce work of calculating outbound device lists updates.
|
|
@ -906,6 +906,13 @@ class DeviceHandler(DeviceWorkerHandler):
|
||||||
context=opentracing_context,
|
context=opentracing_context,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await self.store.mark_redundant_device_lists_pokes(
|
||||||
|
user_id=user_id,
|
||||||
|
device_id=device_id,
|
||||||
|
room_id=room_id,
|
||||||
|
converted_upto_stream_id=stream_id,
|
||||||
|
)
|
||||||
|
|
||||||
# Notify replication that we've updated the device list stream.
|
# Notify replication that we've updated the device list stream.
|
||||||
self.notifier.notify_replication()
|
self.notifier.notify_replication()
|
||||||
|
|
||||||
|
|
|
@ -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(
|
def _add_device_outbound_room_poke_txn(
|
||||||
self,
|
self,
|
||||||
txn: LoggingTransaction,
|
txn: LoggingTransaction,
|
||||||
|
|
Loading…
Reference in a new issue