From 33ee309fd1949dab8bffe752210c2bdccce8f7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20L=C3=B3pez?= Date: Wed, 20 Mar 2019 18:36:51 +0100 Subject: [PATCH] Fix deadlock when Telegraf is aligning aggregators (#5612) --- agent/agent.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index ec9aa7f32..338d418f7 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -378,7 +378,10 @@ func (a *Agent) runAggregators( for _, agg := range a.Config.Aggregators { wg.Add(1) go func(agg *models.RunningAggregator) { - defer wg.Done() + defer func() { + wg.Done() + close(aggregations) + }() if a.Config.Agent.RoundInterval { // Aggregators are aligned to the agent interval regardless of @@ -394,7 +397,6 @@ func (a *Agent) runAggregators( acc := NewAccumulator(agg, aggregations) acc.SetPrecision(precision, interval) a.push(ctx, agg, acc) - close(aggregations) }(agg) }