mirror of https://github.com/milvus-io/milvus.git
enhance: skip loading duplicated index (#29715)
this protect the loading index from failure, and speed up the loading progress Signed-off-by: yah01 <yang.cen@zilliz.com>pull/29901/head
parent
67ab5be15a
commit
44fe06f198
|
@ -888,19 +888,28 @@ func (s *LocalSegment) LoadDeltaData(ctx context.Context, deltaData *storage.Del
|
|||
func (s *LocalSegment) LoadIndex(ctx context.Context, indexInfo *querypb.FieldIndexInfo, fieldType schemapb.DataType) error {
|
||||
ctx, sp := otel.Tracer(typeutil.QueryNodeRole).Start(ctx, fmt.Sprintf("LoadIndex-%d-%d", s.segmentID, indexInfo.GetFieldID()))
|
||||
defer sp.End()
|
||||
loadIndexInfo, err := newLoadIndexInfo(ctx)
|
||||
defer deleteLoadIndexInfo(loadIndexInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log := log.Ctx(ctx).With(
|
||||
zap.Int64("collectionID", s.Collection()),
|
||||
zap.Int64("partitionID", s.Partition()),
|
||||
zap.Int64("segmentID", s.ID()),
|
||||
zap.Int64("fieldID", indexInfo.FieldID),
|
||||
zap.Int64("fieldID", indexInfo.GetFieldID()),
|
||||
zap.Int64("indexID", indexInfo.GetIndexID()),
|
||||
)
|
||||
|
||||
old := s.GetIndex(indexInfo.GetFieldID())
|
||||
// the index loaded
|
||||
if old != nil && old.IndexInfo.GetIndexID() == indexInfo.GetIndexID() {
|
||||
log.Warn("index already loaded")
|
||||
return nil
|
||||
}
|
||||
|
||||
loadIndexInfo, err := newLoadIndexInfo(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer deleteLoadIndexInfo(loadIndexInfo)
|
||||
|
||||
err = loadIndexInfo.appendLoadIndexInfo(ctx, indexInfo, s.collectionID, s.partitionID, s.segmentID, fieldType)
|
||||
if err != nil {
|
||||
if loadIndexInfo.cleanLocalData(ctx) != nil {
|
||||
|
|
Loading…
Reference in New Issue