Repository navigation
fix(gateway): avoid stuck shutdowns after lifecycle errors - #145241
vincentkoc merged 4 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 September 21, 2026, 3:07 AM ET / 07:07 UTC (Revision 4). ClawSweeper reviewWhat this changesKeeps Gateway shutdown deadlines armed through lifecycle completion failures, clears settled restart callbacks, and adds signal-driven regression coverage. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main still cancels restart deadlines when lifecycle completion throws. No actionable introduced defect was found, and the recorded package and upgrade evidence supports the change. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway run loop handles stop and restart requests, drains work, and hands control back to the process supervisor. Its shutdown timers provide a final exit path when cleanup fails. flowchart TD
A[Stop or restart request] --> B[Gateway run loop]
B --> C[Drain work and close listener]
C --> D[Complete lifecycle cleanup]
D --> E{Completion succeeds?}
E -->|Yes| F[Cancel shutdown deadlines]
E -->|No| G[Retain timed exit fallback]
G --> H[Supervisor can recover]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -2, Tests +146. Total +144 across 3 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one shutdown deadline owner active until lifecycle completion succeeds, preserving existing supervisor recovery and managed-update ownership checks. Do we have a high-confidence way to reproduce the issue? Yes, from source: a rejected restart completion reaches current main's unconditional deadline cancellation after listener closure. The supplied regressions exercise that path; this read-only review did not execute tests. Is this the best way to solve the issue? Yes. Moving cancellation to successful completion and independently retiring the restart callback fixes the existing owner without new settings, budgets, or competing lifecycle machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 585312d8ba73. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
352cf90 to
ee97b88
Compare
|
@clawsweeper re-review Published signed head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(gateway): avoid stuck shutdowns after lifecycle errors This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Integrate the landed shutdown-completion owner fix from #145241 so its extracted regression suite composes with the forced-restart drain policy. Keep the cleanup-only fixtures explicitly exhausted and preserve their original timeout assertions. Co-authored-by: Alex Markson <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
…question-layout-restart-recovery-20260921 * 'main' of https://github.com/openclaw/openclaw: (110 commits) perf(infra): collect and retire idle worker heaps (openclaw#154408) perf(sessions): hand shared history to the final reader (openclaw#154552) fix: clarify Codex onboarding migration scope (openclaw#151383) fix: recover conflicted PRs after accepted auto-merge perf(update): defer Gateway maintenance during candidate validation (openclaw#154548) perf(test): advance llama.cpp reload deadlines virtually (openclaw#154536) refactor(skills): prepare pinned library resources off-thread (openclaw#148560) fix(tooling): preserve Node compiler policy in script subprocesses (openclaw#154509) ci: select supported Node and cover packaged Node 26 (openclaw#154298) fix(release): preserve Telegram rerun evidence (openclaw#154561) docs: follow pending PR merges through completion fix(gateway): avoid stuck shutdowns after lifecycle errors (openclaw#145241) fix(ui): let focused dashboard widgets fill the task area (openclaw#154440) feat(release): add non-Latest extended-stable releases (openclaw#154515) fix(release): project 7.35 package Telegram config (openclaw#154546) refactor(config): derive host contracts from schemas (openclaw#153936) fix(ui): remove finished subagents from inline activity (openclaw#154469) refactor(config): derive core channel contracts from schemas (openclaw#153935) refactor(config): derive boundary contracts from schemas (openclaw#153937) fix(ui): keep thread activity current across cached updates (openclaw#154540) ...
* fix: let forced Gateway restarts drain admitted work Keep force separate from exhausted drain budgets and settle startup orphan rows with their failure receipts in one transaction. Reuse prepared process fixtures for restart coverage. * test: include drain budget in external restart health check Preserve the exact running-Gateway and no-candidate-state assertions while allowing the existing five-minute drain budget before the one-minute readiness window. * test(gateway): control elapsed drain clocks * refactor(gateway): separate restart budget and warning formatting * fix(gateway): retain shutdown deadlines through completion Integrate the landed shutdown-completion owner fix from #145241 so its extracted regression suite composes with the forced-restart drain policy. Keep the cleanup-only fixtures explicitly exhausted and preserve their original timeout assertions. Co-authored-by: Alex Markson <[email protected]> Co-authored-by: Vincent Koc <[email protected]> * test(gateway): clean up forced restart fixtures --------- Co-authored-by: Alex Markson <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
…145241) * fix(gateway): retain deadlines through restart completion * test(gateway): extract shutdown completion coverage --------- Co-authored-by: Vincent Koc <[email protected]>
…54300) * fix: let forced Gateway restarts drain admitted work Keep force separate from exhausted drain budgets and settle startup orphan rows with their failure receipts in one transaction. Reuse prepared process fixtures for restart coverage. * test: include drain budget in external restart health check Preserve the exact running-Gateway and no-candidate-state assertions while allowing the existing five-minute drain budget before the one-minute readiness window. * test(gateway): control elapsed drain clocks * refactor(gateway): separate restart budget and warning formatting * fix(gateway): retain shutdown deadlines through completion Integrate the landed shutdown-completion owner fix from openclaw#145241 so its extracted regression suite composes with the forced-restart drain policy. Keep the cleanup-only fixtures explicitly exhausted and preserve their original timeout assertions. Co-authored-by: Alex Markson <[email protected]> Co-authored-by: Vincent Koc <[email protected]> * test(gateway): clean up forced restart fixtures --------- Co-authored-by: Alex Markson <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
Related: #132616
Companion library repair: openclaw/fs-safe#254 (merged)
What Problem This Solves
A Gateway can close its listener but remain alive after retirement, log flushing, or an exit listener throws. Cancelling the shutdown deadline in
finallyleaves the supervisor unable to replace the non-listening process.User Impact
Keep the existing main-thread deadline and hard-exit watchdog armed until lifecycle completion succeeds. Retire a settled restart's upgrade callback without cancelling its original deadline, so a later managed-update signal cannot accidentally remove the remaining exit fallback.
Successful restart, hosted-stop, ordinary-stop, managed-update, restoration, drain, and authority contracts retain their existing owners and budgets. There are no new flags, timeout values, dependency changes, configuration defaults, or persistence/migration surfaces.
Current Integration and Review
Preserves the original contributor commits and integrates main
bb9564112c40. The published, SSH-signed head isd03fdc2525e0, treee1ff425fc60a. It is source-tree-identical to reviewed and packaged candidate84f1e7d5eed1; only signatures and corresponding first-parent commit IDs changed. Production delta is 31 added / 33 removed lines. The extracted test helper keeps the existing test file within its line budget.Independent CLI review of the repaired completion paths is scoped-clean with no P0–P2 findings. Its late-managed-update finding was reproduced and repaired before the final review. Existing ordinary-stop fixes and the already-landed companion library repair are retained, not credited as new changes here.
Evidence
Original SIGUSR2 exit-handler/log-flush controls and the late-managed-update regression fail before their respective repairs and pass after them.
212 tests across the run-loop, forced-cron process, and independent hard-exit process suites passed with
--maxWorkers=1: 113.85 seconds wall. The new focused regression measured 82 ms. Final tree differs from that tested tree only by removing an unused test import; executable production and test behavior are unchanged.Final scoped lint, formatting, line-cap and changed-diff checks passed. The local broad static run passed production typechecking but was interrupted during test-type shards by the Gateway restart; its exit is unavailable and is not claimed passing. Hosted exact-head CI subsequently passed, including required static lanes; this does not retroactively establish the interrupted local exit. Both required CI/security contexts are successful.
Exact candidate package built successfully in secretless Docker. Package SHA-256:
341ad1522c7552ecc479b29f6df43fe11bd9460c9701d7524ab2cd73cdecec76. Candidate and plugin registry both identify84f1e7d5eed1.Final normal upgrade/restart passed at 2026-09-21T07:25:25Z: published
2026.9.4updater to unchanged candidate, then candidate-to-future auto-auth managed restart, 438 seconds lane / 441.25 seconds launcher, exit 0. The fresh data-only worktree and Docker-inspected artifact mount had no previous lane artifacts. Exact candidate package above, plus independently reviewed companion fixture #154560, patch SHA-25633031d902bbc0fad7699a3fba34e75d2e877b52415a858f820566ce565a0bc1a. Automatic supervisor replacement (5406 to 10728), serving agent turn, migration, plugin resolution/cleanup, Doctor, health/readiness/status all passed. No product PID/boot guard or assertion was weakened.The earlier uncorrected normal lane failed after 384 seconds: its inherited synthetic manager exposed supervisor PID 5374 as MainPID instead of actual Gateway child 5388. Production correctly rejected the mismatch before this PR's modified completion path; recovery was healthy. Both original fixture files and the drain helper match base
bb9564112c40. That failed receipt remains retained. Companion fix: report the actual gateway PID in upgrade survival tests #154560 corrects the fixture producer/projections and was applied only to the isolated trusted harness for the final passing run; it is not a source change in this PR.Final legacy-operator-state upgrade passed on the unchanged package at 2026-09-21T06:32:54Z: 243 seconds lane / 246.59 seconds launcher, exit 0. Automatic supervisor replacement, migrations, Gateway probes, a real candidate agent turn, cron owners, plugins, update idempotence, clean Doctor and backup rollback passed. Earlier
c97062fbnormal/legacy passes and the intermediate corrected-fixture pass are historical, not the final reviewed-fixture receipt.Hosted CI attempt 1 at exact published head failed one unchanged cron process-group timeout fixture after 120 seconds (job); the rest of that cron shard passed 939 tests. The identical selected test passed on the exact head in 78 ms with its original timeout and no source change. Existing issue Investigate cron shell process-group timeout test stall in CI #139983 and recent perf(gateway): reduce session projection allocation churn #154415 evidence record this timing-sensitive fixture; the isolated pass does not prove a fix or identify the stalled await. The original-job-order reproduction passed on attempt 2 without a code change: job
106240960764completed successfully at 2026-09-21T07:22:34Z, and the exact-head CI workflow is successful. This is passing validation, not proof of an underlying fixture fix. No timeout, assertion, production, or baseline was weakened.Update Behavior
This changes candidate Gateway completion, not the installed updater. Proof uses the published
[email protected]updater, the exact candidate package, normal and legacy operator-state scenarios, and the maintained synthetic systemd fixture. No operator state or credentials are copied into the containers. This is not native-systemd certification, a production deployment, or Night Watch acceptance.