mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-12 14:02:14 -04:00
Fix device list update stream ids going backward (#7158)
Occasionally we could get a federation device list update transaction which looked like: ``` [ {'edu_type': 'm.device_list_update', 'content': {'user_id': '@user:test', 'device_id': 'D2', 'prev_id': [], 'stream_id': 12, 'deleted': True}}, {'edu_type': 'm.device_list_update', 'content': {'user_id': '@user:test', 'device_id': 'D1', 'prev_id': [12], 'stream_id': 11, 'deleted': True}}, {'edu_type': 'm.device_list_update', 'content': {'user_id': '@user:test', 'device_id': 'D3', 'prev_id': [11], 'stream_id': 13, 'deleted': True}} ] ``` Having `stream_ids` which are lower than `prev_ids` looks odd. It might work (I'm not actually sure), but in any case it doesn't seem like a reasonable thing to expect other implementations to support.
This commit is contained in:
parent
61bb834364
commit
daa1ac89a0
3 changed files with 15 additions and 2 deletions
|
@ -165,7 +165,6 @@ class DeviceWorkerStore(SQLBaseStore):
|
|||
# the max stream_id across each set of duplicate entries
|
||||
#
|
||||
# maps (user_id, device_id) -> (stream_id, opentracing_context)
|
||||
# as long as their stream_id does not match that of the last row
|
||||
#
|
||||
# opentracing_context contains the opentracing metadata for the request
|
||||
# that created the poke
|
||||
|
@ -270,7 +269,14 @@ class DeviceWorkerStore(SQLBaseStore):
|
|||
prev_id = yield self._get_last_device_update_for_remote_user(
|
||||
destination, user_id, from_stream_id
|
||||
)
|
||||
for device_id, device in iteritems(user_devices):
|
||||
|
||||
# make sure we go through the devices in stream order
|
||||
device_ids = sorted(
|
||||
user_devices.keys(), key=lambda i: query_map[(user_id, i)][0],
|
||||
)
|
||||
|
||||
for device_id in device_ids:
|
||||
device = user_devices[device_id]
|
||||
stream_id, opentracing_context = query_map[(user_id, device_id)]
|
||||
result = {
|
||||
"user_id": user_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue