Skip to content

Commit

Permalink
Fix Workerpool deadlock (#10283)
Browse files Browse the repository at this point in the history
* Prevent deadlock on boost

* Force a boost in testchannelqueue
  • Loading branch information
zeripath authored Feb 15, 2020
1 parent 15614a8 commit 8898674
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions modules/queue/queue_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion modules/queue/workerpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 8898674

Please sign in to comment.