app/vmselect/promql: fix panic on -search.disableCache

Reset the cache if it is disabled instead of stopping, since it is stopped on graceful shutdown.
This commit is contained in:
Aliaksandr Valialkin 2019-08-21 17:11:05 +03:00
parent 491b1762c8
commit 90a4b00b10

View File

@ -56,8 +56,7 @@ func InitRollupResultCache(cachePath string) {
c = workingsetcache.New(cacheSize, time.Hour)
}
if *disableCache {
c.Stop()
c = nil
c.Reset()
}
stats := &fastcache.Stats{}
@ -102,10 +101,8 @@ func InitRollupResultCache(cachePath string) {
// StopRollupResultCache closes the rollupResult cache.
func StopRollupResultCache() {
if len(rollupResultCachePath) == 0 {
if !*disableCache {
rollupResultCacheV.c.Stop()
rollupResultCacheV.c = nil
}
rollupResultCacheV.c.Stop()
rollupResultCacheV.c = nil
return
}
logger.Infof("saving rollupResult cache to %q...", rollupResultCachePath)