Repository navigation
fix(storage): dispose SQLite connections after rollback observer failures - #162139
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. |
Security-sensitive guard clearedCurrent revision: This PR no longer changes files in the maintainer security-review tier. Separate CODEOWNERS requirements still apply to security policy and enforcement files. |
|
Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 1:01 AM ET / 05:01 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR drains all SQLite rollback observers, preserves their failures, and ensures failed native rollback still clears connection caches and attempts disposal. Merge readiness✅ Ready for maintainer review The narrowed fix remains necessary and has no actionable correctness findings. Earlier authority and worker-finalizer concerns do not apply to the current introduced patch. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s SQLite transaction helpers coordinate database writes with staged in-memory state and notifications. When a transaction fails, they restore staged state and prevent unsafe connections from serving later writes. flowchart TD
A[Store operation] --> B[SQLite transaction]
B --> C{Rollback outcome}
C -->|Automatic rollback| D[Drain staged state]
C -->|Native cleanup fails| E[Fence unsafe connection]
E --> D
D --> F[Preserve transaction and observer errors]
E --> G[Clear caches and attempt close]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +25, Tests +92. Total +117 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep rollback recovery in the existing transaction owner, preserving healthy handles after automatic rollback and fencing unsafe handles while retaining all cleanup failures. Do we have a high-confidence way to reproduce the issue? Yes, from source: a throwing staged rollback callback interrupts unsafe-connection cleanup on current main. The captured baseline test results support that mechanism; no tests were executed during this read-only review. Is this the best way to solve the issue? Yes. Draining observers and protecting disposal in the existing cleanup owner is a focused repair that preserves automatic-rollback recovery and successful transaction behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0783e3f28d4e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
The failed-generation cleanup finding describes an intentional failure-path tradeoff. After a raw owner settlement fails, this change joins the other owners’ recorded native cleanup before throwing the original failures and retaining the runtime. It does not release that runtime. If a cleanup never settles, this failure path keeps waiting; we accept that availability cost rather than reporting completion while an owner’s cleanup remains outstanding. The existing ten-second policy is preserved for successful settlement followed by native termination. Applying it to failed settlement would change the selected contract. The actual regressions cover Error/undefined identity, successful sibling native joins, and a separately registered failing generation owner; they do not claim a deadline for stalled cleanup. The persisted-table warning does not correspond to a data-model change. The two named files change worker execution and settlement plumbing; they introduce no table, column, schema version, migration, stored-byte, or retention change. Commit |
adea9fb to
042bd83
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
Consolidate admitted transcript query and transaction owners, preserve the first rollback failure during poisoned connection cleanup, and split oversized owner modules without dropping tests. Restore real worker lifetime observations and move timeout waits to test-owned cancellation with joined cleanup. Preserve the rollback-error ownership from #162139 while retaining unconditional cache and native cleanup. No schema, protocol, or Code Mode capability expansion.
Related: #144592
What Problem This Solves
A throwing rollback observer could leave an unsafe SQLite connection open after native rollback failed, skip remaining observers, and hide the original transaction failure.
User Impact
Rollback observers drain in reverse order even when one throws. Failed native rollback still clears the cached database facade and disposes the connection, and later reuse reports the retained transaction/observer failure. When SQLite has already rolled back automatically, observer failure does not incorrectly trigger unsafe-connection disposal.
Schemas, stored data, retention, permissions, successful commit publication, and installed update behavior are unchanged.
Why This Change Was Made
The rollback owner collects observer failures while draining every observer. Connection disposal runs in
finally, and the transaction fence retains the aggregate error for enclosing and later callers. Automatic rollback handling sits outside the nativeROLLBACKfailure handler so an observer error is not mistaken for failed native cleanup.This PR is narrowed to two production files and their owning transaction tests: production +45/-20, net +25 lines. The larger broker/native-lifecycle work and callback/provisional machinery are deferred until they have a production consumer.
Evidence
5381128b68b26dd988514958b6e445a55f782d67:node scripts/run-vitest.mjs src/infra/sqlite-transaction.test.ts -t 'automatic rollback|disposes failed' --maxWorkers=1produced four expected failures and four passing controls (13.01s runner wall). Three failures leave the connection open; one loses the observer aggregate.node scripts/run-vitest.mjs src/infra/sqlite-transaction.test.ts --maxWorkers=1passed all 33 cases; 8.47s process wall, 7.02s runner wall. The tests cover native automatic rollback, failed rollback/savepoint cleanup, reverse observer order, cache clearing before close, and retained failure on reuse.git diff --checkpassed.The existing
test/scripts/pr-worktree-provision.test.tscasenative PR source provisioning > materializes full cold/warm PR siblings, then preserves native sparse transitionshas a separate Darwin no-output fixture issue: consecutive synchronous wrapper calls prevent timely reporter output. The changed-test planner selects this file on Ubuntu, where that case is skipped; this diff enables neither macOS CI lane. Focused SQLite qualification does not invoke it. Broad localtest:changedon macOS would. Its deadlines and assertions are unchanged.