Repository navigation
fix: Gateway startup stops during temporary state maintenance - #166108
ericcaiwx-star wants to merge 2 commits into
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 October 6, 2026, 9:52 PM ET / October 7, 2026, 01:52 UTC (Revision 10). ClawSweeper reviewWhat this changesThe PR makes cold shared-state snapshots wait cancellably for up to five seconds during temporary schema ownership and adds focused admission regressions. Merge readiness✅ Ready for maintainer review The patch is useful, narrowly scoped, and supported by real snapshot-boundary proof. Current main still lacks this retry. The overlapping startup PR remains unmerged and preserves different behavior for non-startup callers, so it does not yet establish complete supersession. Priority: P1 Review scores
Verification
How this fits togetherShared-state snapshots provide consistent private database copies for startup discovery, Doctor, backups, and update preparation. Ownership admission runs before copying data and is checked again before the caller reads it. flowchart TD
A[Startup and management reads] --> B[Snapshot admission]
C[Current database ownership] --> B
B --> D[Bounded cancellable wait]
D --> B
B --> E[Private database snapshot]
E --> F[Revalidate admission]
F --> G[Read callback and cleanup]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +24, Tests +89. Total +113 across 2 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Use one snapshot admission owner with cancellable waits sized for the caller, including startup contention that lasts longer than five seconds. Do we have a high-confidence way to reproduce the issue? Yes, source establishes that cold snapshot admission immediately propagates temporary foreign schema ownership on current main. The contributor also supplies real Windows before/after boundary traces; this review did not execute target code. Is this the best way to solve the issue? Yes for contention that releases within five seconds: retries stay with the existing owner and preserve refusal and cleanup contracts. The reported nine-second startup race needs the longer startup-specific budget proposed in the related candidate. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 19cd32da3326. 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 (9 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review Updated the PR's Evidence section for the remaining CI-provenance next step on unchanged head The completed main UI job at immutable The PR changes only snapshot admission and its owner tests, not that mocked browser flow. The required CI gate remains red. The native inherited-failure landing exception remains a maintainer-owned disposition; no merge or bypass was performed. Please re-evaluate the contributor-side provenance against the updated evidence. |
|
🦞👀 Re-review progress:
|
|
The latest exact-head ClawSweeper review accepts the inherited UI-failure provenance and reports no patch or proof findings. The matching completed main job and all three red-check explanations are now in the PR's Evidence section; the required CI gate is still red. Could a maintainer resolve the review's explicit owner decision: use the repository's native inherited-failure landing workflow for this reviewed snapshot repair, or wait for the main UI repair? The native workflow must independently verify landing authority, exact-head CI evidence, security, and review gates. I have not merged, bypassed checks, rerun CI for green, or bundled an unrelated UI fix. |
7dd033f to
d0a218e
Compare
…atch Keep startup's five-minute schema admission budget and preserve immediate refusal for other snapshot callers. Check caller cancellation after awaited admission, before preparing snapshot bytes. Preserve recovery, refusal, exhaustion, and cancellation coverage, including the startup entry point. Adapt the controlled-time admission regressions from Eric Cai's openclaw#166108. Remove a single-use read forwarding layer without changing retained work settlement, error mapping, or current/live read scopes. Await worker-backed database closure before existing raw SQLite fixture access. Fixes openclaw#166088 Co-authored-by: NianJiuZst <[email protected]> Co-authored-by: Eric Cai <[email protected]>
d0a218e to
518a645
Compare
|
@clawsweeper re-review Rebased cleanly onto current main after #166370 merged. Exact head |
|
🦞👀 Re-review progress:
|
…ion (#166111) * fix(gateway): retry temporary startup state contention * fix(state): retain startup contention coverage and simplify read dispatch Keep startup's five-minute schema admission budget and preserve immediate refusal for other snapshot callers. Check caller cancellation after awaited admission, before preparing snapshot bytes. Preserve recovery, refusal, exhaustion, and cancellation coverage, including the startup entry point. Adapt the controlled-time admission regressions from Eric Cai's #166108. Remove a single-use read forwarding layer without changing retained work settlement, error mapping, or current/live read scopes. Await worker-backed database closure before existing raw SQLite fixture access. Fixes #166088 Co-authored-by: NianJiuZst <[email protected]> Co-authored-by: Eric Cai <[email protected]> --------- Co-authored-by: NianJiuZst <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Eric Cai <[email protected]>
|
Thank you @ericcaiwx-star. Your fix and regression coverage were folded into #166111, merged as af716af with you credited as co-author. That version waits up to the existing five-minute startup migration budget (the reported contention lasted about nine seconds, longer than the five-second window here) and keeps explicit offline maintenance blocking. Closing this one as superseded by #166111. |
…ion (openclaw#166111) * fix(gateway): retry temporary startup state contention * fix(state): retain startup contention coverage and simplify read dispatch Keep startup's five-minute schema admission budget and preserve immediate refusal for other snapshot callers. Check caller cancellation after awaited admission, before preparing snapshot bytes. Preserve recovery, refusal, exhaustion, and cancellation coverage, including the startup entry point. Adapt the controlled-time admission regressions from Eric Cai's openclaw#166108. Remove a single-use read forwarding layer without changing retained work settlement, error mapping, or current/live read scopes. Await worker-backed database closure before existing raw SQLite fixture access. Fixes openclaw#166088 Co-authored-by: NianJiuZst <[email protected]> Co-authored-by: Eric Cai <[email protected]> --------- Co-authored-by: NianJiuZst <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Eric Cai <[email protected]>
Related: #166088.
This PR repairs the temporary schema-owner contention part of that report. The broader Windows launcher, Scheduled Task, and Node Host symptoms remain outside this patch.
What Problem This Solves
Gateway startup discovery can abort immediately while another OpenClaw process briefly holds the shared-state schema lease. The cold snapshot owner receives
StateDatabaseAdmissionPendingErrorbefore it prepares a private snapshot, but previously treated that temporary condition as terminal maintenance.Why This Change Was Made
withOpenClawStateDatabaseReadSnapshotnow waits only when all of these remain true:StateDatabaseAdmissionPendingError;The retry remains before admission capture and snapshot preparation, so it does not replay the callback or prepared work. Genuine offline maintenance, another database's custody, cancellation, and exhausted contention still refuse. This changes no schema, stored data, config, dependency, or permission contract.
User Impact
Startup discovery can recover when temporary foreign schema custody releases. A cancelled caller never enters the callback, persistent contention remains bounded, and ordinary maintenance is not admitted.
Evidence
Current implementation head:
518a645ae50e0c3a002aa3e75b8facc9b115b3ae, rebased cleanly onto889611b388c4a219468f881e192e45ede2c6d3e1after the independent fixture repair #166370 merged.git range-diffreports both patch commits unchanged by the rebase.Real production-boundary proof
Windows / Node 26.7.0 proof used a fresh synthetic database, a separate process holding the production
acquireStateDatabaseSchemaLease, and the production snapshot reader. It did not fabricate owner records, inject errno values, use operator state, or mock the changed production functions.78e8de276bd2d31ed0996338100543c27adb4235: immediate admission refusal, exit 1, recorded byocpr prove.d0a218e7d7ec42349aa4e96ff06d7dd5608c791a: recovery after release, exit 0, re-executed on Windows and recorded byocpr prove. The observed boundary duration was 4,566 ms, including snapshot work and cleanup; it is not a claim that admission waited that long.The rebase did not change either patch commit or the two changed-file blobs. The Windows traces above are retained as prior-head production-boundary evidence; they are not relabeled as execution at the new SHA.
Prior-head Windows control outcomes, exit 0 (synthetic paths redacted):
{"platform":"win32","mode":"release","elapsedMs":1882,"callbackCount":1,"observed":{"admitted":true}} {"platform":"win32","mode":"cancelled","elapsedMs":139,"callbackCount":0,"observed":{"admitted":false,"cause":"aborted","pending":false,"aborted":true}} {"platform":"win32","mode":"maintenance","elapsedMs":128,"callbackCount":0,"observed":{"admitted":false,"pending":false,"aborted":false}} {"platform":"win32","mode":"exhausted","elapsedMs":5084,"callbackCount":0,"observed":{"admitted":false,"pending":true,"aborted":false}}These traces prove the snapshot-owner boundary, not a complete CLI, service, or Scheduled Task boot.
Current exact-head tests and checks
On exact head
518a645ae50e0c3a002aa3e75b8facc9b115b3ae:node scripts/run-vitest.mjs src/state/openclaw-state-db-readonly.snapshot-admission.test.ts --maxWorkers=1: 12/12 passed.node scripts/run-vitest.mjs run test/e2e/qa-lab/runtime/native-worker-slot.e2e.test.ts --maxWorkers=1: 1/1 passed after test(e2e): declare worker prompt-context capability #166370; Vitest reported 40.33 s test time and 80.10 s total test duration.node scripts/check-changed.mjs --base upstream/main -- src/state/openclaw-state-db-readonly.ts src/state/openclaw-state-db-readonly.snapshot-admission.test.ts: exit 0. All selected guards passed, including formatting, lint, core and core-test type graphs, SQLite worker ratchet, dead exports, schema guards, and import cycles.The measured 12-case owner regression cost on the prior patch-identical head remains: 10.50 s command wall time, 7.45 s Vitest duration, and about 0.06 s summed individual test time. The budget and cancellation cases use fake timers, not real five-second sleeps.
Current Status
#166370 was the independently owned two-line E2E fixture repair for the previous
checks-node-changedadmission failure. It merged as98567acd6060d21c2199ef9dd8380779a07e1efe; this branch now includes that merge through currentmain. The exact rebased head passes the formerly blocked native-worker E2E locally without bundling any fixture change into this PR.Hosted CI for
518a645ae50e0c3a002aa3e75b8facc9b115b3aeis the remaining fresh-head gate. No merge, CI bypass, inherited-green claim, or unrelated repair is requested or performed.