Add debugging to help diagnose lost device-list-update (#14268)

This commit is contained in:
Richard van der Hoff 2022-10-24 10:45:10 +01:00 committed by GitHub
parent 6c82b3759f
commit 1469fed0e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 17 deletions

1
changelog.d/14268.misc Normal file
View file

@ -0,0 +1 @@
Add debugging to help diagnose lost device-list-update.

View file

@ -274,6 +274,13 @@ class DeviceWorkerStore(RoomMemberWorkerStore, EndToEndKeyWorkerStore):
destination, int(from_stream_id) destination, int(from_stream_id)
) )
if not has_changed: if not has_changed:
# debugging for https://github.com/matrix-org/synapse/issues/14251
issue_8631_logger.debug(
"%s: no change between %i and %i",
destination,
from_stream_id,
now_stream_id,
)
return now_stream_id, [] return now_stream_id, []
updates = await self.db_pool.runInteraction( updates = await self.db_pool.runInteraction(
@ -1848,7 +1855,7 @@ class DeviceStore(DeviceWorkerStore, DeviceBackgroundUpdateStore):
self, self,
txn: LoggingTransaction, txn: LoggingTransaction,
user_id: str, user_id: str,
device_ids: Iterable[str], device_id: str,
hosts: Collection[str], hosts: Collection[str],
stream_ids: List[int], stream_ids: List[int],
context: Optional[Dict[str, str]], context: Optional[Dict[str, str]],
@ -1864,6 +1871,21 @@ class DeviceStore(DeviceWorkerStore, DeviceBackgroundUpdateStore):
stream_id_iterator = iter(stream_ids) stream_id_iterator = iter(stream_ids)
encoded_context = json_encoder.encode(context) encoded_context = json_encoder.encode(context)
mark_sent = not self.hs.is_mine_id(user_id)
values = [
(
destination,
next(stream_id_iterator),
user_id,
device_id,
mark_sent,
now,
encoded_context if whitelisted_homeserver(destination) else "{}",
)
for destination in hosts
]
self.db_pool.simple_insert_many_txn( self.db_pool.simple_insert_many_txn(
txn, txn,
table="device_lists_outbound_pokes", table="device_lists_outbound_pokes",
@ -1876,23 +1898,21 @@ class DeviceStore(DeviceWorkerStore, DeviceBackgroundUpdateStore):
"ts", "ts",
"opentracing_context", "opentracing_context",
), ),
values=[ values=values,
(
destination,
next(stream_id_iterator),
user_id,
device_id,
not self.hs.is_mine_id(
user_id
), # We only need to send out update for *our* users
now,
encoded_context if whitelisted_homeserver(destination) else "{}",
)
for destination in hosts
for device_id in device_ids
],
) )
# debugging for https://github.com/matrix-org/synapse/issues/14251
if issue_8631_logger.isEnabledFor(logging.DEBUG):
issue_8631_logger.debug(
"Recorded outbound pokes for %s:%s with device stream ids %s",
user_id,
device_id,
{
stream_id: destination
for (destination, stream_id, _, _, _, _, _) in values
},
)
def _add_device_outbound_room_poke_txn( def _add_device_outbound_room_poke_txn(
self, self,
txn: LoggingTransaction, txn: LoggingTransaction,
@ -1997,7 +2017,7 @@ class DeviceStore(DeviceWorkerStore, DeviceBackgroundUpdateStore):
self._add_device_outbound_poke_to_stream_txn( self._add_device_outbound_poke_to_stream_txn(
txn, txn,
user_id=user_id, user_id=user_id,
device_ids=[device_id], device_id=device_id,
hosts=hosts, hosts=hosts,
stream_ids=stream_ids, stream_ids=stream_ids,
context=context, context=context,