From 65a97317e4d777d8fa364a8cd7fa6c3f8a04afcb Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 11 Jun 2024 17:30:34 +0200 Subject: [PATCH] lib/streamaggr: prevent from data race inside dedupAggrShard when samplesBuf can be updated in pushSamples() while their values are read in the flush() loop without das.mu lock This issue has been introduced in the commit 253c0cffbeb835695bcda73c452b2f108433bbc1 --- lib/streamaggr/dedup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/streamaggr/dedup.go b/lib/streamaggr/dedup.go index d04980dba..1374a0e74 100644 --- a/lib/streamaggr/dedup.go +++ b/lib/streamaggr/dedup.go @@ -196,7 +196,7 @@ func (das *dedupAggrShard) flush(ctx *dedupFlushCtx, f func(samples []pushSample das.m = make(map[string]*dedupAggrSample, len(m)) das.sizeBytes.Store(0) das.itemsCount.Store(0) - das.samplesBuf = das.samplesBuf[:0] + das.samplesBuf = make([]dedupAggrSample, 0, len(das.samplesBuf)) } das.mu.Unlock()