← Back to library

Cron 恢复后日志刷屏止血:给调度计时器加最小延迟下限

场景:gateway 重启后大量 overdue job 让 cron 定时器以接近 0ms 重臂,日志和磁盘 I/O 飙升。前置:可升级到含修复版本或自行补丁。步骤:定位 spin-loop 症状→设置 MIN_TIMER_DELAY_MS=1000→回归 overdue 场景。关键改动:delay clamp 从 [0, MAX] 改为 [1000, MAX]。验证:`cron: timer armed` 频率恢复正常且任务仍在 1s 内触发。风险:下限设太高会增加触发抖动。

GITHUBDiscovered 2026-02-15Author echoVic
Prerequisites
  • You can restart gateway and inspect cron logs on the host.
  • Code upgrade path or patch workflow is available for your deployment.
Steps
  1. Identify spin-loop signature after restart: timer re-arm logs appear every few milliseconds.
  2. Apply/upgrade fix that enforces `MIN_TIMER_DELAY_MS = 1000` in cron timer arming path.
  3. Restart gateway and replay overdue-job scenario to confirm no rapid re-arm loop.
  4. Track due-job latency to ensure scheduler responsiveness remains acceptable.
Commands
openclaw gateway restart
openclaw gateway status
Verify

`cron: timer armed` log volume drops sharply, and overdue jobs still fire within ~1 second windows.

Caveats
  • If your branch diverges from upstream timer implementation, patch location may differ(需验证).
  • Do not set an aggressive floor without workload testing on high-frequency schedules.
Source attribution

This tip is aggregated from community/public sources and preserved with attribution.

Open original source ↗
Visit original post