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 <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2024-01-08 14:16:48 +08:00 committed by GitHub
parent cd34de7de5
commit fe47deebf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -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",

View File

@ -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](),

View File

@ -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