From 28d9904efc8842844c6811d34272bb026eae313d Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 12 Jun 2019 01:17:39 +0300 Subject: [PATCH] lib/fs: panic with fatal error when directories cannot be removed Unremoved directories may lead to inconsistent data directory, so VictoriaMetrics will fail to start next time. So panic on the first error when trying to remove directory in order to simplify recover process. --- lib/fs/fs.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/fs/fs.go b/lib/fs/fs.go index 46c6a0fb1..2018b3147 100644 --- a/lib/fs/fs.go +++ b/lib/fs/fs.go @@ -246,16 +246,14 @@ func dirRemover() { break } if !isTemporaryNFSError(err) { - logger.Errorf("cannot remove %q: %s", path, err) - break + logger.Panicf("FATAL: cannot remove %q: %s", path, err) } // NFS prevents from removing directories with open files. // Sleep for a while and try again in the hope open files will be closed. // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/61 . attempts++ if attempts > 10 { - logger.Errorf("cannot remove %q in %d attempts: %s", path, attempts, err) - break + logger.Panicf("FATAL: cannot remove %q in %d attempts: %s", path, attempts, err) } time.Sleep(100 * time.Millisecond) }