element-hq / element-hq/element-web
Element-R | Resetting key backup takes a long time; and blocks the whole application
- Dominant language
- TypeScript
- Stars
- 13.5k
- Forks
- 2.8k
- PR merge metrics
- PR metrics pending
Description
## Step to reproduce
- Have an account with a lot of keys in local database, wait for all of them to be uploaded to backup
- Go to Security & Privacy and click reset, and follow the step
=> Starting now if you type a message, it won't be sent after several minutes depending on the number of room keys in database
## What is happening
See here https://github.com/element-hq/element-web/issues/26783#issuecomment-1867413139
Basically reseting backup will have to do a big write transaction that will lock the `inbound_group_sessions2` object store for several minutes.
It will also lock all the database due to the rust `save_changes_lock` that is taken when saving changes after a sync
=> Sync will be blocked, sending will be blocked
**ANOTHER PROBLEM**: If you close the tab or refresh the page, the transaction won't be retried so the keys won't be marked to be uploaded to the new backup
## Difference with legacy
The `inbound_group_sessions2` rust object store is bigger (encrypted byte array of lenght ~3700) than the legacy one (json with pickled key of around (string of lenght ~700).
So the rust db gets slower faster
Contributor guide
Assessment
This issue has not been assessed yet.