Skip to content

Fix deadlock on immediate connect call #272

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 2 commits into from
Apr 25, 2025
Merged

Fix deadlock on immediate connect call #272

merged 2 commits into from
Apr 25, 2025

Conversation

simolus3
Copy link
Contributor

In the connectInternal() method used to establish a connection to the sync service, we await initialize(). That can be a problem when connect() is the first call on the database, because writing the schema also acquires the lock used to guard connectInternal().

This fixes the issue by awaiting initialize() in connect(), before acquiring the sync connect lock and calling initialize(). I've also added a test calling connect() immediately after opening the database to validate this.

This is the second time I get to fix this exact regression, yikes 😬 At least in Kotlin we've not seen too many concurrency issues after that though...

 - powersync_core@1.2.4
 - powersync_attachments_helper@0.6.18+6
 - powersync_sqlcipher@0.1.5+4
 - powersync@1.12.4
@simolus3 simolus3 merged commit 83b82c9 into main Apr 25, 2025
11 checks passed
@simolus3 simolus3 deleted the fix-connect-on-open branch April 25, 2025 10:34
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.

2 participants