python3.2: crash if segment file is too small (e.g. 0 size)
I started a Backup with 0.30 during this Backup because of some configuration error on my part the target server of my backup went into standby.
After waking him up and trying again i got an error that theres a lock:
Remote: Borg 0.30.0: exception in RPC call:
Remote: Traceback (most recent call last):
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/locking.py", line 134, in acquire
Remote: os.mkdir(self.path)
Remote: OSError: [Errno 17] File exists: '[...]/borg/lock.exclusive'
Remote:
Remote: During handling of the above exception, another exception occurred:
Remote:
Remote: Traceback (most recent call last):
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/remote.py", line 95, in serve
Remote: res = f(*args)
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/remote.py", line 120, in open
Remote: self.repository = Repository(path, create, lock_wait=lock_wait, lock=lock)
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/repository.py", line 63, in __init__
Remote: self.open(self.path, exclusive, lock_wait=lock_wait, lock=lock)
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/repository.py", line 141, in open
Remote: self.lock = UpgradableLock(os.path.join(path, 'lock'), exclusive, timeout=lock_wait).acquire()
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/locking.py", line 267, in acquire
Remote: with self._lock:
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/locking.py", line 118, in __enter__
Remote: return self.acquire()
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/locking.py", line 140, in acquire
Remote: raise LockTimeout(self.path)
Remote: borg.locking.LockTimeout: [...]/borg/lock.exclusive
Remote: Platform: Linux hostname 3.16.0-0.bpo.4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u6~bpo70+1 (2015-11-11) x86_64
Remote: Linux: debian 7.9 LibC: glibc 2.9
Remote: Borg: 0.30.0 Python: CPython 3.2.3
Remote:
Remote Exception (see remote log for the traceback)
Platform: Linux hostname 3.13.0-68-generic #111-Ubuntu SMP Fri Nov 6 18:17:06 UTC 2015 x86_64 x86_64
Linux: Ubuntu 14.04 trusty LibC: glibc 2.9
Borg: 0.30.0 Python: CPython 3.4.3
So i did a borg break-lock which did not return an error.
Any kind of operation on the repository now returns the following error:
borg check hostname:/[...]/borg
Remote: Borg 0.30.0: exception in RPC call:
Remote: Traceback (most recent call last):
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/repository.py", line 335, in check
Remote: transaction_id = self.get_transaction_id()
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/repository.py", line 120, in get_transaction_id
Remote: segments_transaction_id = self.io.get_segments_transaction_id()
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/repository.py", line 512, in get_segments_transaction_id
Remote: if self.is_committed_segment(filename):
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/repository.py", line 531, in is_committed_segment
Remote: fd.seek(-self.header_fmt.size, os.SEEK_END)
Remote: IOError: [Errno 22] Invalid argument
Remote:
Remote: During handling of the above exception, another exception occurred:
Remote:
Remote: Traceback (most recent call last):
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/remote.py", line 95, in serve
Remote: res = f(*args)
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/repository.py", line 338, in check
Remote: transaction_id = self.io.get_segments_transaction_id()
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/repository.py", line 512, in get_segments_transaction_id
Remote: if self.is_committed_segment(filename):
Remote: File "/usr/local/lib/python3.2/dist-packages/borg/repository.py", line 531, in is_committed_segment
Remote: fd.seek(-self.header_fmt.size, os.SEEK_END)
Remote: IOError: [Errno 22] Invalid argument
Remote: Platform: Linux ironbackup 3.16.0-0.bpo.4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u6~bpo70+1 (2015-11-11) x86_64
Remote: Linux: debian 7.9 LibC: glibc 2.9
Remote: Borg: 0.30.0 Python: CPython 3.2.3
Remote:
Remote Exception (see remote log for the traceback)
Platform: Linux hostname 3.13.0-68-generic #111-Ubuntu SMP Fri Nov 6 18:17:06 UTC 2015 x86_64 x86_64
Linux: Ubuntu 14.04 trusty LibC: glibc 2.9
Borg: 0.30.0 Python: CPython 3.4.3
Is there a way to fix this ?
After reading some other bug reports i noticed a still running instance of borg-serve and killed it and did a break-lock again. But this did not solve it.
The orphaned lock is more or less expected currently in such circumstances (there are some other tickets that deal with that) - you have to use borg break-lock carefully to deal with this (as you did).
But the other issue you found is new. It is caused by a segment file of too small size (maybe 0 size).
The code is in principle capable of handling this error condition, but only for python 3.3+ (which raises an OSError for that case). Python 3.2 raises an IOError and that is unfortunately not catched in the code.
https://github.com/borgbackup/borg/commit/7e5d30f41aab067b00f0d3ee86087fa3e24bc16b this should fix the python 3.2 issue of the exception handler.
please apply this patch and then try borg check --repair ... again.
i applied the patch (only on the remote server) and the check is currently running
OK, so it has fixed this issue (as expected). In case you find more issues, please open new tickets.