Commit Graph

31 Commits

Author SHA1 Message Date
Thomas Waldmann 9de07ebd46
update "modern" error RCs (docs and code) 2024-02-13 22:58:02 +01:00
Thomas Waldmann 046f9fe392
LockRoster.modify: no KeyError if element was already gone, fixes #7937
The intention of LockRoster.modify(key, REMOVE) is to remove self.id.

Using set.discard will just ignore it if self.id is not present there anymore.

Previously, using set.remove triggered a KeyError that has been frequently
seen in tracebacks of teardowns involving Repository.__del__ and Repository.__exit__.

I added a REMOVE2 op to serve one caller that needs to get the KeyError if
self.id was not present.

Thanks to @herrmanntom for the workaround!
2023-11-18 17:39:30 +01:00
Thomas Waldmann 3017701958
simplify flake8 configuration
we use black since a while, so some stuff does not need to be ignored any more.
2023-07-25 23:56:31 +02:00
Thomas Waldmann c3d0c525f9
locking: get out of kill_stale_lock more quickly if directory does not exist. 2023-01-18 13:44:51 +01:00
Thomas Waldmann 9ba249b482
use for loop 2023-01-18 13:42:39 +01:00
Thomas Waldmann 6a3aa23f9b
locking (win32): deal with os.rmdir PermissionErrors
Retry if access is denied.
2023-01-13 22:50:41 +01:00
Thomas Waldmann 7063c2abec
locking (win32): deal with os.listdir PermissionErrors
due to unclear circumstances, windows sometimes just says "PermissionError" when trying to list a directory.
2023-01-13 22:50:13 +01:00
Thomas Waldmann e1bb669400
use os.replace not os.rename 2023-01-13 22:48:17 +01:00
Thomas Waldmann 163e92dd04
bugfix: thread id must be parsed as hex from lock file name 2023-01-13 22:48:14 +01:00
Paul D 253d8e8d4e Docs grammar fixes
joined split infinitives, and relocated adverbs appropriately.
2022-12-29 22:26:54 +00:00
Thomas Waldmann 7957af562d blacken all the code
https://black.readthedocs.io/
2022-07-06 16:34:38 +02:00
Thomas Waldmann cbeef56454 pyupgrade --py38-plus ./**/*.py 2022-02-27 20:11:56 +01:00
Andrea Gelmini 72e7c46fa7 Fix typos 2021-01-07 17:54:33 +01:00
Thomas Waldmann 220d890f32 fix locking on openindiana, fixes #5271
OI rmdir gives errno 17 EEXIST when trying to remove a non-empty dir,
not ENOTEMPTY like other OSes.

Also: fix one error handler to also use a tuple-member check instead of "or".
2020-07-26 15:25:26 +02:00
Thomas Portmann dfc5e915cc
Fixed locking, issue #4923 (#4928)
locking: fix ExclusiveLock race condition bug, fixes #4923

- ExclusiveLock is now based on os.rename instead of os.mkdir.
- catch FileNotFoundError observed under race condition in ExclusiveLock.release()
  and .kill_stale_lock()
- added TestExclusiveLock.test_race_condition() which reveals issue #4923
- updated docs
- locking: use "raise LockTimeout from None" for prettier traceback

Co-authored-by: Thomas Portmann <thomas@portmann.org>
Co-authored-by: Thomas Waldmann <tw@waldmann-edv.de>
2020-07-03 10:09:32 +02:00
Thomas Waldmann 7ad5290501 redo stale lock handling, fixes #3986
drop BORG_HOSTNAME_IS_UNIQUE (please use BORG_HOST_ID if needed)

borg now always assumes it has a unique hostid - either automatically
from fqdn plus uuid.getnode() or overridden via BORG_HOST_ID.
2019-03-04 21:07:05 +01:00
Thomas Waldmann 3417de85e0 locking: more logging
(cherry picked from commit f86bf8a0a8)
2018-07-17 19:06:45 +02:00
Thomas Waldmann 89c11f45ce cache lock: use lock_wait everywhere to fix infinite wait
also: clarify docs
(cherry picked from commit 2f3e60d9d5)
2018-07-16 23:50:04 +02:00
Thomas Waldmann 5bad764637 fixup: use asserts for the old_id check 2017-08-11 23:24:33 +02:00
Thomas Waldmann 6f94949a36 migrate locks to child PID when daemonize is used
also:

increase platform api version due to change in get_process_id behaviour.
2017-08-08 03:46:44 +02:00
Marian Beermann 676e69cac4 Parse & pass BORG_HOSTNAME_IS_UNIQUE env var to enable stale lock killing 2016-11-07 21:56:40 +01:00
Marian Beermann cc14975f2d Add tests for stale lock killing and platform.process_alive 2016-11-07 21:56:07 +01:00
Marian Beermann 7930d055ec import platform module instead of functions
(testability)
2016-11-07 21:54:16 +01:00
Marian Beermann 8e1df7a364 Use logging instead of prints 2016-11-07 21:54:16 +01:00
Marian Beermann c562f7750c Move platform-dependent code to platform package 2016-11-07 21:54:16 +01:00
Oleg Drokin d490292be3 Detect and delete stale locks when it's safe
If BORG_UNIQUE_HOSTNAME shell variable is set, stale locks
in both cache and repository are deleted.

Stale lock is defined as a lock that's originating from the same
hostname as us, and correspond to a pid that no longer exists.

This fixes #562
2016-11-07 21:54:16 +01:00
Thomas Waldmann c355f3617a Merge branch '1.0-maint' 2016-08-20 00:04:55 +02:00
Thomas Waldmann dbe862f3d8 Merge branch '1.0-maint' into merge-1.0-maint 2016-08-06 01:24:22 +02:00
Thomas Waldmann 3baa8a3728 Merge branch '1.0-maint'
# Conflicts:
#	docs/changes.rst
#	docs/usage/mount.rst.inc
#	src/borg/archive.py
#	src/borg/archiver.py
#	src/borg/fuse.py
#	src/borg/testsuite/archiver.py
2016-07-11 01:23:27 +02:00
Thomas Waldmann 49484d6d67 split helpers import into multiple ones 2016-05-31 00:33:13 +02:00
Thomas Waldmann d1ea925a5b move borg package to src/ 2016-05-05 20:19:50 +02:00
Renamed from borg/locking.py (Browse further)