From 8ea94ebb580612a21efaee6a344c110f59c659ce Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Tue, 12 May 2015 12:03:30 +0200 Subject: [PATCH] Check context before each preloading. --- promql/analyzer.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/promql/analyzer.go b/promql/analyzer.go index a4d2521f9..32bdc64ed 100644 --- a/promql/analyzer.go +++ b/promql/analyzer.go @@ -131,19 +131,21 @@ func (a *Analyzer) Prepare(ctx context.Context) (local.Preloader, error) { // Preload all analyzed ranges. for offset, pt := range a.offsetPreloadTimes { - if err = contextDone(ctx, env); err != nil { - return nil, err - } - start := a.Start.Add(-offset) end := a.End.Add(-offset) for fp, rangeDuration := range pt.ranges { + if err = contextDone(ctx, env); err != nil { + return nil, err + } err = p.PreloadRange(fp, start.Add(-rangeDuration), end, *stalenessDelta) if err != nil { return nil, err } } for fp := range pt.instants { + if err = contextDone(ctx, env); err != nil { + return nil, err + } err = p.PreloadRange(fp, start, end, *stalenessDelta) if err != nil { return nil, err