Repository navigation
Description
Version / branch / commit
main @ dc15e822. The test and pool.go are unchanged since #274, so this affects every branch.
OS and environment
Observed on CI: Smoke (windows-latest), Windows Server 2025, Go per go.mod. Not OS-specific in principle — it is a scheduling race, and Windows CI is simply where the window is widest.
Steps to reproduce
go test ./internal/daemon/ -run TestPoolDrainKillsStraggler
Intermittent. It does not reproduce on an idle machine — I ran 30× normally and 200× under GOMAXPROCS=1 on Windows 11, all green. It shows up on loaded shared CI runners.
Recent occurrence: https://github.com/Gitlawb/zero/actions/runs/32013099576/job/95336704923 (on the PR #892 branch, whose diff touches only internal/config, internal/cli, and internal/tui — nothing in internal/daemon).
Expected behavior
Drain() force-kills a worker still running after KillTimeout, so straggler.killed == 1.
Actual behavior
--- FAIL: TestPoolDrainKillsStraggler (0.00s)
pool_test.go:231: Drain must kill a straggler still running after KillTimeout
FAIL github.com/Gitlawb/zero/internal/daemon 0.781s
Root cause
The test waits on the wrong piece of state. It gates on the slot lease, while Drain gates on the tracked worker set, and there is a window between the two.
internal/daemon/pool_test.go:222—waitFor(t, func() bool { return pool.QueueDepth() == 1 })internal/daemon/pool.go:169—QueueDepth()islen(p.slots), i.e. slot-channel occupancy, set the momentRunleases a slot.internal/daemon/pool.go:246— the handle only entersp.activelater, inrunOnce→p.track(id, handle), afterLauncherreturns.internal/daemon/pool.go:336—Drain's grace loop readslen(p.active).
So waitFor can return while p.active is still empty. If Drain() runs in that window it takes the early return at pool.go:339:
if n == 0 {
return // all workers drained gracefully
}and never reaches the force-kill block at pool.go:344-354. straggler.killed stays 0, which is exactly the assertion that fires.
This is a test-synchronization defect, not a Drain bug — production Drain is correct for a worker that is actually tracked.
Suggested fix
Synchronize on the state Drain actually reads. WorkerStats() (pool.go:361) is built from p.active, so:
waitFor(t, func() bool { return len(pool.WorkerStats()) == 1 })Worth a quick grep for the same QueueDepth()-as-readiness assumption in the neighbouring pool tests.
Activity
jatmn commentedon Aug 18, 2026
working on this.
fix(daemon): synchronize TestPoolDrainKillsStraggler on active workers
fix(daemon): synchronize TestPoolDrainKillsStraggler on active workers
gnanam1990 commentedon Aug 25, 2026
Approved. The test still waits for
QueueDepth() == 1, whileDraindecides from the separately populated active-worker set, leaving the reported scheduling window. Synchronizing onWorkerStatsis the appropriately scoped test fix. PR #927 is already active and the issue is assigned; please coordinate there.fix(daemon): wait on tracked workers in TestPoolDrainKillsStraggler
fix(daemon): synchronize TestPoolDrainKillsStraggler on active workers
fix(daemon): synchronize TestPoolDrainKillsStraggler on active workers
fix(daemon): synchronize TestPoolDrainKillsStraggler on active workers
fix(daemon): synchronize TestPoolDrainKillsStraggler on active workers