0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-05 13:49:10 +01:00

Fix Workerpool deadlock (#10283)

* Prevent deadlock on boost

* Force a boost in testchannelqueue
This commit is contained in:
zeripath 2020-02-15 18:44:58 +00:00 committed by GitHub
parent 15614a8368
commit 88986746d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -26,16 +26,19 @@ func TestChannelQueue(t *testing.T) {
queue, err := NewChannelQueue(handle, queue, err := NewChannelQueue(handle,
ChannelQueueConfiguration{ ChannelQueueConfiguration{
WorkerPoolConfiguration: WorkerPoolConfiguration{ WorkerPoolConfiguration: WorkerPoolConfiguration{
QueueLength: 20, QueueLength: 0,
MaxWorkers: 10, MaxWorkers: 10,
BlockTimeout: 1 * time.Second, BlockTimeout: 1 * time.Second,
BoostTimeout: 5 * time.Minute, BoostTimeout: 5 * time.Minute,
BoostWorkers: 5, BoostWorkers: 5,
}, },
Workers: 1, Workers: 0,
Name: "TestChannelQueue",
}, &testData{}) }, &testData{})
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, queue.(*ChannelQueue).WorkerPool.boostWorkers, 5)
go queue.Run(nilFn, nilFn) go queue.Run(nilFn, nilFn)
test1 := testData{"A", 1} test1 := testData{"A", 1}

View file

@ -132,8 +132,8 @@ func (p *WorkerPool) pushBoost(data Data) {
p.blockTimeout /= 2 p.blockTimeout /= 2
p.lock.Unlock() p.lock.Unlock()
}() }()
p.addWorkers(ctx, boost)
p.lock.Unlock() p.lock.Unlock()
p.addWorkers(ctx, boost)
p.dataChan <- data p.dataChan <- data
} }
} }