Repository navigation
fix(gateway): stop endless thaw recovery on busy gateways - #149369
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: blocked before merge. Reviewed September 15, 2026, 10:18 PM ET / September 16, 2026, 02:18 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR distinguishes CPU-heavy timing gaps from host pauses, limits thaw restart retries to ten minutes, and keeps admission open during busy checks. Merge readiness⛔ Blocked before merge - 4 items remain This remains useful work: current main and v2026.9.4 still have unbounded thaw retries. No discrete implementation bug was found, but the previously raised recovery tradeoff for accounts with health monitoring disabled remains unresolved. Priority: P2 Review scores
Verification
How this fits togetherGateway maintenance detects long timer gaps and coordinates channel recovery with the shared work-admission owner. It refreshes health and presence, while channel lifecycle management performs eligible reconnects. flowchart TD
A[Maintenance tick and CPU samples] --> B{Long low-CPU gap?}
B -->|No| C[Ordinary maintenance]
B -->|Yes| D[Refresh health and presence]
B -->|Yes| E{Idle within ten minutes?}
E -->|Yes| F[Fence admission and reconnect channels]
E -->|No| G[Expire thaw retry]
G --> H[Health monitoring if enabled]
Decision needed
Why: The expiry is intentional, but its advertised health-monitor fallback does not cover supported opt-outs; selecting their recovery guarantee changes shipped behavior. Before merge
Agent review detailsSecurityNone. PR surfaceSource +36, Tests +79, Docs +2. Total +117 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep recovery bounded and admission quiet, with an explicit, tested recovery outcome for existing health-monitor opt-outs and maintainer acceptance of that upgrade tradeoff. Do we have a high-confidence way to reproduce the issue? Yes, from source: a qualifying timer gap followed by repeated busy snapshots keeps current-main recovery pending indefinitely and repeatedly cycles admission. The supplied regression results support this path; this read-only review did not execute it. Is this the best way to solve the issue? Yes for CPU filtering and synchronous idle-before-admission checks. Universal expiry is a reasonable bounded policy, but its monitor-disabled upgrade outcome needs explicit acceptance and coverage. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 78052a3386b3. LabelsLabel 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 (3 earlier review cycles) |
37c4e1f to
264e875
Compare
264e875 to
7f92b28
Compare
Distinguish CPU-bound timing gaps from host suspension and bound post-thaw channel restart retries to ten minutes. Inspect active work before preparing admission so busy maintenance ticks leave work admission untouched.
7f92b28 to
589f48c
Compare
|
Merged via squash.
|
…49369) Distinguish CPU-bound timing gaps from host suspension and bound post-thaw channel restart retries to ten minutes. Inspect active work before preparing admission so busy maintenance ticks leave work admission untouched.
What Problem This Solves
Fixes repeated admission closures and stale channel recovery when a busy Gateway mistakes CPU-bound event-loop stalls for host sleep.
On team.openclaw.ai on September 15, 2026, one hour of journal evidence showed 119 deferred-thaw messages, 119 admission closures, and 119 reopenings—one triple per maintenance tick—even though the host never slept. Event-loop utilization was 1.0, CPU core ratio was 1.0–2.2, and one p99 event-loop delay reached 16.2 seconds at 17:07 UTC. Recovery could remain pending until an arbitrary idle moment hours later.
Related: #131046.
User Impact
Busy Gateways keep accepting work during deferred thaw checks, avoid channel recovery caused by CPU load, and stop carrying stale post-thaw restart requests after ten minutes. Genuine low-CPU sleep gaps still recover when idle. No configuration or operator migration is required.
Why This Change Was Made
The thaw owner samples cumulative process CPU time at every maintenance tick. A qualifying wall-clock gap with CPU time at least half its duration is logged once as load and schedules no thaw actions. Keeping the existing event-loop measurements avoids masking the load; ordinary health and presence maintenance continues.
A real thaw starts a ten-minute restart window (20 normal maintenance ticks), including time spent waiting for admission to reopen. Deferral logs once per thaw; expiration logs once and clears the pending restart. Maintenance reads the canonical active-work snapshot before synchronously preparing and committing admission, preserving the existing restart fence without busy-path close/rollback cycles.
The 45-second threshold, channel restart mechanics, health probes, and ordinary channel health monitoring are unchanged. The CPU ratio is a heuristic: heavy CPU work mixed with a real sleep can classify the gap as load. After the ten-minute window, automatic channel health monitoring owns further recovery. In-flight restart work is allowed to settle.
Evidence
Regression-first proof used the same two test files before and after the production edit:
Before: 6 failed, 45 passed. After: 51 passed.
does not recover from a CPU-busy gap with ratio %s(0.5, 1, 2.2): previously restarted once; now schedules no recovery.recovers at the threshold with CPU ratio %s(0, 0.499): real low-CPU gaps still recover.abandons busy retries after ten minutes, logging deferral and abandonment once: previously made 22 attempts where the bound allows 20; now stops and permits an independent later thaw.does not renew the restart window while admission stays closed: previously restarted after expiration; now only refreshes health/presence after admission reopens.leaves admission untouched on busy thaw ticks and retries a failed idle pass: previously emitted twopreparing → acceptingcycles; now emits none while busy and retains fenced idle retries.Additional validation:
node scripts/check-changed.mjs,node scripts/check-docs-mdx.mjs docs/cli/channels.md, andgit diff --check. Independent Codex autoreview found no actionable P0–P2 issues. Updateddocs/cli/channels.mdwith detection, retry-window, and health-monitor behavior.Proof uses controlled CPU samples and synthetic maintenance timers with the real admission owner. No live Gateway was restarted, and no physical sleep/wake or production-load test was run. Exact-head CI will be recorded after the PR run completes. This PR is handed off for coordinator review and landing.