瀏覽代碼

Merge pull request #5829 from ThomasWaldmann/kill-stale-lock-race-1.1

handle crash due to kill stale lock race, fixes #5828
TW 4 年之前
父節點
當前提交
7b1d1d0c77
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/borg/locking.py

+ 7 - 1
src/borg/locking.py

@@ -156,7 +156,13 @@ class ExclusiveLock:
         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)