mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: properly remove cache directory contents if reset_cache_on_startup
file is located there
Previously the cache directory was removed. This could result in error when the cache directory is mounted to a separate filesystem.
This commit is contained in:
parent
5f28ca1f42
commit
978dcb4574
1 changed files with 4 additions and 5 deletions
|
@ -169,11 +169,10 @@ func OpenStorage(path string, retentionMsecs int64, maxHourlySeries, maxDailySer
|
||||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1447 for details.
|
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1447 for details.
|
||||||
if fs.IsPathExist(s.cachePath + "/reset_cache_on_startup") {
|
if fs.IsPathExist(s.cachePath + "/reset_cache_on_startup") {
|
||||||
logger.Infof("removing cache directory at %q, since it contains `reset_cache_on_startup` file...", s.cachePath)
|
logger.Infof("removing cache directory at %q, since it contains `reset_cache_on_startup` file...", s.cachePath)
|
||||||
wg := getWaitGroup()
|
// Do not use fs.MustRemoveDirAtomic() here, since the cache directory may be mounted
|
||||||
wg.Add(1)
|
// to a separate filesystem. In this case the fs.MustRemoveDirAtomic() will fail while
|
||||||
fs.MustRemoveAllWithDoneCallback(s.cachePath, wg.Done)
|
// trying to remove the mount root.
|
||||||
wg.Wait()
|
fs.RemoveDirContents(s.cachePath)
|
||||||
putWaitGroup(wg)
|
|
||||||
logger.Infof("cache directory at %q has been successfully removed", s.cachePath)
|
logger.Infof("cache directory at %q has been successfully removed", s.cachePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue