Skip to content

Commit

Permalink
fix dealing with remote repo Locking Exceptions
Browse files Browse the repository at this point in the history
previously, this was handled in RPCError handler and always resulted in rc 2.

now re-raise Lock Exceptions locally, so it gives rc 2 (legacy) or 7x (modern).
  • Loading branch information
ThomasWaldmann committed Nov 13, 2023
1 parent b7d80d5 commit 96ce241
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/borg/archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5314,7 +5314,7 @@ def main(): # pragma: no cover
tb = f"{traceback.format_exc()}\n{sysinfo()}"
exit_code = e.exit_code
except RemoteRepository.RPCError as e:
important = e.exception_class not in ('LockTimeout', ) and e.traceback
important = e.traceback
msgid = e.exception_class
tb_log_level = logging.ERROR if important else logging.DEBUG
if important:
Expand Down
21 changes: 21 additions & 0 deletions src/borg/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .helpers import format_file_size
from .helpers import safe_unlink
from .helpers import prepare_subprocess_env, ignore_sigint
from .locking import LockTimeout, NotLocked, NotMyLock, LockFailed
from .logger import create_logger, setup_logging
from .helpers import msgpack
from .repository import Repository
Expand Down Expand Up @@ -779,6 +780,26 @@ def handle_error(unpacked):
raise InvalidRPCMethod('(not available)')
else:
raise InvalidRPCMethod(args[0].decode())
elif error == 'LockTimeout':
if old_server:
raise LockTimeout('(not available)')
else:
raise LockTimeout(args[0].decode())
elif error == 'LockFailed':
if old_server:
raise LockFailed('(not available)', '')
else:
raise LockFailed(args[0].decode(), args[1].decode())
elif error == 'NotLocked':
if old_server:
raise NotLocked('(not available)')
else:
raise NotLocked(args[0].decode())
elif error == 'NotMyLock':
if old_server:
raise NotMyLock('(not available)')
else:
raise NotMyLock(args[0].decode())
else:
raise self.RPCError(unpacked)

Expand Down

0 comments on commit 96ce241

Please sign in to comment.