Reset busy SQLite statements before returning pooled leases - #21
Open
daniel-vacic wants to merge 1 commit into
Open
Reset busy SQLite statements before returning pooled leases#21daniel-vacic wants to merge 1 commit into
daniel-vacic wants to merge 1 commit into
Conversation
daniel-vacic
marked this pull request as ready for review
July 29, 2026 18:24
simolus3
reviewed
Jul 30, 2026
simolus3
left a comment
Collaborator
There was a problem hiding this comment.
My main concern about this is that it masks programming errors: You simply shouldn't return a connection with busy statements or in the middle of a transaction.
While this adds logs, those are still easy to ignore and this can make some errors hard to find. For example, a developer may end up wondering why changes from their transaction disappeared.
A somewhat drastic but IMO not unreasonable action might be to panic!() when a connection is dropped with busy statements or in a transaction. That also provides a backtrace pointing you straight to the source where you forgot to close a transaction or statement. What do you think?
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.
What changed
available again
checkpoint frames while autocommit is true
Root cause
A stepped statement can retain an implicit WAL read transaction while
sqlite3_get_autocommit()still returns true.OwnedConnectionLease::droppreviously returned the connection directly to the pool, so the stale snapshot
could survive indefinitely and cap
nBackfill.This addresses #19. Cleanup runs at the physical pool boundary, after the lease
owner has finished and before another caller can acquire the handle.
Validation
rustup run 1.96.0 cargo test -p powersyncrustup run 1.96.0 cargo test -p powersync --test wal_pool_repro -- --nocapturerustup run 1.96.0 cargo clippy -p powersync --all-targets -- -D warningsrustup run 1.96.0 cargo fmt --all -- --checkThe regression failed before the fix with
log=14, checkpointed=3; afterexplicit finalization it reached
checkpointed=14. It passes with pool-boundarycleanup.