Repository navigation
fix(gateway): resume worker reconciliation after state DB seals - #175185
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Landing note: the only failing checks on head |
openclaw#175185) Per-database drainage (a state DB read-admission seal/reopen under event-loop stalls) closed the worker-environment store permanently, so every reconcile sweep failed with 'Worker environment inventory has closed' until a Gateway restart. Drainage now retires only the current database generation; the next ready() re-captures the same database file (identity-checked), reinstalls the inventory and keeps revocation subscriptions and a monotonic inventory version. Gateway shutdown still closes permanently. The earlier unhandled-rejection crash was already fixed by openclaw#156160. Fixes openclaw#160521
#175185) Per-database drainage (a state DB read-admission seal/reopen under event-loop stalls) closed the worker-environment store permanently, so every reconcile sweep failed with 'Worker environment inventory has closed' until a Gateway restart. Drainage now retires only the current database generation; the next ready() re-captures the same database file (identity-checked), reinstalls the inventory and keeps revocation subscriptions and a monotonic inventory version. Gateway shutdown still closes permanently. The earlier unhandled-rejection crash was already fixed by #156160. Fixes #160521 (cherry picked from commit 6653b26) Co-authored-by: RomneyDa <[email protected]>
Fixes #160521
What Problem This Solves
Fixes cloud-worker reconciliation remaining disabled after a temporary state-database read-admission seal, with "Worker environment inventory has closed" warnings on every sweep until the Gateway restarts.
User Impact
After the same database reopens, the next reconciliation sweep reloads the inventory and resumes worker maintenance. Explicit store closure and Gateway shutdown remain permanent. No configuration or schema changes are required.
Why This Change Was Made
Per-database drainage used the permanent store-close path, and
ready()could only reject the retired inventory. The store now releases the retired generation and obtains fresh canonical admission on the next awaited access, retaining its original scope and physical database identity. Recovery uses the existing worker reader and admitted database facts, with no freshness probes or main-thread SQL. Shared credential-revocation subscriptions survive projection replacement.The earlier unhandled rejection was already addressed by #156160. This fixes the remaining running-Gateway recovery failure while preserving shutdown retirement from #168862. The simplification keeps one store owner and separates temporary retirement from final closure; production delta is +92/-21 lines, with a 75-line boundary regression and one test-routing entry.
Evidence
66ffabc522acce880e6fc28f18964608049593f1fails at the next reconciliation after reopen withWorkerEnvironmentInventoryClosedError: 32.07s wall.pnpm test src/gateway/worker-environments/service-inventory-recovery.test.ts --maxWorkers=1: 1 passed, 29.63s wall, 1.510s test execution. Covers held admission seal, successful next full sweep after reopen, revoked old admission, shared revocation notifications, and permanent shutdown retirement.store-worker.test.tsandservice-lifetime.test.tscases: 6 passed, 33.78s wall. Covers database aliases, refused admission, durable quarantine, reconciliation retirement, and draining accepted shutdown operations.node --import ./scripts/tsx.mjs scripts/run-oxlint-shards.mts --only=core --files-json <three changed TypeScript files>: 0 warnings/errors, 11.95s wall. Test-routing lint throughscripts/run-oxlint.mjs --tsconfig test/tsconfig/tsconfig.test.root.json: 0 warnings/errors, 0.66s wall.pnpm exec oxfmt --checkon all five changed files: passed, 0.08s wall.git diff --check: passed.pnpm run tsgo:core: passed, 53.77s wall. Independent code review: no actionable P0–P2 findings.Focused tests and lint completed on Linux/Node 24.19.0 using Blacksmith Testbox
tbx_01m5454e4fctcsa0bhvhm3kgys(carrier workflow); the final command exited 0 against source treec3675304ccf83e78f32645265208553f8fa9655e. Lease cleanup may mark the carrier workflow cancelled. Local test startup was interrupted before assertions on the heavily loaded host; those attempts are not test verdicts. Broad suites and PR CI timing remain for PR CI.