From d0eeae9d0eb5934013689103b8780cc7b2fc1f28 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Tue, 14 Jun 2016 14:04:22 +0200 Subject: [PATCH] retrieval: don't sync to uninitialized scrape pool This change does just signal a scrape target update to the scraping loop once an initial target set is fetched. Before, the scrape pool was directly synced, causing a race against an uninitialized scrape pool. Fixes #1703 --- retrieval/targetmanager.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/retrieval/targetmanager.go b/retrieval/targetmanager.go index b5de5962e..4788f27dc 100644 --- a/retrieval/targetmanager.go +++ b/retrieval/targetmanager.go @@ -331,7 +331,12 @@ func (ts *targetSet) runProviders(ctx context.Context, providers map[string]Targ // We wait for a full initial set of target groups before releasing the mutex // to ensure the initial sync is complete and there are no races with subsequent updates. wg.Wait() - ts.sync() + // Just signal that there are initial sets to sync now. Actual syncing must only + // happen in the runScraping loop. + select { + case ts.syncCh <- struct{}{}: + default: + } } // update handles a target group update from a target provider identified by the name.