Skip to content

[Feature] Implement web sync locks #119

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

Merged
merged 5 commits into from
Jul 10, 2024
Merged

Conversation

stevensJourney
Copy link
Contributor

@stevensJourney stevensJourney commented Jul 9, 2024

Overview

This uses the Navigator locks in the Mutex class from here powersync-ja/sqlite_async.dart#54 to limit the number of active sync implementations when multiple tabs are used.

This is only a stop-gap to prevent multiple tabs with multiple StreamingSyncImplementations from applying sync bucket changes at the same time (this can leave the local SQLite DB in an inconsistent or broken state).

This method enhances the safety of using multiple tabs, but is far from complete multiple tab support.

This should address the issue of "Flutter web + PowerSync still has the issue where multiple open tabs will cause sqlite to get messed up" from #11

Testing

Note that the app works when switching between tabs. The sync status is isolated per tab - only 1 tab is ever connected or uploading at a time.

locked_tabs.mp4

Todos:

  • Update sqlite_async package

Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

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

The approach here looks good to me

@stevensJourney stevensJourney mentioned this pull request Jul 9, 2024
 - powersync@1.3.0-alpha.9
 - powersync_attachments_helper@0.3.0-alpha.4
@stevensJourney stevensJourney merged commit ecc9c22 into alpha-release Jul 10, 2024
5 checks passed
@stevensJourney stevensJourney deleted the sync-locks branch July 10, 2024 16:47
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

Successfully merging this pull request may close these issues.

3 participants