From 315d928626cfed2e71ff4765f3379cdc78dab00c Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 15 Feb 2020 19:28:25 +0000 Subject: [PATCH] Fix Workerpool deadlock (#10283) (#10284) * Prevent deadlock on boost * Force a boost in testchannelqueue --- modules/queue/queue_channel_test.go | 5 +++-- modules/queue/workerpool.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/queue/queue_channel_test.go b/modules/queue/queue_channel_test.go index fafc1e3303eb..fb5e5881d4c3 100644 --- a/modules/queue/queue_channel_test.go +++ b/modules/queue/queue_channel_test.go @@ -25,12 +25,13 @@ func TestChannelQueue(t *testing.T) { queue, err := NewChannelQueue(handle, ChannelQueueConfiguration{ - QueueLength: 20, - Workers: 1, + QueueLength: 0, MaxWorkers: 10, BlockTimeout: 1 * time.Second, BoostTimeout: 5 * time.Minute, BoostWorkers: 5, + Workers: 0, + Name: "TestChannelQueue", }, &testData{}) assert.NoError(t, err) diff --git a/modules/queue/workerpool.go b/modules/queue/workerpool.go index 25fc7dd64425..11115b0b7cd5 100644 --- a/modules/queue/workerpool.go +++ b/modules/queue/workerpool.go @@ -96,8 +96,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 } }