Reset the statement when a step fails - #116
Open
ninjapanzer wants to merge 2 commits into
Open
ninjapanzer wants to merge 2 commits into
ninjapanzer wants to merge 2 commits into
Conversation
straight-shoota
approved these changes
Sep 3, 2026
Agreed, thanks. Co-authored-by: Johannes Müller <straightshoota@gmail.com>
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.
perform_execraises when a step does not returnSQLITE_DONEwithout callingsqlite3_resetfirst, so the statement is left active on the connection, which blocksCOMMITand holds the connection's implicit read transaction open until something happens to reset it. This resets on the failure path, building the exception first because it readserrmsg/errcodeoff the connection handle.Fixes #115, where there is a standalone reproduction and the measurements behind the two things that make this awkward to reproduce by hand.
Testing:
spec/statement_reset_spec.cragainst currentmaster:3 examples, 2 failures, 1 errors.334 examples, 0 failures, up from a331 examples, 0 failuresbaseline, andcrystal tool formatis clean.v0.23.0,masterand the branch: the first two are identical, the third shows 0 active statements, three transactions committing, and the reader tracking a peer writer atdata_version3, 4, 5, 6 instead of holding 2.masterthe reader shows one body across four peer commits and the peer'swal_checkpoint(TRUNCATE)returnsbusy=1and copies nothing, on the branch both track correctly and the WAL truncates to 0 bytes.834 examples, 0 failures, including its own specs written around the un-patched behaviour.Crystal 1.19.1, SQLite 3.53.3, crystal-db 0.14.0, Linux.