Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropping the database can drop to-device messages going forwards #448

Closed
kegsay opened this issue Jun 3, 2024 · 0 comments
Closed

Dropping the database can drop to-device messages going forwards #448

kegsay opened this issue Jun 3, 2024 · 0 comments
Assignees

Comments

@kegsay
Copy link
Member

kegsay commented Jun 3, 2024

Ideally the database should not be dropped, but there may be circumstances where a server admin wants to do this. Currently, we do not provide guidelines on what should be kept/not, beyond "keep to-device events and device data or else E2EE breaks". This has been informal and not written down anywhere.

Unfortunately, after debugging another cause of UTDs, it has come to my attention that this is insufficient. It is critical that the syncv3_to_device_messages_seq sequence IS NOT DROPPED. If it is, it will cause to-device events to be dropped and not delivered to the client, causing unable-to-decrypt messages (UTDs). The reasoning for this is as follows:

  • The sequence encodes a stream of to-device events
  • When the client asks for to-device events, the proxy delivers all to-device events > the client-provided position. This position defaults to 0.
  • If the sequence gets dropped, the positions reset to 0, but the client is still using higher positions.
  • This means no new to-device events are delivered (as the new events are <= the client-provided position).
  • Worst of all, it deletes new to-device events because acknowledged to-device events delete all events <= the client-provided position.

This will persistently cause UTDs until the sequence has caught up to the client provided position.

@kegsay kegsay self-assigned this Jun 3, 2024
kegsay added a commit that referenced this issue Jun 4, 2024
Helps fix the worst of #448
@kegsay kegsay changed the title Provide documentation to drop the database safely Dropping the database can drop to-device messages going forwards Jun 5, 2024
@kegsay kegsay closed this as completed in 09be2d1 Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant