Repository navigation
fix(sqlite): prevent writes after failed nested rollback - #139700
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 4:54 AM ET / 08:54 UTC. ClawSweeper reviewWhat this changesThe PR prevents continued writes after failed SQLite rollback, preserves the original error, discards staged notifications, and prevents Doctor imports from committing an aborted batch. Merge readiness✅ Ready for maintainer review The repair remains necessary on current main. No actionable introduced defect was found, and the PR records acceptance of its scoped recovery behavior. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s shared SQLite transaction helpers coordinate database writes and publish staged state after commit. Plugin-state imports use these helpers to process resumable batches while database owners manage connection recovery. flowchart TD
A[Database writes and Doctor imports] --> B[Shared transaction helper]
B --> C[Nested savepoint]
C --> D{Rollback succeeds?}
D -->|Yes| E[Preserve outer transaction]
D -->|No| F[Discard staged state and close connection]
F --> G[Report original failure]
G --> H[Database owner acquires fresh connection]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +49, Tests +244, Docs +2. Total +295 across 6 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep failed-transaction recovery in the shared transaction owner, preserving ordinary savepoint behavior and reacquiring abandoned connections through existing database owners. Do we have a high-confidence way to reproduce the issue? Yes, from source: force SQLITE_FULL inside a nested transaction, catch the failure, and attempt another write after SQLite has discarded the transaction. The supplied native reproduction and regression cases target this path; this read-only review did not execute them. Is this the best way to solve the issue? Yes. The patch repairs the shared lifecycle owner and the importer’s error classification while preserving ordinary rollback, existing batch durability, and the database format. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7b481f3e2e38. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
|
Merged via squash.
|
…9700) * fix(sqlite): prevent writes after failed nested rollback * test(gateway): derive history fixture state from its producer
What Problem This Solves
Fixes an issue where a failed nested SQLite write could hide the original disk-full error and allow a caller that caught it to persist later writes outside the intended transaction. Doctor plugin-state imports could also treat an aborted batch as a resumable row refusal.
Why This Change Was Made
The transaction owner now preserves the first terminal failure, discards staged state and post-commit observers, and closes a connection when rollback or savepoint recovery fails. A later operation acquires a fresh connection through its database owner. Ordinary savepoint rollback and successful-prefix import behavior remain intact.
Maintainer decision, September 5: accepted this scoped recovery repair as part of the SQLite cleanup campaign. It changes failed-transaction recovery only; there is no schema, version, configuration, retention, or durable representation change. Earlier completed import batches remain durable and the aborted batch contributes no rows. Reverting the source needs no migration, but restores the demonstrated unsafe continuation.
User Impact
Storage failures retain their useful original cause. Catching a nested failure cannot accidentally commit subsequent writes or publish notifications for rolled-back state. Doctor can reacquire the database and resume from earlier committed batches.
Evidence
29d30210a930feba3cff57bc732e906ddd320643, preserving writer admission. Terminal failures are also rechecked at async entry, after preparation, and after retry waits before deadline handling. Native Node 24/26 probes preserve the original SQLite error across each boundary and reopen with no aborted rows. All 33 focused transaction/import tests, the full changed-file gate, and the final independent P0–P2 review pass. Earlier CI failures came from main's stale suppression inventory and renamed session-history fixture fields; both canonical upstream fixes are included. The session-history fixture is identical to main.Proof uses synthetic native databases, not production state or an external provider. SQLite documents the automatic-rollback behavior in transaction error handling and savepoint semantics.