Skip to content

fix(history): wait for cancelled rollback before retry - #1552

Merged
frahlg merged 2 commits into
masterfrom
codex/stable-storage-cause-20261011
Oct 11, 2026
Merged

frahlg merged 2 commits into
masterfrom
codex/stable-storage-cause-20261011

Conversation

@frahlg

@frahlg frahlg commented Oct 11, 2026

Copy link
Copy Markdown
Member

A cancelled history write can return after database/sql marks its transaction done but before SQLite finishes rollback. Core then releases historyWriteMu; its immediate retry reads a snapshot and fails the write upgrade with SQLITE_BUSY. This matches the timeout/BUSY sequence seen on v0.140.4-beta.1.

Reserve a sql.Conn for the batch and close it before releasing the writer mutex. Closing the connection waits for automatic rollback. Failed writes also name their phase so the initial timeout can be traced. The source of that initial delay remains unproven; this PR fixes the retry race.

Validation: a test delegates to the real modernc SQLite driver, delays rollback after a cancelled write, and reproduces the immediate BUSY before the fix. It passes 20 times after the fix and checks that receipt retries preserve the sample exactly once. make verify and the full state suite pass. State schema, Energyplan and bundled drivers are unchanged. Stable remains held pending a new exact beta and field trial.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-11T11:00:17.244399Z 443816d 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.

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