borgbackup / borg

Deduplicating archiver with compression and authenticated encryption.
https://www.borgbackup.org/
Other
11.22k stars 743 forks source link

borg2: check if borg does not close the repo in case of exceptions #8413

Closed ThomasWaldmann closed 1 month ago

ThomasWaldmann commented 1 month ago

https://github.com/borgbackup/borgstore/issues/54#issuecomment-2373742876

Update: the related PR fixed the hanging issue and will be released in borgstore 0.0.5.

ThomasWaldmann commented 1 month ago

Repository has a context manager that calls .close(), so that should close the repo (if the context manager was used).

ThomasWaldmann commented 1 month ago

Looks good if it can acquire the lock:

(borg-env) tw@MacBook-Pro borg % borg with-lock python -c 'import time; time.sleep(100)'
>>> store opened
>>> repository locked
>>> repository opened
^CTraceback (most recent call last):
  File "<string>", line 1, in <module>
KeyboardInterrupt
>>> repository unlocked
>>> store closed
>>> repository closed

But there is a bug if the lock can't be acquired:

(borg-env) tw@MacBook-Pro borg % borg repo-list
>>> store opened
Failed to create/acquire the lock <Store(url='file:///tmp/borg2test123', levels=[('archives/', [0]), ('config/', [0]), ('cache/', [0]), ('locks/', [0]), ('data/', [2]), ('keys/', [0])])> (timeout).

Note: no store closed in this case.