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