mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
fix: Don't create index for unsorted importing segment when enable stats (#41864)
issue: #41863 --------- Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
This commit is contained in:
parent
7660be0993
commit
38ded7364f
@ -61,10 +61,6 @@ func (s *Server) startIndexService(ctx context.Context) {
|
||||
}
|
||||
|
||||
func (s *Server) createIndexForSegment(ctx context.Context, segment *SegmentInfo, indexID UniqueID) error {
|
||||
if !segment.GetIsSorted() && Params.DataCoordCfg.EnableStatsTask.GetAsBool() && !segment.GetIsImporting() && segment.Level != datapb.SegmentLevel_L0 {
|
||||
log.Info("segment not sorted, skip create index", zap.Int64("segmentID", segment.GetID()))
|
||||
return nil
|
||||
}
|
||||
log.Info("create index for segment", zap.Int64("segmentID", segment.ID), zap.Int64("indexID", indexID))
|
||||
buildID, err := s.allocator.AllocID(context.Background())
|
||||
if err != nil {
|
||||
@ -89,7 +85,7 @@ func (s *Server) createIndexForSegment(ctx context.Context, segment *SegmentInfo
|
||||
}
|
||||
|
||||
func (s *Server) createIndexesForSegment(ctx context.Context, segment *SegmentInfo) error {
|
||||
if Params.DataCoordCfg.EnableStatsTask.GetAsBool() && !segment.GetIsSorted() && !segment.GetIsImporting() {
|
||||
if Params.DataCoordCfg.EnableStatsTask.GetAsBool() && !segment.GetIsSorted() {
|
||||
log.Ctx(ctx).Debug("segment is not sorted by pk, skip create indexes", zap.Int64("segmentID", segment.GetID()))
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -877,16 +877,26 @@ func (s *Server) postFlush(ctx context.Context, segmentID UniqueID) error {
|
||||
}
|
||||
// set segment to SegmentState_Flushed
|
||||
var operators []UpdateOperator
|
||||
operators = append(operators, SetSegmentIsInvisible(segmentID, true))
|
||||
if Params.DataCoordCfg.EnableStatsTask.GetAsBool() {
|
||||
operators = append(operators, SetSegmentIsInvisible(segmentID, true))
|
||||
}
|
||||
operators = append(operators, UpdateStatusOperator(segmentID, commonpb.SegmentState_Flushed))
|
||||
err := s.meta.UpdateSegmentsInfo(ctx, operators...)
|
||||
if err != nil {
|
||||
log.Warn("flush segment complete failed", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
select {
|
||||
case getStatsTaskChSingleton() <- segmentID:
|
||||
default:
|
||||
|
||||
if Params.DataCoordCfg.EnableStatsTask.GetAsBool() {
|
||||
select {
|
||||
case getStatsTaskChSingleton() <- segmentID:
|
||||
default:
|
||||
}
|
||||
} else {
|
||||
select {
|
||||
case getBuildIndexChSingleton() <- segmentID:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
insertFileNum := 0
|
||||
|
||||
@ -4809,6 +4809,7 @@ if param targetVecIndexVersion is not set, the default value is -1, which means
|
||||
DefaultValue: "true",
|
||||
PanicIfEmpty: false,
|
||||
Export: false,
|
||||
Forbidden: true,
|
||||
}
|
||||
p.EnableStatsTask.Init(base.mgr)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user