lib/storage: fix infinite loop introduced in aa9b56a046

This commit is contained in:
Aliaksandr Valialkin 2021-06-17 14:27:14 +03:00
parent aa9b56a046
commit dcbc22552f

View file

@ -485,14 +485,11 @@ func (rrs *rawRowsShard) addRows(pt *partition, rows []rawRow) {
rrs.rows = make([]rawRow, 0, n)
}
maxRowsCount := cap(rrs.rows)
for {
capacity := maxRowsCount - len(rrs.rows)
if capacity >= len(rows) {
// Fast path - rows fit capacity.
rrs.rows = append(rrs.rows, rows...)
break
}
capacity := maxRowsCount - len(rrs.rows)
if capacity >= len(rows) {
// Fast path - rows fit capacity.
rrs.rows = append(rrs.rows, rows...)
} else {
// Slow path - rows don't fit capacity.
// Put rrs.rows and rows to rowsToFlush and convert it to a part.
rowsToFlush = append(rowsToFlush, rrs.rows...)