Skip to content

Commit

Permalink
handle crash due to kill stale lock race, fixes borgbackup#5828
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWaldmann committed Jun 9, 2021
1 parent af00ed4 commit d4a56a7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/borg/locking.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,15 @@ def by_me(self):
return os.path.exists(self.unique_name)

def kill_stale_lock(self):
for name in os.listdir(self.path):
try:
names = os.listdir(self.path)
except FileNotFoundError:
# if another borg process won the race for killing a stale lock, we get here.
# we return True, because there is currently no exclusive lock directory.
# of course there might be another race now for creating that directory...
return True

for name in names:
try:
host_pid, thread_str = name.rsplit('-', 1)
host, pid_str = host_pid.rsplit('.', 1)
Expand Down

0 comments on commit d4a56a7

Please sign in to comment.