From c014337ae3dec53bf414299657fae4d81fed20ab Mon Sep 17 00:00:00 2001 From: Ben Ye Date: Sat, 9 May 2026 21:45:42 +0000 Subject: [PATCH] fix(scheduler): Fix flaky TestQueueConcurrency deadlock The test could deadlock because goroutines calling dequeueRequest on a FIFORequestQueue would block indefinitely on an empty channel. This happened when odd multiples of 5 (cnt=5,15,25) raced ahead of the enqueue goroutines, causing the WaitGroup to never complete. Fix by checking queue.length() > 0 before attempting to dequeue, preventing the blocking channel receive on an empty queue. Signed-off-by: Ben Ye --- pkg/scheduler/queue/user_queues_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/scheduler/queue/user_queues_test.go b/pkg/scheduler/queue/user_queues_test.go index 382a1c2eafb..95ab21cdd71 100644 --- a/pkg/scheduler/queue/user_queues_test.go +++ b/pkg/scheduler/queue/user_queues_test.go @@ -481,7 +481,9 @@ func TestQueueConcurrency(t *testing.T) { queue.enqueueRequest(MockRequest{}) q.getNextQueueForQuerier(0, "q-1") } else if cnt%5 == 0 { - queue.dequeueRequest(0, false) + if queue.length() > 0 { + queue.dequeueRequest(0, false) + } } else if cnt%7 == 0 { q.deleteQueue("userID") }