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

Prevent overlapping sync accumulator persists #2392

Merged
merged 3 commits into from
May 21, 2022

Conversation

ara4n
Copy link
Member

@ara4n ara4n commented May 21, 2022

Adds a flag to stop the sync worker trying to persist to indexeddb if there is already a persist in flight. This means that if indexeddb is being very slow (e.g. due to the browser running for a few seconds every ~10 mins while a macbook is asleep), you won't end up with overlapping write operations to indexeddb which could consume heap and cause an OOM. It's okay to do this in the sync worker rather than the main thread, as it turns out that all the accumulation happens inside the worker, so we never pass large accumulated sync responses over postmessage to the worker.

If the persist is skipped, we accumulate user presence updates in RAM to stop them being lost (given the sync accumulator doesn't handle them itself for some reason).

Hopefully fixes element-hq/element-desktop#680


Here's what your changelog entry will look like:

🐛 Bug Fixes

add a flag to stop the sync worker trying to persist to indexeddb
if there are already persists in flight. accumulates user presence
updates in RAM to stop them being lost if the persist is skipped.

hopefully fixes https://github.com/vector-im/element-web/issues/21541
@ara4n ara4n requested a review from a team as a code owner May 21, 2022 11:56
Copy link
Contributor

@SimonBrandner SimonBrandner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM!

src/store/indexeddb-local-backend.ts Outdated Show resolved Hide resolved
@ara4n
Copy link
Member Author

ara4n commented May 21, 2022

going to merge this so i don't have to run a custom Nightly to see if it's fixed things.

@ara4n ara4n enabled auto-merge May 21, 2022 13:27
@ara4n ara4n merged commit 25afb7c into develop May 21, 2022
@ara4n ara4n deleted the matthew/fix-sync-acc-overlap branch May 21, 2022 13:32
su-ex added a commit to SchildiChat/matrix-js-sdk that referenced this pull request Jun 7, 2022
* Convert `getLocalAliases` to a stable API call ([\matrix-org#2402](matrix-org#2402)).
* Fix request, crypto, and bs58 imports ([\matrix-org#2414](matrix-org#2414)). Fixes matrix-org#2415.
* Update relations after every decryption attempt ([\matrix-org#2387](matrix-org#2387)). Fixes element-hq/element-web#22258. Contributed by @weeman1337.
* Fix degraded mode for the IDBStore and test it ([\matrix-org#2400](matrix-org#2400)). Fixes matrix-org/element-web-rageshakes#13170.
* Don't cancel SAS verifications if `ready` is received after `start` ([\matrix-org#2250](matrix-org#2250)).
* Prevent overlapping sync accumulator persists ([\matrix-org#2392](matrix-org#2392)). Fixes vector-im/element-web#21541.
* Fix behaviour of isRelation with relation m.replace for state events ([\matrix-org#2389](matrix-org#2389)). Fixes element-hq/element-web#22280.
* Fixes matrix-org#2384 ([\matrix-org#2385](matrix-org#2385)). Fixes undefined/matrix-js-sdk#2384. Contributed by @schmop.
* Ensure rooms are recalculated on re-invites ([\matrix-org#2374](matrix-org#2374)). Fixes element-hq/element-web#22106.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On un-sleeping laptop, element desktop sometimes goes entirely white (because EW has OOMed during the night)
3 participants