🐛 Fix PriorityQueue deadlock on shutdown (#3540)
* 🐛 Fix PriorityQueue deadlock on shutdown handleReadyItems hands a ready item to a waiting consumer with an unbuffered send on w.get while holding w.lock. If ShutDown shuts the w.done channel first, the parked GetWithPriority consumer can return through <-w.done instead of receiving, so the send blocks forever and the whole queue deadlocks (every later GetWithPriority and handleAddBuffer blocks on w.lock). Wrap the send in a select that also watches w.done so it is cancelled on shutdown. Add a regression test that runs the reporter's add/get loop and fails if workers stay blocked after ShutDown. Reference: kubernetes-sigs/controller-runtime issue 3538 Signed-off-by: arpitjain099 <arpitjain099@gmail.com> * Address modernize lint findings in shutdown deadlock test Switch the counted for loops to range-over-int, use WaitGroup.Go for the worker goroutines, and replace ptr.To with the new(x) builtin, as flagged by the modernize linter. No behavior change to the test. Signed-off-by: arpitjain099 <arpitjain099@gmail.com> --------- Signed-off-by: arpitjain099 <arpitjain099@gmail.com>
A
Arpit Jain committed
b7090f65d5663ab151413ab07e6f2d1550e3963a
Parent: e26a26a
Committed by GitHub <noreply@github.com>
on 7/10/2026, 12:30:32 AM