diff --git a/app/vmselect/promql/eval.go b/app/vmselect/promql/eval.go index 023c209bb..e5b829a35 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 51f8cbb3f..6bb1e5f88 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 }