Task/Action won't finish util the RPC returned (#20669)

Signed-off-by: yah01 <yang.cen@zilliz.com>

Signed-off-by: yah01 <yang.cen@zilliz.com>
This commit is contained in:
yah01 2022-11-17 17:55:09 +08:00 committed by GitHub
parent 19524a5344
commit cc371d6801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 19 deletions

View File

@ -32,11 +32,6 @@ import (
"go.uber.org/zap"
)
type actionIndex struct {
Task int64
Step int
}
type Executor struct {
doneCh chan struct{}
wg sync.WaitGroup
@ -50,7 +45,7 @@ type Executor struct {
// Merge load segment requests
merger *Merger[segmentIndex, *querypb.LoadSegmentsRequest]
executingActions sync.Map
executingTasks sync.Map
}
func NewExecutor(meta *meta.Meta,
@ -69,7 +64,7 @@ func NewExecutor(meta *meta.Meta,
nodeMgr: nodeMgr,
merger: NewMerger[segmentIndex, *querypb.LoadSegmentsRequest](),
executingActions: sync.Map{},
executingTasks: sync.Map{},
}
}
@ -87,11 +82,7 @@ func (ex *Executor) Stop() {
// does nothing and returns false if the action is already committed,
// returns true otherwise.
func (ex *Executor) Execute(task Task, step int) bool {
index := actionIndex{
Task: task.ID(),
Step: step,
}
_, exist := ex.executingActions.LoadOrStore(index, struct{}{})
_, exist := ex.executingTasks.LoadOrStore(task.ID(), struct{}{})
if exist {
return false
}
@ -116,6 +107,11 @@ func (ex *Executor) Execute(task Task, step int) bool {
return true
}
func (ex *Executor) Exist(taskID int64) bool {
_, ok := ex.executingTasks.Load(taskID)
return ok
}
func (ex *Executor) scheduleRequests() {
ex.wg.Add(1)
go func() {
@ -192,11 +188,7 @@ func (ex *Executor) removeAction(task Task, step int) {
zap.Error(task.Err()))
}
index := actionIndex{
Task: task.ID(),
Step: step,
}
ex.executingActions.Delete(index)
ex.executingTasks.Delete(task.ID())
}
func (ex *Executor) executeSegmentAction(task *SegmentTask, step int) {

View File

@ -527,7 +527,7 @@ func (scheduler *taskScheduler) process(task Task) bool {
zap.Int64("source", task.SourceID()),
)
if task.IsFinished(scheduler.distMgr) {
if !scheduler.executor.Exist(task.ID()) && task.IsFinished(scheduler.distMgr) {
task.SetStatus(TaskStatusSucceeded)
} else if scheduler.checkCanceled(task) {
task.SetStatus(TaskStatusCanceled)

View File

@ -1148,7 +1148,7 @@ func (suite *TaskSuite) dispatchAndWait(node int64) {
for start := time.Now(); time.Since(start) < timeout; {
count = 0
keys = make([]any, 0)
suite.scheduler.executor.executingActions.Range(func(key, value any) bool {
suite.scheduler.executor.executingTasks.Range(func(key, value any) bool {
keys = append(keys, key)
count++
return true