Skip to content

fix(session): roll back any transaction a session call leaves open - #352

Merged
senamakel merged 1 commit into
mainfrom
session-rollback-open-tx
Oct 9, 2026
Merged

senamakel merged 1 commit into
mainfrom
session-rollback-open-tx

Conversation

@senamakel

Copy link
Copy Markdown
Member

Summary

store::with_connection now rolls back any transaction its closure leaves open, however the closure ended. Before, it rolled back only when the closure panicked.

Since #348, sessions.db runs on the SQLite driver's shared per-file connection. A closure that issues BEGIN and then returns an error, or succeeds without committing, would leave that shared connection inside a transaction. The next caller then inherits it: its own BEGIN fails 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_transaction is unaffected: it commits or rolls back itself, so the connection is back in autocommit when its closure returns.
  • A rollback failure is logged at warn and never masks the caller's own result.

Tests

store_tests.rs::a_transaction_left_open_never_reaches_the_next_call covers both an error mid-transaction and an uncommitted success, then checks that the next with_transaction starts cleanly and sees neither write.

cargo test -p tinyagents-session --all-features          # 540 passed
cargo test -p tinyagents-integration-tests --test session_conformance
cargo test -p tinyagents-orchestration
cargo clippy -p tinyagents-session --all-targets --all-features -- -D warnings   # stable and 1.99.0

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>
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 2 billable files and costs up to $0.50.

Or wait 20 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4afb64f9-8b7f-4028-9947-55546209e845
📥 Commits

Reviewing files that changed from the base of the PR and between 518d33b and a9ef9fc.

📒 Files selected for processing (2)
  • crates/tinyagents-session/src/store.rs
  • crates/tinyagents-session/src/store_tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T06:30:20.128580Z a9ef9fc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@senamakel
senamakel merged commit 37185fd into main Oct 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant