From 0c00fe70cf2134e3527764b470872f802acea04f Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 30 Jul 2020 23:14:15 +0300 Subject: [PATCH] app/vmselect: do not adjust `start` and `end` query args passed to `/api/v1/query_range` when `-search.disableCache` command-line flag is set Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/563 --- app/vmselect/promql/eval.go | 9 +++++++++ app/vmselect/promql/rollup_result_cache.go | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/vmselect/promql/eval.go b/app/vmselect/promql/eval.go index 023c209bb3..e5b829a352 100644 --- a/app/vmselect/promql/eval.go +++ b/app/vmselect/promql/eval.go @@ -18,6 +18,7 @@ import ( ) var ( + disableCache = flag.Bool("search.disableCache", false, "Whether to disable response caching. This may be useful during data backfilling") maxPointsPerTimeseries = flag.Int("search.maxPointsPerTimeseries", 30e3, "The maximum points per a single timeseries returned from the search") ) @@ -43,6 +44,11 @@ func ValidateMaxPointsPerTimeseries(start, end, step int64) error { // // See EvalConfig.mayCache for details. func AdjustStartEnd(start, end, step int64) (int64, int64) { + if *disableCache { + // Do not adjust start and end values when cache is disabled. + // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/563 + return start, end + } points := (end-start)/step + 1 if points < minTimeseriesPointsForTimeRounding { // Too small number of points for rounding. @@ -117,6 +123,9 @@ func (ec *EvalConfig) validate() { } func (ec *EvalConfig) mayCache() bool { + if *disableCache { + return false + } if !ec.MayCache { return false } diff --git a/app/vmselect/promql/rollup_result_cache.go b/app/vmselect/promql/rollup_result_cache.go index 51f8cbb3f9..6bb1e5f887 100644 --- a/app/vmselect/promql/rollup_result_cache.go +++ b/app/vmselect/promql/rollup_result_cache.go @@ -21,7 +21,6 @@ import ( ) var ( - disableCache = flag.Bool("search.disableCache", false, "Whether to disable response caching. This may be useful during data backfilling") cacheTimestampOffset = flag.Duration("search.cacheTimestampOffset", 5*time.Minute, "The maximum duration since the current time for response data, "+ "which is always queried from the original raw data, without using the response cache. Increase this value if you see gaps in responses "+ "due to time synchronization issues between VictoriaMetrics and data sources") @@ -142,7 +141,7 @@ func ResetRollupResultCache() { } func (rrc *rollupResultCache) Get(ec *EvalConfig, expr metricsql.Expr, window int64) (tss []*timeseries, newStart int64) { - if *disableCache || !ec.mayCache() { + if !ec.mayCache() { return nil, ec.Start } @@ -223,7 +222,7 @@ func (rrc *rollupResultCache) Get(ec *EvalConfig, expr metricsql.Expr, window in var resultBufPool bytesutil.ByteBufferPool func (rrc *rollupResultCache) Put(ec *EvalConfig, expr metricsql.Expr, window int64, tss []*timeseries) { - if *disableCache || len(tss) == 0 || !ec.mayCache() { + if len(tss) == 0 || !ec.mayCache() { return }