Fix deadlock caused by not releasing the lock in time (#12161)

Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
pull/12160/head
zhenshan.cao 2021-11-22 12:19:14 +08:00 committed by GitHub
parent dea751a419
commit 0f2b7d1790
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -147,21 +147,22 @@ func (queue *baseTaskQueue) PopActiveTask(tID UniqueID) task {
func (queue *baseTaskQueue) getTaskByReqID(reqID UniqueID) task {
queue.utLock.RLock()
defer queue.utLock.RUnlock()
for e := queue.unissuedTasks.Front(); e != nil; e = e.Next() {
if e.Value.(task).ID() == reqID {
queue.utLock.RUnlock()
return e.Value.(task)
}
}
queue.utLock.RUnlock()
queue.atLock.RLock()
defer queue.atLock.RUnlock()
for tID := range queue.activeTasks {
for tID, t := range queue.activeTasks {
if tID == reqID {
return queue.activeTasks[tID]
queue.atLock.RUnlock()
return t
}
}
queue.atLock.RUnlock()
return nil
}