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
This commit is contained in:
Aliaksandr Valialkin 2020-07-30 23:14:15 +03:00
parent e9860b2fa3
commit 0c00fe70cf
2 changed files with 11 additions and 3 deletions

View File

@ -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
}

View File

@ -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
}