From def9ccd36062f4c44ebfa289c4113433d0df6c24 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 26 Nov 2019 22:55:23 +0200 Subject: [PATCH] app/vmselect/prometheus: consistently apply `nocache` arg to `/api/v1/query` the same way ast to `/api/v1/query_range` Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/241 --- app/vmselect/prometheus/prometheus.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index c388271919..4a9080ab55 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -554,7 +554,9 @@ func QueryHandler(at *auth.Token, w http.ResponseWriter, r *http.Request) error if len(query) > *maxQueryLen { return fmt.Errorf(`too long query; got %d bytes; mustn't exceed %d bytes`, len(query), *maxQueryLen) } - if ct-start < queryOffset { + if !getBool(r, "nocache") && ct-start < queryOffset { + // Adjust start time only if `nocache` arg isn't set. + // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/241 start = ct - queryOffset } if childQuery, windowStr, offsetStr := promql.IsMetricSelectorWithRollup(query); childQuery != "" {