diff --git a/lib/storage/block.go b/lib/storage/block.go index 1a3d1f06d..43635f651 100644 --- a/lib/storage/block.go +++ b/lib/storage/block.go @@ -171,12 +171,12 @@ func (b *Block) deduplicateSamplesDuringMerge() { srcValues := b.values[b.nextIdx:] timestamps, values := deduplicateSamplesDuringMerge(srcTimestamps, srcValues, dedupInterval) dedups := len(srcTimestamps) - len(timestamps) - atomic.AddUint64(&dedupsDuringMerge, uint64(dedups)) + dedupsDuringMerge.Add(uint64(dedups)) b.timestamps = b.timestamps[:b.nextIdx+len(timestamps)] b.values = b.values[:b.nextIdx+len(values)] } -var dedupsDuringMerge uint64 +var dedupsDuringMerge atomic.Uint64 func (b *Block) rowsCount() int { if len(b.values) == 0 { diff --git a/lib/storage/storage.go b/lib/storage/storage.go index 661dd00d0..301d44314 100644 --- a/lib/storage/storage.go +++ b/lib/storage/storage.go @@ -560,7 +560,7 @@ func (m *Metrics) Reset() { // UpdateMetrics updates m with metrics from s. func (s *Storage) UpdateMetrics(m *Metrics) { m.RowsAddedTotal = atomic.LoadUint64(&rowsAddedTotal) - m.DedupsDuringMerge = atomic.LoadUint64(&dedupsDuringMerge) + m.DedupsDuringMerge = dedupsDuringMerge.Load() m.SnapshotsCount += uint64(s.mustGetSnapshotsCount()) m.TooSmallTimestampRows += atomic.LoadUint64(&s.tooSmallTimestampRows)