mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
Check the indexcoord state before building index (#12451)
Signed-off-by: Cai.Zhang <cai.zhang@zilliz.com>
This commit is contained in:
parent
567c657310
commit
ed546d0a55
@ -361,6 +361,17 @@ func (i *IndexCoord) BuildIndex(ctx context.Context, req *indexpb.BuildIndexRequ
|
|||||||
zap.Strings("DataPath = ", req.DataPaths),
|
zap.Strings("DataPath = ", req.DataPaths),
|
||||||
zap.Any("TypeParams", req.TypeParams),
|
zap.Any("TypeParams", req.TypeParams),
|
||||||
zap.Any("IndexParams", req.IndexParams))
|
zap.Any("IndexParams", req.IndexParams))
|
||||||
|
if !i.isHealthy() {
|
||||||
|
errMsg := "IndexCoord is not healthy"
|
||||||
|
err := errors.New(errMsg)
|
||||||
|
log.Warn(errMsg)
|
||||||
|
return &indexpb.BuildIndexResponse{
|
||||||
|
Status: &commonpb.Status{
|
||||||
|
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
||||||
|
Reason: errMsg,
|
||||||
|
},
|
||||||
|
}, err
|
||||||
|
}
|
||||||
sp, ctx := trace.StartSpanFromContextWithOperationName(ctx, "IndexCoord-BuildIndex")
|
sp, ctx := trace.StartSpanFromContextWithOperationName(ctx, "IndexCoord-BuildIndex")
|
||||||
defer sp.Finish()
|
defer sp.Finish()
|
||||||
hasIndex, indexBuildID := i.metaTable.HasSameReq(req)
|
hasIndex, indexBuildID := i.metaTable.HasSameReq(req)
|
||||||
|
|||||||
@ -247,3 +247,12 @@ func TestIndexCoord_GetComponentStates(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIndexCoord_NotHealthy(t *testing.T) {
|
||||||
|
ic := &IndexCoord{}
|
||||||
|
ic.stateCode.Store(internalpb.StateCode_Abnormal)
|
||||||
|
req := &indexpb.BuildIndexRequest{}
|
||||||
|
resp, err := ic.BuildIndex(context.Background(), req)
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp.Status.ErrorCode)
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user