Skip to content

Commit

Permalink
fix: Set & Return correct SegmentLevel in querynode segment manager (#…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
congqixia authored Jan 8, 2024
1 parent cd34de7 commit fe47dee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/querynodev2/delegator/delegator_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 8 additions & 4 deletions internal/querynodev2/segments/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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](),
Expand Down
2 changes: 1 addition & 1 deletion internal/querynodev2/segments/segment_l0.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fe47dee

Please sign in to comment.