daemon: a per-task stop does not interrupt a resumed run reacquiring capacity #1937
Notifications
Due Date
No due date set.
Blocks
#1920 Effective Go: critical paths
sam/archie
Reference: sam/archie#1937
Reference in new issue
Block a user
After #1932, a run resumed from a call wait reacquires its slot under the call-wait watcher's context, so only daemon shutdown interrupts that wait. A per-task stop leaves it waiting until capacity frees. The run's own context cannot be stored on the hold (containedctx), so the dispatcher needs the run's cancellation passed through setCallWaits or a cancel signal on the hold.
Done when stopping a task whose run is waiting to reacquire returns that wait and releases its place.
Fixed in
7d6f22d2. The run now binds its per-task stop context to its hold (hold.bindStop, a done channel since containedctx forbids storing the context), and reacquire waits on that as well as the watcher context. takeSlotLocked now takes a context and returns when it ends (it previously ignored cancellation entirely, even on shutdown), so a stopped run's re-acquire returns the wait and releases its slot and repo place; Submit's initial slot wait gets the same. Not reproducible deterministically, so no test. Ran task check (passed).