mirror of https://github.com/milvus-io/milvus.git
Filter index segment with empty index file paths (#10751)
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/10730/head
parent
6f0bbf72d3
commit
ff7c107d4d
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue