Fix memory leak in indexservice (#5779)

Signed-off-by: sunby <bingyi.sun@zilliz.com>
This commit is contained in:
sunby 2021-06-15 18:25:55 +08:00 committed by GitHub
parent ebe5073749
commit 324f5d1df7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -474,12 +474,19 @@ func (nt *nodeTasks) finishTask(indexBuildID UniqueID) {
nt.lock.Lock()
defer nt.lock.Unlock()
for serverID := range nt.nodeID2Tasks {
for i, buildID := range nt.nodeID2Tasks[serverID] {
if buildID == indexBuildID {
nt.nodeID2Tasks[serverID] = append(nt.nodeID2Tasks[serverID][:i], nt.nodeID2Tasks[serverID][:i+1]...)
removed := false
for serverID, taskIDs := range nt.nodeID2Tasks {
for i := 0; i < len(taskIDs); i++ {
if indexBuildID == taskIDs[i] {
taskIDs = append(taskIDs[:i], taskIDs[i+1:]...)
removed = true
break
}
}
if removed {
nt.nodeID2Tasks[serverID] = taskIDs
break
}
}
}