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 ab740afd0d
commit f4a38f7fb1

View File

@ -53,8 +53,7 @@ func InitRollupResultCache(cachePath string) {
c = workingsetcache.New(cacheSize, time.Hour)
}
if *disableCache {
c.Stop()
c = nil
c.Reset()
}
stats := &fastcache.Stats{}
@ -99,10 +98,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)