Should set index task retry not failed when task canceled (#26878)

Signed-off-by: cai.zhang <cai.zhang@zilliz.com>
This commit is contained in:
cai.zhang 2023-09-06 19:01:14 +08:00 committed by GitHub
parent 0844e19505
commit 8b5b137207
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -220,9 +220,9 @@ func (sched *TaskScheduler) processTask(t task, q TaskQueue) {
pipelines := []func(context.Context) error{t.Prepare, t.BuildIndex, t.SaveIndexFiles}
for _, fn := range pipelines {
if err := wrap(fn); err != nil {
if err == errCancel {
log.Ctx(t.Ctx()).Warn("index build task canceled", zap.String("task", t.Name()))
t.SetState(commonpb.IndexState_Failed, err.Error())
if errors.Is(err, errCancel) {
log.Ctx(t.Ctx()).Warn("index build task canceled, retry it", zap.String("task", t.Name()))
t.SetState(commonpb.IndexState_Retry, err.Error())
} else if errors.Is(err, ErrNoSuchKey) {
t.SetState(commonpb.IndexState_Failed, err.Error())
} else {

View File

@ -164,9 +164,9 @@ func TestIndexTaskScheduler(t *testing.T) {
tasks := make([]task, 0)
tasks = append(tasks,
newTask(fakeTaskEnqueued, nil, commonpb.IndexState_Failed),
newTask(fakeTaskPrepared, nil, commonpb.IndexState_Failed),
newTask(fakeTaskBuiltIndex, nil, commonpb.IndexState_Failed),
newTask(fakeTaskEnqueued, nil, commonpb.IndexState_Retry),
newTask(fakeTaskPrepared, nil, commonpb.IndexState_Retry),
newTask(fakeTaskBuiltIndex, nil, commonpb.IndexState_Retry),
newTask(fakeTaskSavedIndexes, nil, commonpb.IndexState_Finished),
newTask(fakeTaskSavedIndexes, map[fakeTaskState]error{fakeTaskSavedIndexes: fmt.Errorf("auth failed")}, commonpb.IndexState_Retry))