Skip to content

Wait out SQLITE_BUSY when loading CloudSync on new pool connections. - #6933

Merged
ComputelessComputer merged 1 commit into
mainfrom
fix/cloudsync-connect-lock-logs
Aug 20, 2026
Merged

Wait out SQLITE_BUSY when loading CloudSync on new pool connections.#6933
ComputelessComputer merged 1 commit into
mainfrom
fix/cloudsync-connect-lock-logs

Conversation

@ComputelessComputer

@ComputelessComputer ComputelessComputer commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

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 IMMEDIATE around each load. That transaction fought active writers and caused sqlx after_connect to fail quickly (~270ms) with "database is locked" when the pool grew during normal writes.

Loads now use a short PRAGMA busy_timeout = 50 so SQLite’s C busy handler does not block Tokio workers, then retry load_extension + validation asynchronously with exponential backoff for up to 5 seconds (aligned with app-wide busy handling). Busy detection was extended via is_busy_error so 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.

@netlify

netlify Bot commented Aug 19, 2026

Copy link
Copy Markdown

Deploy Preview for anarlog canceled.

Name Link
🔨 Latest commit 413845e
🔍 Latest deploy log https://app.netlify.com/projects/anarlog/deploys/6a8654845e5a7a00084291f4

@ComputelessComputer
ComputelessComputer force-pushed the fix/cloudsync-connect-lock-logs branch from 5a20cb0 to 08460eb Compare August 19, 2026 19:01
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
ComputelessComputer force-pushed the fix/cloudsync-connect-lock-logs branch from 08460eb to 413845e Compare August 20, 2026 01:12
@ComputelessComputer
ComputelessComputer merged commit 877d511 into main Aug 20, 2026
18 checks passed
@ComputelessComputer
ComputelessComputer deleted the fix/cloudsync-connect-lock-logs branch August 20, 2026 01:25
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.

1 participant