From 3456e241acc5e1ffaa35f13a474c62b24a2f9ff1 Mon Sep 17 00:00:00 2001 From: "cai.zhang" Date: Tue, 12 Nov 2024 19:02:31 +0800 Subject: [PATCH] fix: [2.4]Fix the bug that retrieved from wrong field for L0 segments (#37599) issue: #37574 master pr: #37598 Signed-off-by: Cai Zhang --- internal/querynodev2/handlers.go | 2 +- internal/querynodev2/services_test.go | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/internal/querynodev2/handlers.go b/internal/querynodev2/handlers.go index bbabddf8f4860..abe645d4e5423 100644 --- a/internal/querynodev2/handlers.go +++ b/internal/querynodev2/handlers.go @@ -43,7 +43,7 @@ import ( func loadL0Segments(ctx context.Context, delegator delegator.ShardDelegator, req *querypb.WatchDmChannelsRequest) error { l0Segments := make([]*querypb.SegmentLoadInfo, 0) for _, channel := range req.GetInfos() { - for _, segmentID := range channel.GetFlushedSegmentIds() { + for _, segmentID := range channel.GetLevelZeroSegmentIds() { segmentInfo, ok := req.GetSegmentInfos()[segmentID] if !ok || segmentInfo.GetLevel() != datapb.SegmentLevel_L0 { diff --git a/internal/querynodev2/services_test.go b/internal/querynodev2/services_test.go index 86d88b37320b4..1ab3663b11aa8 100644 --- a/internal/querynodev2/services_test.go +++ b/internal/querynodev2/services_test.go @@ -69,9 +69,10 @@ type ServiceSuite struct { schema *schemapb.CollectionSchema partitionIDs []int64 // Test segments - validSegmentIDs []int64 - flushedSegmentIDs []int64 - droppedSegmentIDs []int64 + validSegmentIDs []int64 + flushedSegmentIDs []int64 + droppedSegmentIDs []int64 + levelZeroSegmentIDs []int64 // Test channel vchannel string pchannel string @@ -101,8 +102,9 @@ func (suite *ServiceSuite) SetupSuite() { suite.collectionName = "test-collection" suite.partitionIDs = []int64{222} suite.validSegmentIDs = []int64{1, 2, 3} - suite.flushedSegmentIDs = []int64{4, 5, 6} + suite.flushedSegmentIDs = []int64{5, 6} suite.droppedSegmentIDs = []int64{7, 8, 9} + suite.levelZeroSegmentIDs = []int64{4} var err error suite.mapper = metautil.NewDynChannelMapper() @@ -277,16 +279,17 @@ func (suite *ServiceSuite) TestWatchDmChannelsInt64() { PartitionIDs: suite.partitionIDs, Infos: []*datapb.VchannelInfo{ { - CollectionID: suite.collectionID, - ChannelName: suite.vchannel, - SeekPosition: suite.position, - FlushedSegmentIds: suite.flushedSegmentIDs, - DroppedSegmentIds: suite.droppedSegmentIDs, + CollectionID: suite.collectionID, + ChannelName: suite.vchannel, + SeekPosition: suite.position, + FlushedSegmentIds: suite.flushedSegmentIDs, + DroppedSegmentIds: suite.droppedSegmentIDs, + LevelZeroSegmentIds: suite.levelZeroSegmentIDs, }, }, SegmentInfos: map[int64]*datapb.SegmentInfo{ - suite.flushedSegmentIDs[0]: { - ID: suite.flushedSegmentIDs[0], + suite.levelZeroSegmentIDs[0]: { + ID: suite.levelZeroSegmentIDs[0], CollectionID: suite.collectionID, PartitionID: suite.partitionIDs[0], InsertChannel: suite.vchannel,