mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
lib/storage: remove data race when updating rowsDeleted
This commit is contained in:
parent
c5e6c5f5a6
commit
f2bff64933
@ -3,6 +3,7 @@ package storage
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/decimal"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||
@ -53,12 +54,12 @@ func mergeBlockStreamsInternal(ph *partHeader, bsw *blockStreamWriter, bsm *bloc
|
||||
}
|
||||
if dmis.Has(bsm.Block.bh.TSID.MetricID) {
|
||||
// Skip blocks for deleted metrics.
|
||||
*rowsDeleted += uint64(bsm.Block.bh.RowsCount)
|
||||
atomic.AddUint64(rowsDeleted, uint64(bsm.Block.bh.RowsCount))
|
||||
continue
|
||||
}
|
||||
if bsm.Block.bh.MaxTimestamp < retentionDeadline {
|
||||
// Skip blocks out of the given retention.
|
||||
*rowsDeleted += uint64(bsm.Block.bh.RowsCount)
|
||||
atomic.AddUint64(rowsDeleted, uint64(bsm.Block.bh.RowsCount))
|
||||
continue
|
||||
}
|
||||
if pendingBlockIsEmpty {
|
||||
@ -181,7 +182,7 @@ func skipSamplesOutsideRetention(b *Block, retentionDeadline int64, rowsDeleted
|
||||
for nextIdx < len(timestamps) && timestamps[nextIdx] < retentionDeadline {
|
||||
nextIdx++
|
||||
}
|
||||
*rowsDeleted += uint64(nextIdx - b.nextIdx)
|
||||
atomic.AddUint64(rowsDeleted, uint64(nextIdx - b.nextIdx))
|
||||
b.nextIdx = nextIdx
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user