Repository navigation
Add SessionBuilder.Interleave - #25
Merged
Merged
Conversation
Interleave lets statements and transactions run while an application transaction is open, instead of waiting for it: a statement outside the transaction runs inside it in a savepoint of its own, and a transaction begun meanwhile nests inside it. Nested transactions that end out of order fail with ErrTxOrder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #25 +/- ##
==========================================
- Coverage 93.08% 92.47% -0.62%
==========================================
Files 7 7
Lines 376 425 +49
==========================================
+ Hits 350 393 +43
- Misses 14 17 +3
- Partials 12 15 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
SessionBuilder.Interleave, for code that begins a transaction on a*sql.DBand then, before it ends, uses the*sql.DBoutside the transaction or begins another transaction on it. Outside a test these run on separate connections; on one session they wait for each other untilErrTimeout.Interleave, a statement outside an open application transaction runs at once, inside it, in a savepoint of its own: it sees what the transaction wrote, a failure fails only that statement, and what it writes is rolled back with the transaction.Commitrolls both back and returns an error wrapping the newErrTxOrder, and the inner one's statements,CommitandRollbackreturn such an error.Begin, instead of waiting for the timeout.Interleave, nothing changes.Test plan
make vetgo test -race -count=1 ./...go test -race -count=20 -run 'TestInterleave' ./...golangci-lint run