diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2021-06-07 09:19:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-07 09:19:06 +0100 |
commit | fa1db8f1567471e6cb29c0d6c0b740fcb79ea202 (patch) | |
tree | 51b29f6ea1b3d506dbb83b934d7208d7c7814327 /synapse/handlers/sync.py | |
parent | Don't try and backfill the same room in parallel. (#10116) (diff) | |
download | synapse-fa1db8f1567471e6cb29c0d6c0b740fcb79ea202.tar.xz |
Delete completes to-device messages earlier in /sync (#10124)
I hope this will improve https://github.com/matrix-org/synapse/issues/9564.
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/sync.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 069ffc76f7..b1c58ffdc8 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -315,6 +315,17 @@ class SyncHandler: if context: context.tag = sync_type + # if we have a since token, delete any to-device messages before that token + # (since we now know that the device has received them) + if since_token is not None: + since_stream_id = since_token.to_device_key + deleted = await self.store.delete_messages_for_device( + sync_config.user.to_string(), sync_config.device_id, since_stream_id + ) + logger.debug( + "Deleted %d to-device messages up to %d", deleted, since_stream_id + ) + if timeout == 0 or since_token is None or full_state: # we are going to return immediately, so don't bother calling # notifier.wait_for_events. @@ -1230,16 +1241,6 @@ class SyncHandler: since_stream_id = int(sync_result_builder.since_token.to_device_key) if since_stream_id != int(now_token.to_device_key): - # We only delete messages when a new message comes in, but that's - # fine so long as we delete them at some point. - - deleted = await self.store.delete_messages_for_device( - user_id, device_id, since_stream_id - ) - logger.debug( - "Deleted %d to-device messages up to %d", deleted, since_stream_id - ) - messages, stream_id = await self.store.get_new_messages_for_device( user_id, device_id, since_stream_id, now_token.to_device_key ) |