remove invalid locks caused by race conditions or else the block the critical function of snapshot taking until manual intervention

This commit is contained in:
Christoph Klaffl 2019-12-28 02:15:28 +01:00
parent 45d0898523
commit d7edf8ddff
No known key found for this signature in database
GPG Key ID: 8FC1D76EED4970D2
1 changed files with 6 additions and 2 deletions

8
sanoid
View File

@ -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);