From 845d2144cb6a4e4f870f3e5af993d299e90ceffd Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 22 Dec 2015 12:11:36 +0100 Subject: [PATCH] fix locking, partial fix for #502 the problem was that the borg process removed its own shared lock when upgrading it to an exclusive lock. this is fine if we get the exclusive lock, but if we don't, we must re-add our shared lock. this fixes the KeyError in locking.py:217 --- borg/locking.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/borg/locking.py b/borg/locking.py index cd54ca797..af17d8bcf 100644 --- a/borg/locking.py +++ b/borg/locking.py @@ -278,9 +278,11 @@ def _wait_for_readers_finishing(self, remove, sleep): try: if remove is not None: self._roster.modify(remove, REMOVE) - remove = None if len(self._roster.get(SHARED)) == 0: return # we are the only one and we keep the lock! + # restore the roster state as before (undo the roster change): + if remove is not None: + self._roster.modify(remove, ADD) except: # avoid orphan lock when an exception happens here, e.g. Ctrl-C! self._lock.release()