未验证 提交 ff7c107d 编写于 作者: C congqixia 提交者: GitHub

Filter index segment with empty index file paths (#10751)

Signed-off-by: NCongqi Xia <congqi.xia@zilliz.com>
上级 6f0bbf72
......@@ -205,6 +205,9 @@ func (loader *indexLoader) setIndexInfo(collectionID UniqueID, segment *Segment,
if len(pathResponse.FilePaths) <= 0 {
return errors.New("illegal index file paths")
}
if len(pathResponse.FilePaths[0].IndexFilePaths) == 0 {
return errors.New("empty index paths")
}
info := &indexInfo{
indexID: response.IndexID,
......
......@@ -111,6 +111,24 @@ func TestIndexLoader_loadIndex(t *testing.T) {
assert.NoError(t, err)
})
t.Run("test set indexinfo with empty indexFilePath", func(t *testing.T) {
historical, err := genSimpleHistorical(ctx)
assert.NoError(t, err)
segment, err := genSimpleSealedSegment()
assert.NoError(t, err)
historical.loader.indexLoader.rootCoord = newMockRootCoord()
ic := newMockIndexCoord()
ic.idxFileInfo.IndexFilePaths = []string{}
historical.loader.indexLoader.indexCoord = ic
err = historical.loader.indexLoader.setIndexInfo(defaultCollectionID, segment, simpleVecField.id)
assert.Error(t, err)
})
//t.Run("test get index failed", func(t *testing.T) {
// historical, err := genSimpleHistorical(ctx)
// assert.NoError(t, err)
......
......@@ -177,10 +177,22 @@ func (m *mockRootCoord) GetMetrics(ctx context.Context, req *milvuspb.GetMetrics
type mockIndexCoord struct {
types.Component
types.TimeTickProvider
idxFileInfo *indexpb.IndexFilePathInfo
}
func newMockIndexCoord() *mockIndexCoord {
return &mockIndexCoord{}
paths, _ := generateIndex(defaultSegmentID)
return &mockIndexCoord{
idxFileInfo: &indexpb.IndexFilePathInfo{
Status: &commonpb.Status{
ErrorCode: commonpb.ErrorCode_Success,
},
IndexBuildID: buildID,
IndexFilePaths: paths,
},
}
}
func (m *mockIndexCoord) BuildIndex(ctx context.Context, req *indexpb.BuildIndexRequest) (*indexpb.BuildIndexResponse, error) {
......@@ -196,27 +208,11 @@ func (m *mockIndexCoord) GetIndexStates(ctx context.Context, req *indexpb.GetInd
}
func (m *mockIndexCoord) GetIndexFilePaths(ctx context.Context, req *indexpb.GetIndexFilePathsRequest) (*indexpb.GetIndexFilePathsResponse, error) {
paths, err := generateIndex(defaultSegmentID)
if err != nil {
return &indexpb.GetIndexFilePathsResponse{
Status: &commonpb.Status{
ErrorCode: commonpb.ErrorCode_UnexpectedError,
},
}, nil
}
return &indexpb.GetIndexFilePathsResponse{
Status: &commonpb.Status{
ErrorCode: commonpb.ErrorCode_Success,
},
FilePaths: []*indexpb.IndexFilePathInfo{
{
Status: &commonpb.Status{
ErrorCode: commonpb.ErrorCode_Success,
},
IndexBuildID: buildID,
IndexFilePaths: paths,
},
},
FilePaths: []*indexpb.IndexFilePathInfo{m.idxFileInfo},
}, nil
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册