Repository navigation
fix(session): roll back any transaction a session call leaves open - #352
Merged
Merged
Conversation
The connection cleanup only rolled back when the call panicked, so a call that returned an error or simply forgot to commit left its transaction open on the shared connection, where the next caller would inherit it and its locks. The rollback now runs whenever the connection is not in autocommit mode, and a test covers both the error and the uncommitted success paths. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50. Or wait 20 minutes for your next included review. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (2)
Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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
store::with_connectionnow rolls back any transaction its closure leaves open, however the closure ended. Before, it rolled back only when the closure panicked.Since #348,
sessions.dbruns on the SQLite driver's shared per-file connection. A closure that issuesBEGINand then returns an error, or succeeds without committing, would leave that shared connection inside a transaction. The next caller then inherits it: its ownBEGINfails with "cannot start a transaction within a transaction", or it reads uncommitted state and holds the write lock. The old per-path connection had the same exposure, but nothing caught it.tinyhumansai/tinyflows#109 got this exact review finding and fix (
native::run). This brings the session store in line.with_transactionis unaffected: it commits or rolls back itself, so the connection is back in autocommit when its closure returns.warnand never masks the caller's own result.Tests
store_tests.rs::a_transaction_left_open_never_reaches_the_next_callcovers both an error mid-transaction and an uncommitted success, then checks that the nextwith_transactionstarts cleanly and sees neither write.