fix: [2.5] Ignore growing segment without start pos for seal policy (#41131)

Cherry-pick from master
pr: #41130
Related to #41129

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
hotfix-2.5.8
congqixia 2025-04-07 23:42:27 +08:00 committed by Li Liu
parent 3d54438981
commit a6bc93cb26
2 changed files with 18 additions and 1 deletions

View File

@ -301,7 +301,6 @@ func sealByBlockingL0(meta *meta) channelSealPolicy {
// util func to calculate blocking statistics
blockingStats := func(l0Segments []*SegmentInfo, minStartTs uint64) (blockingSize int64, blockingEntryNum int64) {
for _, l0Segment := range l0Segments {
// GetBinlogSizeAsBytes()
if l0Segment.GetDmlPosition().GetTimestamp() >= minStartTs {
blockingSize += id2Size[l0Segment.GetID()]
blockingEntryNum += id2EntryNum[l0Segment.GetID()]
@ -314,6 +313,11 @@ func sealByBlockingL0(meta *meta) channelSealPolicy {
var result []*SegmentInfo
for len(candidates) > 0 {
// skip segments with nil start position
if candidates[0].GetStartPosition() == nil {
candidates = candidates[1:]
continue
}
// minStartPos must be [0], since growing is sorted
blockingSize, blockingEntryNum := blockingStats(l0segments, candidates[0].GetStartPosition().GetTimestamp())

View File

@ -349,6 +349,12 @@ func Test_sealByBlockingL0(t *testing.T) {
StartPosition: &msgpb.MsgPosition{Timestamp: 35},
},
}
growing_3 := &SegmentInfo{
SegmentInfo: &datapb.SegmentInfo{
ID: 2003,
InsertChannel: "channel_1",
},
}
testCases := []*testCase{
{
@ -386,6 +392,13 @@ func Test_sealByBlockingL0(t *testing.T) {
entryNumLimit: -1,
expected: []int64{},
},
{
tag: "growing_segment_with_nil_start_position",
channel: "channel_1",
l0Segments: []*SegmentInfo{l0_1, l0_2},
growingSegments: []*SegmentInfo{growing_3},
expected: []int64{},
},
}
for _, tc := range testCases {