lib/storage: yet another attempt to properly determine disk space shortage, which prevents from optimal merges

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1373
This commit is contained in:
Aliaksandr Valialkin 2021-07-27 12:02:52 +03:00
parent 92628f9f07
commit 1950f57316

View File

@ -1425,15 +1425,17 @@ func appendPartsToMerge(dst, src []*partWrapper, maxPartsToMerge int, maxRows ui
for i := minSrcParts; i <= maxSrcParts; i++ {
for j := 0; j <= len(src)-i; j++ {
a := src[j : j+i]
rowsCount := getRowsCount(a)
if rowsCount > maxRows {
needFreeSpace = true
}
if a[0].p.ph.RowsCount*uint64(len(a)) < a[len(a)-1].p.ph.RowsCount {
// Do not merge parts with too big difference in rows count,
// since this results in unbalanced merges.
continue
}
rowsCount := getRowsCount(a)
if rowsCount > maxRows {
// There is no need in verifying remaining parts with higher number of rows
needFreeSpace = true
break
}
m := float64(rowsCount) / float64(a[len(a)-1].p.ph.RowsCount)