Skip to content

Commit 8898674

Browse files
authored
Fix Workerpool deadlock (#10283)
* Prevent deadlock on boost * Force a boost in testchannelqueue
1 parent 15614a8 commit 8898674

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

modules/queue/queue_channel_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,19 @@ func TestChannelQueue(t *testing.T) {
2626
queue, err := NewChannelQueue(handle,
2727
ChannelQueueConfiguration{
2828
WorkerPoolConfiguration: WorkerPoolConfiguration{
29-
QueueLength: 20,
29+
QueueLength: 0,
3030
MaxWorkers: 10,
3131
BlockTimeout: 1 * time.Second,
3232
BoostTimeout: 5 * time.Minute,
3333
BoostWorkers: 5,
3434
},
35-
Workers: 1,
35+
Workers: 0,
36+
Name: "TestChannelQueue",
3637
}, &testData{})
3738
assert.NoError(t, err)
3839

40+
assert.Equal(t, queue.(*ChannelQueue).WorkerPool.boostWorkers, 5)
41+
3942
go queue.Run(nilFn, nilFn)
4043

4144
test1 := testData{"A", 1}

modules/queue/workerpool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ func (p *WorkerPool) pushBoost(data Data) {
132132
p.blockTimeout /= 2
133133
p.lock.Unlock()
134134
}()
135-
p.addWorkers(ctx, boost)
136135
p.lock.Unlock()
136+
p.addWorkers(ctx, boost)
137137
p.dataChan <- data
138138
}
139139
}

0 commit comments

Comments
 (0)