From a9a214e19a4eb3979bd7dc9f27c07dc25bec6341 Mon Sep 17 00:00:00 2001 From: Lars Stegman Date: Mon, 7 Oct 2024 16:20:01 +0200 Subject: [PATCH] fix(inputs.influxdb_v2_listener): Fix concurrent read/write dict (#15982) --- plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go b/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go index 612521f97..07146192f 100644 --- a/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go +++ b/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go @@ -166,12 +166,12 @@ func (h *InfluxDBV2Listener) Start(acc telegraf.Accumulator) error { case <-h.ctx.Done(): return case info := <-h.trackingAcc.Delivered(): + h.countLock.Lock() if count, ok := h.trackingMetricCount[info.ID()]; ok { - h.countLock.Lock() h.totalUndeliveredMetrics.Add(-count) delete(h.trackingMetricCount, info.ID()) - h.countLock.Unlock() } + h.countLock.Unlock() } } }()