From fe47deebf3e46158ac7852904b9921fe6993a095 Mon Sep 17 00:00:00 2001 From: congqixia Date: Mon, 8 Jan 2024 14:16:48 +0800 Subject: [PATCH] fix: Set & Return correct SegmentLevel in querynode segment manager (#29740) See also #27349 The segment level label in querynode used `Legacy` before segment level was correctly passed in Load request. Now this attribute is still using legacy so the metrics does not look right. This PR add paramter for `NewSegment` and passes corrent values for each invocation. Signed-off-by: Congqi Xia --- internal/querynodev2/delegator/delegator_data.go | 2 +- internal/querynodev2/segments/segment.go | 12 ++++++++---- internal/querynodev2/segments/segment_l0.go | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/querynodev2/delegator/delegator_data.go b/internal/querynodev2/delegator/delegator_data.go index 69191dfbc4509..a6d1238230547 100644 --- a/internal/querynodev2/delegator/delegator_data.go +++ b/internal/querynodev2/delegator/delegator_data.go @@ -98,7 +98,7 @@ func (sd *shardDelegator) ProcessInsert(insertRecords map[int64]*InsertData) { 0, insertData.StartPosition, insertData.StartPosition, - datapb.SegmentLevel_Legacy, + datapb.SegmentLevel_L1, ) if err != nil { log.Error("failed to create new segment", diff --git a/internal/querynodev2/segments/segment.go b/internal/querynodev2/segments/segment.go index a7e3baed07069..efec5ddd2b97e 100644 --- a/internal/querynodev2/segments/segment.go +++ b/internal/querynodev2/segments/segment.go @@ -74,18 +74,20 @@ type baseSegment struct { shard string collectionID int64 typ SegmentType + level datapb.SegmentLevel version *atomic.Int64 startPosition *msgpb.MsgPosition // for growing segment release bloomFilterSet *pkoracle.BloomFilterSet } -func newBaseSegment(id, partitionID, collectionID int64, shard string, typ SegmentType, version int64, startPosition *msgpb.MsgPosition) baseSegment { +func newBaseSegment(id, partitionID, collectionID int64, shard string, typ SegmentType, level datapb.SegmentLevel, version int64, startPosition *msgpb.MsgPosition) baseSegment { return baseSegment{ segmentID: id, partitionID: partitionID, collectionID: collectionID, shard: shard, typ: typ, + level: level, version: atomic.NewInt64(version), startPosition: startPosition, bloomFilterSet: pkoracle.NewBloomFilterSet(id, partitionID, typ), @@ -114,7 +116,7 @@ func (s *baseSegment) Type() SegmentType { } func (s *baseSegment) Level() datapb.SegmentLevel { - return datapb.SegmentLevel_Legacy + return s.level } func (s *baseSegment) StartPosition() *msgpb.MsgPosition { @@ -205,10 +207,12 @@ func NewSegment(ctx context.Context, zap.Int64("collectionID", collectionID), zap.Int64("partitionID", partitionID), zap.Int64("segmentID", segmentID), - zap.String("segmentType", segmentType.String())) + zap.String("segmentType", segmentType.String()), + zap.String("level", level.String()), + ) segment := &LocalSegment{ - baseSegment: newBaseSegment(segmentID, partitionID, collectionID, shard, segmentType, version, startPosition), + baseSegment: newBaseSegment(segmentID, partitionID, collectionID, shard, segmentType, level, version, startPosition), ptr: newPtr, lastDeltaTimestamp: atomic.NewUint64(0), fieldIndexes: typeutil.NewConcurrentMap[int64, *IndexedFieldInfo](), diff --git a/internal/querynodev2/segments/segment_l0.go b/internal/querynodev2/segments/segment_l0.go index e0a6b7b90f698..125642e55752a 100644 --- a/internal/querynodev2/segments/segment_l0.go +++ b/internal/querynodev2/segments/segment_l0.go @@ -62,7 +62,7 @@ func NewL0Segment(collection *Collection, zap.String("segmentType", segmentType.String())) segment := &L0Segment{ - baseSegment: newBaseSegment(segmentID, partitionID, collectionID, shard, segmentType, version, startPosition), + baseSegment: newBaseSegment(segmentID, partitionID, collectionID, shard, segmentType, datapb.SegmentLevel_L0, version, startPosition), } return segment, nil