From f160f17a6f13583c45b693550e3f8066cbaf330e Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Thu, 11 May 2017 16:15:07 +0200 Subject: [PATCH] retrieval: fix missing scrape context cancellation (#2599) --- retrieval/scrape.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retrieval/scrape.go b/retrieval/scrape.go index f537c8496..052396b7c 100644 --- a/retrieval/scrape.go +++ b/retrieval/scrape.go @@ -413,7 +413,7 @@ func (sl *scrapeLoop) run(interval, timeout time.Duration, errc chan<- error) { if !sl.appender.NeedsThrottling() { var ( start = time.Now() - scrapeCtx, _ = context.WithTimeout(sl.ctx, timeout) + scrapeCtx, cancel = context.WithTimeout(sl.ctx, timeout) numPostRelabelSamples = 0 ) @@ -425,6 +425,7 @@ func (sl *scrapeLoop) run(interval, timeout time.Duration, errc chan<- error) { } samples, err := sl.scraper.scrape(scrapeCtx, start) + cancel() if err == nil { numPostRelabelSamples, err = sl.append(samples) }