Repository navigation
fix(state): avoid gateway stalls during WAL coordination - #157484
Conversation
…l-maintenance-admission-20260924
|
🦞👀 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 24, 2026, 5:22 PM ET / 21:22 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch makes periodic shared-state SQLite maintenance wait asynchronously for lifecycle coordination, rechecks the database before SQL, and adds cancellation, cleanup, tests, and documentation. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Current main still makes the periodic checkpoint wait synchronously for lifecycle coordination, so this PR remains useful. The earlier test-timing finding is addressed on the current head, and this review found no introduced blocking defect. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw stores shared Gateway state in SQLite. A periodic timer maintains its write-ahead log, while lifecycle coordination controls when that maintenance can use the open database; checkpoint health feeds status and Doctor. flowchart LR
A[Gateway shared state] --> B[SQLite database]
C[Periodic maintenance timer] --> D[Lifecycle coordination]
D --> E[Check live database and file]
E --> F[WAL checkpoint]
F --> G[Status and Doctor health]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +151, Tests +364, Docs +4, Other +1. Total +520 across 11 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the existing lifecycle coordinator as the sole checkpoint gate and land the bounded periodic-wait repair after the normal exact-head gates complete. Do we have a high-confidence way to reproduce the issue? Yes, the source-defined path is clear: hold the lifecycle coordinator in another process and trigger the periodic timer on current main, where acquisition waits synchronously for up to 350 ms. This review did not execute that path. Is this the best way to solve the issue? Yes. The patch uses the existing coordinator owner, preserves explicit synchronous maintenance, and checks current database ownership and file identity before periodic SQL. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a219fa50a0a9. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…7484) * fix(state): avoid gateway stalls during WAL coordination * test(state): observe WAL checkpoints without polling
Related: #157121
What Problem This Solves
Fixes Gateway pauses during periodic shared-state database maintenance when another process holds the lifecycle coordinator.
User Impact
The Gateway can keep servicing events while maintenance waits for coordination. The existing 350 ms contention budget, short-wait recovery, blocked-health reporting, and retry cadence remain intact.
Why This Change Was Made
Periodic maintenance uses the existing asynchronous acquisition owner and rechecks the current database handle and physical file immediately before SQL. Retirement cancels and joins pending admission. Failed coordinator release remains owned until canonical cleanup succeeds, including when a symlink target changes. Explicit synchronous checkpoint and close behavior is preserved; no schema, migration, retention, permission, or environment-setting change is introduced.
Evidence
Linux/Node 24.19 proof reproduces a 371.3 ms callback stall on the original process main thread. Four causal negative controls cover blocking acquisition, yielding only once, lost holder attribution, and failed-release custody. The revised path keeps servicing independently acknowledged turns while preserving successful short-contention maintenance.
284 focused/sibling/wrapper/routing cases passed, with 54 affected cases rechecked after canonical main integration. Core types and all 25 test graphs passed; affected types and all reported lint failures were rechecked on the integrated head. Formatting, dependency, schema, legacy-store, script lint, import-cycle, webhook, and pairing guards passed. Managed review is clean through P2.
The coordinator tests now use buffered checkpoint events and child-process acknowledgments instead of pacing sleeps or polling. All three affected negative controls still fail for their intended reasons; 60 positive cases passed.
Single-worker cost on Linux/Node 24.19 in the CI-backed Testbox:
openclaw-state-db.coordinator.test.ts(19 cases)state-database-coordinator-acquisition.test.ts(9 cases)The coordinator command includes 19.975 s preparing the real SQLite worker runtime. Reported case totals exclude harness setup/teardown; the full command measurements include it. For ordinary PR CI at
1156d99, the complete workflow spanned 1318 seconds across 166 jobs (44591 summed job seconds, including setup and all selected checks).The isolated full build and ordinary CI at
1156d99passed. The enforced Security Review also passed before native landing as7a052255f8d6876a3132b845ce37ffcf392ac546. Source proof does not establish that deployed event-loop stalls have been eliminated.