fix: load gets stuck probably (#29191)

we found the load got stuck probably, and reviewed the logs.

the target observer seems not working, the reason is the taskDispatcher
removes the task in a goroutine, and modifies the task status after
committing the task into the goroutine pool, but this may happen after
the task removed, which leads to the task will never be removed

related #29086

Signed-off-by: yah01 <yang.cen@zilliz.com>
This commit is contained in:
yah01 2023-12-14 18:28:38 +08:00 committed by GitHub
parent b8674811cf
commit 13beb5ccc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,12 +96,12 @@ func (d *taskDispatcher[K]) schedule(ctx context.Context) {
case <-d.notifyCh:
d.tasks.Range(func(k K, submitted bool) bool {
if !submitted {
d.tasks.Insert(k, true)
d.pool.Submit(func() (any, error) {
d.taskRunner(ctx, k)
d.tasks.Remove(k)
return struct{}{}, nil
})
d.tasks.Insert(k, true)
}
return true
})