Repository navigation
fix: graceful Gateway shutdown outlives its stop deadline - #188188
Conversation
Bound process-owned session admission settlement after restart markers and cancellation while preserving embedded-host joins and retained database ownership. Retire the direct Linux subreaper child once its descendant certificate and channel EOFs prove only the native owner remains.
Capture a monotonic deadline before creating the native watchdog worker. Observe queued cancellation at the kill effect so an already-cancelled watchdog cannot kill after delayed startup. Prove both paths through real worker bootstrap delays and native process exit.
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR bounds process-owned session cleanup, retires fully drained Linux child owners, and includes worker startup in the shutdown watchdog deadline. Example: A watchdog has a 1,000 ms budget and its worker takes 1,000 ms to bootstrap.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses shutdown defects still present on current main, and the reviewed diff introduces no concrete correctness finding. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway shutdown path records restart markers, cancels session work, and closes resources; the process supervisor joins child extinction, while an independent worker enforces the process exit deadline. flowchart TD
A[Stop or restart request] --> B[Gateway shutdown owner]
B --> C[Persist markers and cancel sessions]
C --> D[Bound cleanup and retain dependencies]
B --> E[Join certified child retirement]
A --> F[Independent deadline watchdog]
D --> G[Process exit]
E --> G
F --> G
Technical reviewBest possible solution: Keep shutdown deadlines with the existing lifecycle owners while retaining dependencies for unfinished cleanup and refusing unsafe runtime reuse. Do we have a high-confidence way to reproduce the issue? Current main starts the watchdog delay after worker bootstrap and excludes Linux subreapers from retained-child retirement; the author also reports base-red regressions, which this read-only review did not rerun. Is this the best way to solve the issue? The patch is a focused repair using existing shutdown, retirement, and cancellation owners; every production hunk serves the stated problem, and no smaller complete alternative was established. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4c6ae7f801f5. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +26, Tests -11, Docs +6. Total +21 across 9 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 30, 2026, 4:43 AM ET / 08:43 UTC. |
Adapt the service-child retirement portion of main PR #188188 for the release branch so a native Linux subreaper receipt can retire the retained relay without a stale process-group probe. Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: RomneyDa <[email protected]>
…r systemd SIGKILL (openclaw#188188) On Team (2026-10-30 05:05Z), the restart redesign resumed every running root correctly, but the process never exited on its own. systemd SIGKILLed it at 90 s: - restart.close.session-admissions stayed pending for 85 s; - a service-child relay (linux-subreaper) missed its cleanup deadline; - the native hard-exit watchdog did not beat systemd. Fixes: - The session-admission join waited for full producer, operation, effect and terminal-persistence settlement. It now has a 5 s process-owned bound and keeps databases open for late cleanup. - Service-child relay retirement: once descendant extinction is certified and channel closure is complete, it uses the existing direct-child retirement path. - The hard-exit watchdog started its relative timer after worker bootstrap, which could exceed systemd's margin. It now consumes an absolute monotonic deadline and checks queued cancellation before killing. Proof at exact head e0e9ee2: - Regressions for all three are red on base and green here. Close/resource suites (116), the service-child relay suite (36) and the hard-exit process test (incl. delayed cancellation and blocked-main SIGKILL) pass. - The restart acceptance and handoff e2e pass: markers and abort in 24.6 ms, SIGTERM exit in 381 ms. - Exact-head CI: 65 jobs succeeded, zero failed. Gap: Linux handoff proof (Testbox queued). Uncertified owners still rely on the watchdog. Production +26 LOC.
What Problem This Solves
Fixes graceful Gateway stops that leave a completed Linux service-child owner alive, keep session-admission cleanup pending after cancellation, or let watchdog worker startup extend the native shutdown deadline.
User Impact
Process-owned shutdown bounds session resource settlement to five seconds after marker persistence and cancellation, and retires a certified, fully drained native child. Embedded hosts still join actual cleanup before reusing resources. Uncertified descendants or incomplete channels remain retained and use the existing process-exit safety net.
Why This Change Was Made
Session admission settlement joins captured producers, operation owners, interrupted effects, and terminal persistence; an abort signal is only the start of that cleanup. The run-shutdown owner now bounds its process-exit receipt and uses the existing close-step warning/retention path, preserving databases for late cleanup.
The Linux host previously excluded every subreaper from retained-child retirement, even after a descendant-extinction certificate and all channel EOFs. Reuse the existing direct-child retirement path for that completed owner, including ordinary graceful closure. No native PGID signaling is introduced.
The watchdog was armed with the correct shutdown budget but started its relative timer only after worker bootstrap. Pass an absolute monotonic deadline and check its existing cancellation queue immediately before killing. A delayed bootstrap now consumes the budget, and an already-queued cancellation still wins. The historical bootstrap delay was not measured, so this proves a deadline-accounting defect rather than attributing the recorded incident conclusively.
Evidence
Candidate:
e0e9ee29edf3d24766beb8524975cffbed60b425, basec32556b0cea7f63b33db0ac393affd71ecb0015b.<500 ms); green with the fix. It also joins delayed cancellation and kills a real blocked-main process. Signal/liveness consumer suites: 11 passed before the final queue-read correction; final watchdog regression passed afterward.pnpm test:e2e:gateway test/gateway-restart-resume.e2e.test.ts test/gateway-restart-handoff.e2e.test.ts --maxWorkers=1: 2 passed / 1 Linux-only skipped on macOS. SIGTERM markers+abort 24.6 ms, shutdown 381 ms; managed restart shutdown 359 ms. Linux Testbox queued and was stopped; Linux handoff remains a specific proof gap for CI/coordinator.pnpm tsgo:core, all 29 core test typecheck graphs, final owning CLI test graph, targeted oxlint/oxfmt, both line-count ratchets, andgit diff --check: pass. No cap/baseline changes. Whole diff: production +26, tests −11, docs +6 lines.pr-simplify: reused existing shutdown, retirement, and cancellation owners; removed duplicate close tracking and test scaffolding. Final local Codex autoreview of the entire base-to-candidate snapshot: complete/scoped-clean at P0/P1, no actionable findings. The committed candidate has the same reviewed bytes.No live deployment, schema, configuration option, dependency, version, or changelog change. CI observation and merge belong to the coordinator; this PR does not enable auto-merge.