Repository navigation
fix(jdbc): match xerial transaction begin and re-begin lifecycle - #64
Merged
Merged
Conversation
magnusp
force-pushed
the
fix/40-transaction-lifecycle
branch
from
October 21, 2026 22:12
fb7260f to
ebefc87
Compare
magnusp
force-pushed
the
fix/40-transaction-lifecycle
branch
from
October 21, 2026 22:15
ebefc87 to
7ec6a5d
Compare
This was referenced Oct 22, 2026
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.
Closes #40. Part of #54.
What changed
setAutoCommit(false)now begins a transaction immediately in the configured mode instead of waiting for the first statement.LibsqlConnection.TransactionMode(DEFERRED,IMMEDIATE,EXCLUSIVE) withsetTransactionMode(...)/getTransactionMode(). The default isDEFERRED, matching xerial 3.53.4.0.commit()androllback()now send the end command and the nextBEGINin one pipeline request, so a non-auto-commit connection always has the next transaction open.setAutoCommit(true)commits the open transaction and closes the Hrana stream without starting another transaction.COMMIT/ROLLBACKstill throws and keeps the transaction stream for a retry. Nothing here depends on rollback swallowing errors.setAutoCommit.TransactionLifecycleITconcurrency tests against sqld for the documented lock behavior.Contract decision
Parity with xerial 3.53.4.0
SQLiteConnection.setAutoCommit/commit/rollback:DEFERRED;commit()/rollback()end the current transaction and immediately begin the next one;DEFERREDtransaction holds no lock, whileIMMEDIATE/EXCLUSIVEacquire the write lock at begin.This replaces the driver's previous read-write
BEGIN IMMEDIATEdefault with xerial'sDEFERREDdefault. Callers that want the old lock behavior can selectIMMEDIATEthroughsetTransactionMode.Evidence
Failing before the fix (old
LibsqlConnection, new unit tests):Passing after the fix:
DOCKER_CONFIG=/tmp/docker-configuses an empty public-image auth file because the sandbox blocks~/.docker/config.json(AGENTS.md section 4). It does not change test behavior.Deviations
LibsqlConnection.java, so the mode is exposed asLibsqlConnection.setTransactionMode(...)rather than as a JDBC URL property /LibsqlClientConfigfield. Begin timing, default mode, and lock behavior match xerial; URL-based configuration of the mode would require changes in the URL parser and client config.COMMIT/ROLLBACKand the followingBEGINare sent as two execute steps in one Hrana pipeline request. This produces the same observable state as xerial's two calls while avoiding an extra round trip. The stream is closed only when auto-commit is re-enabled, as required to keep the next transaction open.Out-of-scope defects
IMPLEMENTATION_BUGS_AND_RESOLUTIONS.mdstill describesBEGIN IMMEDIATEas the read-write default. It is now stale after this parity change, but documentation files are outside this lane's owned files.