Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

to_device messages get lost due to to_device stream id not being saved #6311

Closed
dbkr opened this issue Oct 31, 2019 · 4 comments
Closed

to_device messages get lost due to to_device stream id not being saved #6311

dbkr opened this issue Oct 31, 2019 · 4 comments
Assignees
Labels
z-bug (Deprecated Label)

Comments

@dbkr
Copy link
Member

dbkr commented Oct 31, 2019

In schema delta 35, synapse added an entry into the device_max_stream_id table (https://github.com/matrix-org/synapse/blob/develop/synapse/storage/data_stores/main/schema/delta/35/device_stream_id.sql). Full schema 54 has now been cut which means this schema delta file isn't being run for new installs as of 1.0 (when full schema 54 was released) so it looks like these synapse installs never get an entry in device_max_stream_id. It's written to by an UPDATE clause so no entry is created if one doesn't already exist.

It doesn't look like it gets created anywhere else. If not, this means the device stream token resets any time synapse is restarted which causes to_device messages to go missing, causing Unable To Decrypt errors.

Same bug may apply to appservice_stream as that appears to do the same thing

@neilisfragile neilisfragile added p1 z-bug (Deprecated Label) labels Oct 31, 2019
@richvdh richvdh changed the title to_device token not saved to_device messages get lost due to to_device stream id not being saved Oct 31, 2019
@erikjohnston
Copy link
Member

We probably want to go and audit all tables that expect to have a row in them.

The easiest fix for this is probably to upsert rather than update. Now that we have native upsert support that should not have too much of a performance penalty.

@anoadragon453
Copy link
Member

A fix for this is available here: #6375 It fixes the schema instead of using an UPSERT.

Closing this one and made another issue for investigating related tables: #6381

@anoadragon453
Copy link
Member

Err, actually I'll wait until that PR is closed huh.

@anoadragon453
Copy link
Member

This should be fixed for this specific instance by #6555

appservice_stream and others is covered by

INSERT INTO appservice_stream_position (stream_ordering) SELECT COALESCE(MAX(stream_ordering), 0) FROM events;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
z-bug (Deprecated Label)
Projects
None yet
Development

No branches or pull requests

4 participants