From 74c08069efac87986fce30fdc4d1f97d7ebc9683 Mon Sep 17 00:00:00 2001 From: "cai.zhang" Date: Wed, 23 Jul 2025 19:04:53 +0800 Subject: [PATCH] fix: Set result storage version for sort compaction (#43521) issue: #43520 Signed-off-by: Cai Zhang --- internal/datacoord/meta.go | 2 +- internal/datacoord/meta_test.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/datacoord/meta.go b/internal/datacoord/meta.go index de44640443..118f1d768b 100644 --- a/internal/datacoord/meta.go +++ b/internal/datacoord/meta.go @@ -2126,7 +2126,6 @@ func (m *meta) completeSortCompactionMutation( StartPosition: oldSegment.GetStartPosition(), DmlPosition: oldSegment.GetDmlPosition(), IsImporting: oldSegment.GetIsImporting(), - StorageVersion: oldSegment.GetStorageVersion(), State: oldSegment.GetState(), Level: oldSegment.GetLevel(), LastLevel: oldSegment.GetLastLevel(), @@ -2134,6 +2133,7 @@ func (m *meta) completeSortCompactionMutation( LastPartitionStatsVersion: oldSegment.GetLastPartitionStatsVersion(), CreatedByCompaction: oldSegment.GetCreatedByCompaction(), IsInvisible: resultInvisible, + StorageVersion: resultSegment.GetStorageVersion(), ID: resultSegment.GetSegmentID(), NumOfRows: resultSegment.GetNumOfRows(), Binlogs: resultSegment.GetInsertLogs(), diff --git a/internal/datacoord/meta_test.go b/internal/datacoord/meta_test.go index c18d246b97..5943fbc00d 100644 --- a/internal/datacoord/meta_test.go +++ b/internal/datacoord/meta_test.go @@ -40,6 +40,7 @@ import ( mocks2 "github.com/milvus-io/milvus/internal/metastore/mocks" "github.com/milvus-io/milvus/internal/metastore/model" "github.com/milvus-io/milvus/internal/mocks" + "github.com/milvus-io/milvus/internal/storage" "github.com/milvus-io/milvus/pkg/v2/common" "github.com/milvus-io/milvus/pkg/v2/kv" "github.com/milvus-io/milvus/pkg/v2/metrics" @@ -439,8 +440,9 @@ func (suite *MetaBasicSuite) TestCompleteCompactionMutation() { Binlogs: []*datapb.FieldBinlog{getFieldBinlogIDs(0, 10000, 10001)}, Statslogs: []*datapb.FieldBinlog{getFieldBinlogIDs(0, 20000, 20001)}, // latest segment has 2 deltalogs, one submit for compaction, one is appended before compaction done - Deltalogs: []*datapb.FieldBinlog{getFieldBinlogIDs(0, 30000), getFieldBinlogIDs(0, 30001)}, - NumOfRows: 2, + Deltalogs: []*datapb.FieldBinlog{getFieldBinlogIDs(0, 30000), getFieldBinlogIDs(0, 30001)}, + NumOfRows: 2, + StorageVersion: storage.StorageV1, }}, } { latestSegments.SetSegment(segID, segment) @@ -455,6 +457,7 @@ func (suite *MetaBasicSuite) TestCompleteCompactionMutation() { InsertLogs: []*datapb.FieldBinlog{getFieldBinlogIDs(0, 50000)}, Field2StatslogPaths: []*datapb.FieldBinlog{getFieldBinlogIDs(0, 50001)}, NumOfRows: 2, + StorageVersion: storage.StorageV2, } result := &datapb.CompactionPlanResult{ @@ -482,6 +485,7 @@ func (suite *MetaBasicSuite) TestCompleteCompactionMutation() { suite.EqualValues(2, info.GetID()) suite.Equal(datapb.SegmentLevel_L2, info.GetLevel()) suite.Equal(commonpb.SegmentState_Flushed, info.GetState()) + suite.Equal(storage.StorageV2, info.GetStorageVersion()) binlogs := info.GetBinlogs() for _, fbinlog := range binlogs {