Skip to content

--bypass-lock: also skip the cache lock - #10158

Open
ThomasWaldmann wants to merge 1 commit into
borgbackup:1.4-maintfrom
ThomasWaldmann:bypass-lock-7255
Open

--bypass-lock: also skip the cache lock#10158
ThomasWaldmann wants to merge 1 commit into
borgbackup:1.4-maintfrom
ThomasWaldmann:bypass-lock-7255

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

Fixes #7255.

--bypass-lock only skipped the repository lock, but the security checks run for every command still acquired the exclusive client-side cache lock via CacheConfig, although they only read the cache config. Thus, e.g. borg list --bypass-lock was blocked while a borg create using the same $HOME was running.

Now the bypass flag is passed down to assert_secure / CacheConfig, which then reads the cache config without locking. This is safe because the cache config is only ever written via SaveFile (atomic rename), so an unlocked reader always sees a complete file. When no lock is held, the relocated-repository handling only updates the security dir and does not write to the cache config.

Commands that really open the cache (e.g. borg info, borg config --cache) still acquire the cache lock, as they might write to the cache.

Not an issue on master: borg2 removed --bypass-lock and its cache has no lock.

🤖 Generated with Claude Code

The security checks done for commands without cache access only read
the cache config, so they do not need the exclusive cache lock.

Previously, e.g. "borg list --bypass-lock" was blocked by a
concurrently running "borg create" using the same $HOME, because
the security checks always acquired the cache lock.

Commands that really open the cache (e.g. "borg info",
"borg config --cache") still acquire the cache lock, as they might
write to the cache.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.13%. Comparing base (38b6dce) to head (d8e9d67).
⚠️ Report is 3 commits behind head on 1.4-maint.

Files with missing lines Patch % Lines
src/borg/cache.py 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           1.4-maint   #10158      +/-   ##
=============================================
+ Coverage      82.11%   82.13%   +0.02%     
=============================================
  Files             38       38              
  Lines          11435    11437       +2     
  Branches        1802     1803       +1     
=============================================
+ Hits            9390     9394       +4     
+ Misses          1461     1459       -2     
  Partials         584      584              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant