mirror of https://github.com/milvus-io/milvus.git
It is also correct to get the failed index status in indexcoord ut (#8059)
Signed-off-by: cai.zhang <cai.zhang@zilliz.com>pull/8114/head
parent
01c8341a2e
commit
fa00f1f48a
|
@ -108,7 +108,8 @@ func TestIndexCoord(t *testing.T) {
|
||||||
resp, err := ic.GetIndexStates(ctx, req)
|
resp, err := ic.GetIndexStates(ctx, req)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
||||||
if resp.States[0].State == commonpb.IndexState_Finished {
|
if resp.States[0].State == commonpb.IndexState_Finished ||
|
||||||
|
resp.States[0].State == commonpb.IndexState_Failed {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
|
@ -16,16 +16,17 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/milvus-io/milvus/internal/log"
|
"go.uber.org/zap"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
etcdkv "github.com/milvus-io/milvus/internal/kv/etcd"
|
etcdkv "github.com/milvus-io/milvus/internal/kv/etcd"
|
||||||
"github.com/milvus-io/milvus/internal/util/metricsinfo"
|
"github.com/milvus-io/milvus/internal/log"
|
||||||
|
|
||||||
"github.com/milvus-io/milvus/internal/proto/commonpb"
|
"github.com/milvus-io/milvus/internal/proto/commonpb"
|
||||||
"github.com/milvus-io/milvus/internal/proto/indexpb"
|
"github.com/milvus-io/milvus/internal/proto/indexpb"
|
||||||
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
||||||
"github.com/milvus-io/milvus/internal/proto/milvuspb"
|
"github.com/milvus-io/milvus/internal/proto/milvuspb"
|
||||||
|
"github.com/milvus-io/milvus/internal/util/metricsinfo"
|
||||||
|
"github.com/milvus-io/milvus/internal/util/retry"
|
||||||
"github.com/milvus-io/milvus/internal/util/sessionutil"
|
"github.com/milvus-io/milvus/internal/util/sessionutil"
|
||||||
"github.com/milvus-io/milvus/internal/util/typeutil"
|
"github.com/milvus-io/milvus/internal/util/typeutil"
|
||||||
)
|
)
|
||||||
|
@ -62,31 +63,73 @@ func (inm *Mock) buildIndexTask() {
|
||||||
return
|
return
|
||||||
case req := <-inm.buildIndex:
|
case req := <-inm.buildIndex:
|
||||||
if inm.Failure {
|
if inm.Failure {
|
||||||
|
saveIndexMeta := func() error {
|
||||||
indexMeta := indexpb.IndexMeta{}
|
indexMeta := indexpb.IndexMeta{}
|
||||||
|
|
||||||
_, values, versions, _ := inm.etcdKV.LoadWithPrefix2(req.MetaPath)
|
_, values, versions, err := inm.etcdKV.LoadWithPrefix2(req.MetaPath)
|
||||||
_ = proto.UnmarshalText(values[0], &indexMeta)
|
if err != nil {
|
||||||
indexMeta.IndexFilePaths = []string{"IndexFilePath-1", "IndexFilePath-2"}
|
return err
|
||||||
indexMeta.State = commonpb.IndexState_Failed
|
}
|
||||||
_ = inm.etcdKV.CompareVersionAndSwap(req.MetaPath, versions[0],
|
err = proto.UnmarshalText(values[0], &indexMeta)
|
||||||
proto.MarshalTextString(&indexMeta))
|
if err != nil {
|
||||||
continue
|
return err
|
||||||
}
|
}
|
||||||
indexMeta := indexpb.IndexMeta{}
|
|
||||||
_, values, versions, _ := inm.etcdKV.LoadWithPrefix2(req.MetaPath)
|
|
||||||
_ = proto.UnmarshalText(values[0], &indexMeta)
|
|
||||||
indexMeta.IndexFilePaths = []string{"IndexFilePath-1", "IndexFilePath-2"}
|
indexMeta.IndexFilePaths = []string{"IndexFilePath-1", "IndexFilePath-2"}
|
||||||
indexMeta.State = commonpb.IndexState_Failed
|
indexMeta.State = commonpb.IndexState_Failed
|
||||||
_ = inm.etcdKV.CompareVersionAndSwap(req.MetaPath, versions[0],
|
err = inm.etcdKV.CompareVersionAndSwap(req.MetaPath, versions[0],
|
||||||
proto.MarshalTextString(&indexMeta))
|
proto.MarshalTextString(&indexMeta))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
err := retry.Do(context.Background(), saveIndexMeta, retry.Attempts(3))
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("IndexNode Mock saveIndexMeta error", zap.Error(err))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
saveIndexMeta := func() error {
|
||||||
|
indexMeta := indexpb.IndexMeta{}
|
||||||
|
_, values, versions, err := inm.etcdKV.LoadWithPrefix2(req.MetaPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = proto.UnmarshalText(values[0], &indexMeta)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
indexMeta.IndexFilePaths = []string{"IndexFilePath-1", "IndexFilePath-2"}
|
||||||
|
indexMeta.State = commonpb.IndexState_Failed
|
||||||
|
err = inm.etcdKV.CompareVersionAndSwap(req.MetaPath, versions[0],
|
||||||
|
proto.MarshalTextString(&indexMeta))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
indexMeta2 := indexpb.IndexMeta{}
|
indexMeta2 := indexpb.IndexMeta{}
|
||||||
_, values2, versions2, _ := inm.etcdKV.LoadWithPrefix2(req.MetaPath)
|
_, values2, versions2, err := inm.etcdKV.LoadWithPrefix2(req.MetaPath)
|
||||||
_ = proto.UnmarshalText(values2[0], &indexMeta2)
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = proto.UnmarshalText(values2[0], &indexMeta2)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
indexMeta2.Version = indexMeta.Version + 1
|
indexMeta2.Version = indexMeta.Version + 1
|
||||||
indexMeta2.IndexFilePaths = []string{"IndexFilePath-1", "IndexFilePath-2"}
|
indexMeta2.IndexFilePaths = []string{"IndexFilePath-1", "IndexFilePath-2"}
|
||||||
indexMeta2.State = commonpb.IndexState_Finished
|
indexMeta2.State = commonpb.IndexState_Finished
|
||||||
_ = inm.etcdKV.CompareVersionAndSwap(req.MetaPath, versions2[0],
|
err = inm.etcdKV.CompareVersionAndSwap(req.MetaPath, versions2[0],
|
||||||
proto.MarshalTextString(&indexMeta2))
|
proto.MarshalTextString(&indexMeta2))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
err := retry.Do(context.Background(), saveIndexMeta, retry.Attempts(3))
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("IndexNode Mock saveIndexMeta error", zap.Error(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue