Wait out SQLITE_BUSY when loading CloudSync on new pool connections. - #6933
Merged
Conversation
✅ Deploy Preview for anarlog canceled.
|
ComputelessComputer
force-pushed
the
fix/cloudsync-connect-lock-logs
branch
from
August 19, 2026 19:01
5a20cb0 to
08460eb
Compare
after_connect no longer takes BEGIN IMMEDIATE just to load the extension, so in-flight writers do not make sqlx log "database is locked" while the pool grows.
ComputelessComputer
force-pushed
the
fix/cloudsync-connect-lock-logs
branch
from
August 20, 2026 01:12
08460eb to
413845e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
after_connect gave up on BEGIN IMMEDIATE after ~270ms, so sqlx retried the whole connect and logged "database is locked" during normal desktop writes.
Note
Medium Risk
Touches connection initialization and SQLite locking behavior on every new pool connection with CloudSync enabled; wrong retry/classification could delay connects or mask real load failures.
Overview
CloudSync sqlite-sync extension loading no longer wraps
BEGIN IMMEDIATEaround each load. That transaction fought active writers and caused sqlxafter_connectto fail quickly (~270ms) with "database is locked" when the pool grew during normal writes.Loads now use a short
PRAGMA busy_timeout = 50so SQLite’s C busy handler does not block Tokio workers, then retryload_extension+ validation asynchronously with exponential backoff for up to 5 seconds (aligned with app-wide busy handling). Busy detection was extended viais_busy_errorso extension-load failures that surface as locked-database messages are retried, not only raw sqlx busy codes.The db-core integration test for concurrent pool acquires under a held writer was adjusted: it no longer depends on a fixed 90ms delay before commit, matching the new willingness to wait on busy during connect.
Reviewed by Cursor Bugbot for commit 08460eb. Bugbot is set up for automated code reviews on this repo. Configure here.