mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-11-06 17:27:31 +00:00
fix(scheduler): 空闲时入队不再误报 "level insufficient"
现场:日志满屏
[agent] interrupt queued: task#2 class=interrupt level=3 from qq (L3)
vs <nil> (?) — level insufficient
而实际成因是"当前没有运行任务可抢占",与级别毫无关系。这类假因会
把运维引到"是不是级别配低了"的错误方向(本仓反复吃亏的静默/误导同族)。
改成四种成因分开写:
idle (no running task; queued for next pick) / running in critical section
/ preempt cooldown / level insufficient
This commit is contained in:
@ -328,10 +328,16 @@ func (s *scheduler) registerInterrupt(t *Task) bool {
|
|||||||
s.enqueueInterruptLocked(t)
|
s.enqueueInterruptLocked(t)
|
||||||
// 入队而不是抢占:这也是要能看见的(否则「中断明明到了却没生效」无从解释)。
|
// 入队而不是抢占:这也是要能看见的(否则「中断明明到了却没生效」无从解释)。
|
||||||
// 两种成因分开写:临界区 vs 级别不够/冷却期。
|
// 两种成因分开写:临界区 vs 级别不够/冷却期。
|
||||||
|
// 成因必须分开写,否则「中断明明到了却没生效」无从解释。
|
||||||
|
// 特别地:**空闲时没有受害者可抢**,不该报 "level insufficient"——
|
||||||
|
// 那会让运维以为级别配错了(实测日志里满屏 "vs <nil> (?) — level insufficient")。
|
||||||
reason := "level insufficient"
|
reason := "level insufficient"
|
||||||
if critical {
|
switch {
|
||||||
|
case running == nil:
|
||||||
|
reason = "idle (no running task; queued for next pick)"
|
||||||
|
case critical:
|
||||||
reason = "running in critical section"
|
reason = "running in critical section"
|
||||||
} else if canPreempt(t, running) && running != nil && !running.LastPreemptAt.IsZero() && time.Since(running.LastPreemptAt) < preemptCooldown {
|
case canPreempt(t, running) && !running.LastPreemptAt.IsZero() && time.Since(running.LastPreemptAt) < preemptCooldown:
|
||||||
reason = "preempt cooldown"
|
reason = "preempt cooldown"
|
||||||
}
|
}
|
||||||
log.Printf("[agent] interrupt queued: %s from %s (L%d) vs %s (%s) — %s; queue=%d",
|
log.Printf("[agent] interrupt queued: %s from %s (L%d) vs %s (%s) — %s; queue=%d",
|
||||||
|
|||||||
Reference in New Issue
Block a user