From 92531a38c460fabe99dd4495a1ebf6a72de3c39e Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 22 Mar 2021 11:57:57 +0200 Subject: [PATCH] app/vmselect/promql: increment key prefix for faster reset for rollup result cache --- app/vmselect/promql/rollup_result_cache.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/vmselect/promql/rollup_result_cache.go b/app/vmselect/promql/rollup_result_cache.go index b8c67d0aff..492a005cc9 100644 --- a/app/vmselect/promql/rollup_result_cache.go +++ b/app/vmselect/promql/rollup_result_cache.go @@ -137,7 +137,7 @@ var rollupResultCacheResets = metrics.NewCounter(`vm_cache_resets_total{type="pr // ResetRollupResultCache resets rollup result cache. func ResetRollupResultCache() { rollupResultCacheResets.Inc() - rollupResultCacheV.c.Reset() + atomic.AddUint64(&rollupResultCacheKeyPrefix, 1) logger.Infof("rollupResult cache has been cleared") } @@ -301,10 +301,11 @@ var ( var tooBigRollupResults = metrics.NewCounter("vm_too_big_rollup_results_total") // Increment this value every time the format of the cache changes. -const rollupResultCacheVersion = 7 +const rollupResultCacheVersion = 8 func marshalRollupResultCacheKey(dst []byte, at *auth.Token, expr metricsql.Expr, window, step int64, filters []storage.TagFilter) []byte { dst = append(dst, rollupResultCacheVersion) + dst = encoding.MarshalUint64(dst, rollupResultCacheKeyPrefix) dst = encoding.MarshalUint32(dst, at.AccountID) dst = encoding.MarshalUint32(dst, at.ProjectID) dst = encoding.MarshalInt64(dst, window)