From 6f8866a40a7e9ddfaf0814f41dc66e2faa94d215 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sun, 28 Feb 2021 16:05:13 +0200 Subject: [PATCH] lib/promscrape: fix possible deadlock in parallel execution of target relabeling --- lib/promscrape/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/promscrape/config.go b/lib/promscrape/config.go index 641adf8f15..ceeb531fc0 100644 --- a/lib/promscrape/config.go +++ b/lib/promscrape/config.go @@ -611,9 +611,9 @@ func appendScrapeWorkForTargetLabels(dst []*ScrapeWork, swc *scrapeWorkConfig, t sw *ScrapeWork err error } - resultCh := make(chan result) - workCh := make(chan map[string]string) goroutines := cgroup.AvailableCPUs() + resultCh := make(chan result, len(targetLabels)) + workCh := make(chan map[string]string, goroutines) for i := 0; i < goroutines; i++ { go func() { for metaLabels := range workCh {