Repository navigation
fix(state): tolerate brief WAL coordinator contention - #157121
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: blocked before merge. Reviewed September 24, 2026, 10:21 AM ET / 14:21 UTC (Revision 6). ClawSweeper reviewWhat this changesThe branch adds a short wait and retry for shared-state SQLite WAL checkpoints, Linux lock-holder diagnostics, tests, documentation, and wrapper packaging. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 3 items remain The short-lock recovery remains useful because current main does not provide it. The earlier review’s blocker remains: a reader-blocked checkpoint followed by coordinator contention resets the warning streak, suppressing the documented Status and Doctor warning. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw periodically checkpoints the shared-state SQLite database behind a process coordinator. Its checkpoint observations feed Status and Doctor warnings and clear a history-eviction deferral after completion. flowchart LR
A[Shared state database] --> B[Periodic WAL maintenance]
C[Other process lock] --> D[Coordinator admission]
B --> D
D --> E[Checkpoint result]
E --> F[Status and Doctor]
E --> G[History eviction gate]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +89, Tests +101, Docs +10, Other +1. Total +201 across 10 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the bounded coordinator wait and retry, while counting every consecutive blocked checkpoint until completion and preserving the intended contention-log cadence. Do we have a high-confidence way to reproduce the issue? Yes, from source: a reader-blocked checkpoint followed by coordinator contention records count one and no warning. This read-only review did not execute that mixed-order sequence. Is this the best way to solve the issue? No, not yet. The existing checkpoint owner is the right place for the wait and retry, but its health count must preserve the documented warning threshold across both blocker types. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 85af71525401. LabelsLabel changes: No label changes. Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
Wait briefly for WAL maintenance admission, retry a blocked periodic pass once, and report repeated contention with Linux holder identity. Preserve native SQLite exclusion and publish completed checkpoints through the existing eviction gate.
Keep status and Doctor warning eligibility after two coordinator refusals while throttling maintenance logs to every fifth refusal.
Package the holder-attribution module with the standalone wrapper so state lease bootstrap and extracted runtime import closure stay complete.
2574c55 to
b3b4335
Compare
* commit '9ccfc7d1bea21e34da48edbd54afd2e1be57db40': (89 commits) fix(exec): avoid gateway stalls during background task writes (#157177) test(cli): isolate preaction title setter state fix(test): synchronize Git backoff cancellation readiness (#157315) fix: validate Codex model references in Docker (#157175) fix(state): tolerate brief WAL coordinator contention (#157121) fix: unblock conversations after recovery preparation fails (#157214) test(telegram): avoid wall-clock pacing in HTTP conformance (#157281) fix: keep independent database work responsive under load (#157230) refactor(sqlite): centralize WAL checkpoint execution (#157263) improve(android): show tool outcomes in collapsed work (#156950) fix: remove tracked release scratch blocking source capture (#157308) test(update): remove legacy probe stream ordering race fix: preserve steering across reconnects and show queued input (#157135) fix(ui): keep typing focus when the GitHub reader opens (#157202) fix(ios): keep screenshot logs outside capture evidence test(codex): await startup teardown in lifecycle fixtures chore(ui): refresh control ui locales (#157311) refactor(memory): deslop memory plugins (#156867) refactor(test): share CLI diagnostics fixture setup (#157201) fix(release): retry notarization submit/wait on transport failures and name the resume command (#157116) ...
Bound WAL maintenance waits with backoff, warn once per run of blocked cycles, and record the coordinator holder so contention names its process.
Peter Steinberger's upstream fix, merged to main 2026-09-24, after the 9.6 tag. Shared-state WAL maintenance now waits up to 350 ms for the lifecycle coordinator instead of failing at once. A contended periodic pass records "blocked" health rather than "error", retries once after 1 s, and calls onCheckpointError only on every fifth consecutive block; health turns to a warning from the second. The contention error names the coordinator's holder (pid, start time, command) when it can read one; that reader uses /proc/locks, so off Linux the holder stays "unknown" and the message is unchanged. Applied with cherry-pick -x and one adaptation. Upstream's retry chains on the periodic scheduler's promise, which arrived with openclaw#155631's page-budget scheduler; that change is not carried. Here createSqliteWalMaintenanceScheduler returns a promise that settles when its attempt (or the one already admitted) has run, and resolves at once on the unadmitted path, which still runs synchronously. Its one caller is configureSqliteWalMaintenance. Conflicts: sqlite-wal.ts, the interval callback calls maintainPeriodically(); sqlite-wal-checkpoint.test.ts, upstream's new test is inserted before the tag's (synchronous) next test, and no existing test changed. The other files auto-merged; the new owner module and the errors module equal upstream's blobs. Tests on the branch: sqlite-wal-checkpoint 13/13 and openclaw-state-db.coordinator 14/14, including both new upstream tests; the Linux-only holder assertions do not run on macOS. With eight WAL and coordinator neighbor files: 10 files, 115 passed, 8 skipped. (cherry picked from commit 1b32a8b)
… the 9.6 carry Records the three upstream ports (openclaw#156583, openclaw#157834, openclaw#157121), why openclaw#155988 was not carried, the /tools/invoke loop-detection fix, the review left-overs, and the validation run on this branch.
Related: #157064
What Problem This Solves
A brief lifecycle lock held by another CLI process makes shared-state WAL maintenance abandon its checkpoint, emit an anonymous error, and leave history eviction waiting for completion.
User Impact
Maintenance can finish through short coordinator holds. Persistent contention remains visible in status and Doctor, repeated logs are throttled, and Linux diagnostics identify the observed holder. A completed checkpoint clears the existing history-eviction gate. No configuration, schema, durability, retention, or update migration changes are required.
Why This Change Was Made
Allow 350 ms for maintenance acquisition and retry a refused periodic attempt once after one second. The checkpoint owner records contention as blocked; health warnings remain eligible after two refusals, while log callbacks occur every fifth refusal. Completion resets the count, and close cancels the retry. Writer admission and checkpoint thread placement stay with their existing owners.
Linux holder attribution reads kernel locks by device and inode and reports PID, process start time, command, and family. The snapshot is diagnostic only; SQLite still owns exclusion. Unsupported platforms and unavailable procfs observations report
unknown, and coordinator files remain write-free.Rebased onto main
b9da50953aa88b0c9cb021e447b9542e555c4edb. Dropped the separate CI-routing commit, including.github/workflows/ci.yml,scripts/changed-lanes.mts,scripts/lib/tsgo-core-test-shards.mts,docs/ci.md, andtest/scripts/ci-workflow-planning.test.ts; those files match main. No separate CI PR was created. The only tooling change is one entry inscripts/pr-lib/wrapper-components.txt: the standalone wrapper must package the new coordinator-owner module or its state-lease imports fail.Evidence
All new validation ran on Blacksmith Testbox
tbx_01m39skzsqt0mndkcvehssyz3f(runner). No local tests, typechecks, or builds ran.checks-node-compact-small-8failure was real:eager-import-closure.test.tscould not resolvestate-database-coordinator-owner.jsin the extracted wrapper. The manifest entry fixes the missing runtime module; all 15 existing wrapper-closure cases now pass.checks-node-changed-compact-large-2failure counted two warning records insubagent-completion-admission.task-missing.test.ts; its wake-count assertions passed. All five cases now pass unchanged on this candidate. The extra old warning's source is unproven, so this is not claimed as a repaired flake.b39eca3dd5dahas successful subagent-support and all 13 UI E2E jobs, including the suites containing the two prior UI failures. No UI source changes are included here.git diff --checkpasses.The first Testbox invocation stopped before testing because the synchronized checkout lacked dependencies.
pnpm install --frozen-lockfilerepaired that setup, and the focused command then passed. Existing regression proof from the original PR demonstrated failure before the fix for the 200 ms foreign hold and warning cadence; the single-worker checkpoint and shared-state coordinator files previously measured 1.35 s and 20.35 s cold wall respectively.node scripts/check-changed.mjs --base b9da50953aa88b0c9cb021e447b9542e555c4edbpassed in 37m28.96s command wall: core plus all 25 core-test type graphs, formatting, lint, all three export scans, and every selected guard. The remote execution directory and hashes of all ten candidate files were verified before this command. The final head isb3b4335f82d4b873870a90ebac366c78a48b41b0; hosted CI is tracked on that rewritten head. The Testbox lease was stopped after validation. Linux holder attribution is covered; no macOS/Windows holder-attribution or production deployment proof is claimed.