Skip to content

Commit

Permalink
app/vmselect: do not adjust start and end query args passed to `/…
Browse files Browse the repository at this point in the history
…api/v1/query_range` when `-search.disableCache` command-line flag is set

Updates #563
  • Loading branch information
valyala committed Jul 30, 2020
1 parent e9860b2 commit 0c00fe7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 9 additions & 0 deletions app/vmselect/promql/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

Expand All @@ -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.
Expand Down Expand Up @@ -117,6 +123,9 @@ func (ec *EvalConfig) validate() {
}

func (ec *EvalConfig) mayCache() bool {
if *disableCache {
return false
}
if !ec.MayCache {
return false
}
Expand Down
5 changes: 2 additions & 3 deletions app/vmselect/promql/rollup_result_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 0c00fe7

Please sign in to comment.