From d7edf8ddff92e9e2693e2b6e92de188093dc555b Mon Sep 17 00:00:00 2001 From: Christoph Klaffl Date: Sat, 28 Dec 2019 02:15:28 +0100 Subject: [PATCH] remove invalid locks caused by race conditions or else the block the critical function of snapshot taking until manual intervention --- sanoid | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sanoid b/sanoid index 2b566ef..def7feb 100755 --- a/sanoid +++ b/sanoid @@ -1389,7 +1389,9 @@ sub checklock { # make sure lockfile contains something if ( -z $lockfile) { # zero size lockfile, something is wrong - die "ERROR: something is wrong! $lockfile is empty\n"; + warn "WARN: deleting invalid/empty $lockfile\n"; + unlink $lockfile; + return 1 } # lockfile exists. read pid and mutex from it. see if it's our pid. if not, see if @@ -1400,7 +1402,9 @@ sub checklock { close FH; # if we didn't get exactly 2 items from the lock file there is a problem if (scalar(@lock) != 2) { - die "ERROR: $lockfile is invalid.\n" + warn "WARN: deleting invalid $lockfile\n" + unlink $lockfile; + return 1 } my $lockmutex = pop(@lock);