Repository navigation
fix(gateway): frozen worker processes never resume when the host ps stalls - #123976
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 10:50 AM ET / 14:50 UTC. ClawSweeper reviewWhat this changesThe PR bounds and kills stalled remote Merge readinessKeep open: this MEMBER-authored, Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherGateway workspace sync temporarily pauses remote worker processes through generated scripts and a lease-backed watchdog before reconciling workspace changes. The watchdog and explicit resume path probe process identity, thaw stopped workers, and remove the lease when recovery is complete. flowchart LR
A[Workspace synchronization] --> B[Quiesce remote worker]
B --> C[Lease-backed watchdog]
C --> D[Bounded process probe]
D --> E[Resume or retry recovery]
E --> F[Worker continues]
E --> G[Lease removed]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +35, Tests +234. Total +269 across 3 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Retain the shared lease/watchdog recovery owner and run the stopped-worker, stalled- Do we have a high-confidence way to reproduce the issue? No high-confidence current-main reproduction was possible: the available test defines a concrete real-process stopped-worker scenario, but local main and the PR’s final integrated proof could not be accessed. Is this the best way to solve the issue? Unclear: keeping bounded probing and recovery in the lease/watchdog owner is the narrowest observed design, but unavailable main/history evidence prevents a final best-fix conclusion. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ee6e0251b461. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (25 earlier review cycles; latest 8 shown)
|
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
484284f to
825d0bd
Compare
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
processIdentity() ran `ps` through execFileSync with no timeout, while its two siblings in the same script (processes(), processStatus()) both pass timeout: 2000. Every thaw path gates on it — resumeProcesses(), the watchdog expiry loop, and REMOTE_WORKSPACE_RESUME_JS all call processIdentity before each SIGCONT — so a host whose `ps` stalls leaves the entire lease frozen with no remaining resumer. SIGSTOP cannot be caught, so those processes never run again and never release their memory. Bring processIdentity to parity with its siblings. Measured with the exported scripts against a fixture whose `ps` stalls on the identity lookup: unbounded resume was still hung when a 20s cap killed it (exit 124); bounded resume fails in 2s with `spawnSync ps ETIMEDOUT`.
…tchdog A bounded identity lookup still fails on a stalled host ps. Resume retired the watchdog first, so an aborted sweep left the lease with no resumer at all and the frozen workers stopped forever. Thawing first keeps the watchdog as the recovery owner that clears the lease at expiry; the orphan sweep had the same inverted order.
…y probe At lease expiry the watchdog ran the same bounded ps lookup and its catch retired the process on the first ETIMEDOUT, so a stall spanning expiry left the frozen workers with no resumer at all. It now re-probes on a bounded schedule and still verifies pid start time before every SIGCONT.
… can fire execFileSync's timeout only sends killSignal and then waits for the child to exit, so under the default SIGTERM a ps that ignores it blocked the thaw forever and the added timeout bounded nothing. All three probes now kill the stuck child; verified a TERM-ignoring ps returns in ~2s instead of hanging.
…try count A fixed 150-attempt budget reinstated the permanent freeze for any ps stall longer than five minutes. The watchdog now backs off up to 60s and keeps retrying until its sweep completes or the lease file is gone, which is the condition that actually means the workers no longer need a resumer.
… rollback ClawSweeper on 0162987: the explicit resume path was reordered to thaw before retiring its watchdog, but the initial quiescence sweep's rollback still retired first. A bounded identity probe can throw inside resumeProcesses, and by then the watchdog was already gone, leaving a stopped worker with no remaining recovery owner and the lease still present. Apply the same owner-preserving order to the rollback path, so the last resumer outlives a failed thaw exactly as it does on explicit resume. Production +3/-1: the resume call moves ahead of the watchdog retirement, plus a two-line contract comment.
Review fixes on top of the killable-probe change, from one native pass and two cold passes: - The watchdog retried forever on an unparseable lease, leaving an immortal detached process. The pids to resume live in that file, so retrying cannot recover them; an unusable lease is now terminal. - A missing ps binary throws ENOENT too, so the watchdog retired as if the lease were gone while its workers stayed SIGSTOPped. Only the lease path retires it now, discriminated on error.path. - The thaw-first reorder stretched two unlink races. The resume script and the orphan sweep now tolerate a lease that another owner already removed, so a fully successful thaw cannot report the sync as failed. - The stalled-ps recovery test polled 5s against a backoff that doubles to 8s and never resets; widened to outlast the retry ladder. Test-file hygiene, required to land lint-clean: the additions pushed workspace-sync-scripts.test.ts past the repo max-lines cap and introduced two no-promise-executor-return errors, neither of which fires at the PR base. The promise executors now use block bodies, and the file is split by subject rather than suppressed: manifest transaction tests move to workspace-sync-manifest.test.ts, quiescence tests stay. The moved block is byte-identical and no helper crosses the boundary. Proof gap: the gateway vitest project cannot run in this checkout (pre-existing configureFsSafeNative import failure from stale node_modules), so the split and the new tests are verified by git comparison, static analysis, oxlint, and isolated execution of the embedded scripts rather than by a suite run.
Restore the healthy process probe after the expected failure, resume the lease, and wait for the detached watchdog to exit so repeated runs do not leak recovery processes. Co-authored-by: jesse-merhi <[email protected]>
825d0bd to
7038a0b
Compare
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…talls (openclaw#123976) * fix(gateway): bound quiescence identity lookups so thaw cannot hang processIdentity() ran `ps` through execFileSync with no timeout, while its two siblings in the same script (processes(), processStatus()) both pass timeout: 2000. Every thaw path gates on it — resumeProcesses(), the watchdog expiry loop, and REMOTE_WORKSPACE_RESUME_JS all call processIdentity before each SIGCONT — so a host whose `ps` stalls leaves the entire lease frozen with no remaining resumer. SIGSTOP cannot be caught, so those processes never run again and never release their memory. Bring processIdentity to parity with its siblings. Measured with the exported scripts against a fixture whose `ps` stalls on the identity lookup: unbounded resume was still hung when a 20s cap killed it (exit 124); bounded resume fails in 2s with `spawnSync ps ETIMEDOUT`. * fix(gateway): thaw frozen processes before retiring the quiescence watchdog A bounded identity lookup still fails on a stalled host ps. Resume retired the watchdog first, so an aborted sweep left the lease with no resumer at all and the frozen workers stopped forever. Thawing first keeps the watchdog as the recovery owner that clears the lease at expiry; the orphan sweep had the same inverted order. * fix(gateway): keep the quiescence watchdog retrying a stalled identity probe At lease expiry the watchdog ran the same bounded ps lookup and its catch retired the process on the first ETIMEDOUT, so a stall spanning expiry left the frozen workers with no resumer at all. It now re-probes on a bounded schedule and still verifies pid start time before every SIGCONT. * fix(gateway): make the quiescence ps probes killable so their timeout can fire execFileSync's timeout only sends killSignal and then waits for the child to exit, so under the default SIGTERM a ps that ignores it blocked the thaw forever and the added timeout bounded nothing. All three probes now kill the stuck child; verified a TERM-ignoring ps returns in ~2s instead of hanging. * fix(gateway): retire the quiescence watchdog on recovery, not on a retry count A fixed 150-attempt budget reinstated the permanent freeze for any ps stall longer than five minutes. The watchdog now backs off up to 60s and keeps retrying until its sweep completes or the lease file is gone, which is the condition that actually means the workers no longer need a resumer. * fix(gateway): thaw before retiring the watchdog in initial quiescence rollback ClawSweeper on 0162987: the explicit resume path was reordered to thaw before retiring its watchdog, but the initial quiescence sweep's rollback still retired first. A bounded identity probe can throw inside resumeProcesses, and by then the watchdog was already gone, leaving a stopped worker with no remaining recovery owner and the lease still present. Apply the same owner-preserving order to the rollback path, so the last resumer outlives a failed thaw exactly as it does on explicit resume. Production +3/-1: the resume call moves ahead of the watchdog retirement, plus a two-line contract comment. * fix(gateway): harden quiescence recovery after two-phase code review Review fixes on top of the killable-probe change, from one native pass and two cold passes: - The watchdog retried forever on an unparseable lease, leaving an immortal detached process. The pids to resume live in that file, so retrying cannot recover them; an unusable lease is now terminal. - A missing ps binary throws ENOENT too, so the watchdog retired as if the lease were gone while its workers stayed SIGSTOPped. Only the lease path retires it now, discriminated on error.path. - The thaw-first reorder stretched two unlink races. The resume script and the orphan sweep now tolerate a lease that another owner already removed, so a fully successful thaw cannot report the sync as failed. - The stalled-ps recovery test polled 5s against a backoff that doubles to 8s and never resets; widened to outlast the retry ladder. Test-file hygiene, required to land lint-clean: the additions pushed workspace-sync-scripts.test.ts past the repo max-lines cap and introduced two no-promise-executor-return errors, neither of which fires at the PR base. The promise executors now use block bodies, and the file is split by subject rather than suppressed: manifest transaction tests move to workspace-sync-manifest.test.ts, quiescence tests stay. The moved block is byte-identical and no helper crosses the boundary. Proof gap: the gateway vitest project cannot run in this checkout (pre-existing configureFsSafeNative import failure from stale node_modules), so the split and the new tests are verified by git comparison, static analysis, oxlint, and isolated execution of the embedded scripts rather than by a suite run. * test(gateway): clean up stalled probe watchdog Restore the healthy process probe after the expected failure, resume the lease, and wait for the detached watchdog to exit so repeated runs do not leak recovery processes. Co-authored-by: jesse-merhi <[email protected]> * fix(gateway): clean up failed watchdog startup * fix(gateway): release empty quiescence leases
Workspace sync could leave worker processes frozen forever when the host's
pscommand stalled during an identity check. Because the workers were stopped withSIGSTOP, they could not recover themselves, stranding builds, deploys, or agent sessions. This PR bounds every identity probe, keeps the watchdog responsible until thaw succeeds, and releases empty leases without depending onps. A stalled probe now fails visibly, while the watchdog resumes real workers once the host responds again.Layer 2 of 3. #123975 is merged; #123979 depends on this PR.
Change breakdown
The test total includes a 797-line manifest-test block moved unchanged into its own file after the recovery coverage exceeded the repository's file-size limit.
Proof
Same real lease, stopped worker, and TERM-ignoring fake
psin both runs:Before: direct base
After: PR
Empty shared-host leases are removed immediately because they own no frozen processes. Malformed or identity-bearing leases still fail closed.
How to verify
Exact head
7038a0b5bc2f8731fcf75b8ee3ca95acbd6273be: exact-head CI passed, and the stopped-worker recovery scenario passed in both Gateway projects (2/2 focused tests; 20 skipped).