lib/storage: do not update b.nextIdx if no samples are removed because of retention

This commit is contained in:
Aliaksandr Valialkin 2021-03-26 17:57:51 +02:00
parent 0c403bfd29
commit 2601cc0fb0

View File

@ -179,11 +179,14 @@ func mergeBlocks(ob, ib1, ib2 *Block, retentionDeadline int64, rowsDeleted *uint
func skipSamplesOutsideRetention(b *Block, retentionDeadline int64, rowsDeleted *uint64) {
timestamps := b.timestamps
nextIdx := b.nextIdx
nextIdxOrig := nextIdx
for nextIdx < len(timestamps) && timestamps[nextIdx] < retentionDeadline {
nextIdx++
}
atomic.AddUint64(rowsDeleted, uint64(nextIdx-b.nextIdx))
b.nextIdx = nextIdx
if n := nextIdx - nextIdxOrig; n > 0 {
atomic.AddUint64(rowsDeleted, uint64(n))
b.nextIdx = nextIdx
}
}
func appendRows(ob, ib *Block) {