fix: Fix large growing segment (#37388) (#37540)

Consider the `sealProportion` factor during segment allocation.

issue: https://github.com/milvus-io/milvus/issues/37387

pr: https://github.com/milvus-io/milvus/pull/37388

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
yihao.dai 2024-11-08 17:34:27 +08:00 committed by GitHub
parent 5c166a25b9
commit fd1ca73b61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -107,7 +107,18 @@ func AllocatePolicyL1(segments []*SegmentInfo, count int64,
for _, allocation := range segment.allocations {
allocSize += allocation.NumOfRows
}
free := segment.GetMaxRowNum() - segment.GetNumOfRows() - allocSize
// When inserts are too fast, hardTimeTick may lag, causing segment to be unable to seal in time.
// To prevent allocating large segment, introducing the sealProportion factor here.
// The condition `free < 0` ensures that the allocation exceeds the minimum sealable size,
// preventing segments from remaining unsealable indefinitely.
maxRowsWithSealProportion := int64(float64(segment.GetMaxRowNum()) * paramtable.Get().DataCoordCfg.SegmentSealProportion.GetAsFloat())
free := maxRowsWithSealProportion - segment.GetNumOfRows() - allocSize
if free < 0 {
continue
}
free = segment.GetMaxRowNum() - segment.GetNumOfRows() - allocSize
if free < count {
continue
}