From 350c54f92c198ab3b26075c6aebb8e1c3b7efa58 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 9 Jun 2021 14:07:56 +0200 Subject: [PATCH] handle crash due to kill stale lock race, fixes #5828 --- src/borg/locking.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/borg/locking.py b/src/borg/locking.py index e1b0c7fe09..c58f089d7c 100644 --- a/src/borg/locking.py +++ b/src/borg/locking.py @@ -156,7 +156,13 @@ 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. + return False + + for name in names: try: host_pid, thread_str = name.rsplit('-', 1) host, pid_str = host_pid.rsplit('.', 1)