From 88986746d51ef9bf7ea5d812bb889f8cc668b4f2 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 15 Feb 2020 18:44:58 +0000 Subject: [PATCH] Fix Workerpool deadlock (#10283) * Prevent deadlock on boost * Force a boost in testchannelqueue --- modules/queue/queue_channel_test.go | 7 +++++-- modules/queue/workerpool.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/queue/queue_channel_test.go b/modules/queue/queue_channel_test.go index 8234b0f6f2a..08a64c0ab86 100644 --- a/modules/queue/queue_channel_test.go +++ b/modules/queue/queue_channel_test.go @@ -26,16 +26,19 @@ func TestChannelQueue(t *testing.T) { queue, err := NewChannelQueue(handle, ChannelQueueConfiguration{ WorkerPoolConfiguration: WorkerPoolConfiguration{ - QueueLength: 20, + QueueLength: 0, MaxWorkers: 10, BlockTimeout: 1 * time.Second, BoostTimeout: 5 * time.Minute, BoostWorkers: 5, }, - Workers: 1, + Workers: 0, + Name: "TestChannelQueue", }, &testData{}) assert.NoError(t, err) + assert.Equal(t, queue.(*ChannelQueue).WorkerPool.boostWorkers, 5) + go queue.Run(nilFn, nilFn) test1 := testData{"A", 1} diff --git a/modules/queue/workerpool.go b/modules/queue/workerpool.go index 63ec897481a..952e87681e2 100644 --- a/modules/queue/workerpool.go +++ b/modules/queue/workerpool.go @@ -132,8 +132,8 @@ func (p *WorkerPool) pushBoost(data Data) { p.blockTimeout /= 2 p.lock.Unlock() }() - p.addWorkers(ctx, boost) p.lock.Unlock() + p.addWorkers(ctx, boost) p.dataChan <- data } }