create: do not wrap repository writes in backup_io("read") - #9854
Merged
ThomasWaldmann merged 1 commit intoJul 3, 2026
Merged
Conversation
process_file() ran process_file_chunks() inside `with backup_io('read')`.
That block is meant to guard reading the *source* file, but the source reads
are already guarded individually by backup_io_iter(). The outer wrapper also
caught add_chunk()'s (and maybe_checkpoint()'s) *repository* writes, so a
repository IO failure -- e.g. the repo running out of space -- was wrapped
into a per-file BackupOSError tagged "read". Borg then emitted misleading
"<path>: read: [Errno 28] No space left on device" warnings, pointlessly
retried the file, and only treated a critical repository error as a
non-critical per-file one, contrary to the BackupOSError docstring ("Any
unwrapped IO error is critical and aborts execution (for example repository
IO failure)").
In 1.4 the transactional repository still rolls the partial transaction back
on the eventual failure, so this is not data loss here (unlike borg2, where
it silently commits a corrupt archive). But the misclassification -- wrong
warning text and needless read-retries of a repository-full condition -- is
wrong regardless.
Drop the outer backup_io('read') wrapper. Source reads stay per-file
warnings (backup_io_iter is unchanged); repository OSErrors are now left
unwrapped and critical, aborting promptly with the correct error.
Verified on a space-limited macOS ramdisk: before, create emitted many
"read: [Errno 28]" retry warnings then rolled back; after, it aborts
immediately ("No space left on device, cleaning up partial transaction"),
commits no archive, and the repo stays consistent. Normal backups and
unreadable-source-file handling (per-file warning) are unchanged.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.4-maint #9854 +/- ##
=============================================
+ Coverage 82.04% 82.06% +0.02%
=============================================
Files 38 38
Lines 11384 11383 -1
Branches 1794 1794
=============================================
+ Hits 9340 9342 +2
+ Misses 1460 1459 -1
+ Partials 584 582 -2 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
process_file()ranprocess_file_chunks()insidewith backup_io('read'). That block is meant to guard reading the source file, but the source reads are already guarded individually bybackup_io_iter(). The outer wrapper additionally caughtadd_chunk()'s (andmaybe_checkpoint()'s) repository writes, so a repository IO failure — e.g. the repo running out of space — was wrapped into a per-fileBackupOSErrortagged"read".Symptom
On an out-of-space repository,
borg createemitted misleading per-file warnings:i.e. a repository-full condition was reported as if the source file couldn't be read, and the file was pointlessly retried. This contradicts the
BackupOSErrordocstring:Note: in 1.4 this is not data loss — the transactional segment repository still rolls the partial transaction back on the eventual failure ("No space left on device, cleaning up partial transaction to free space"), so no corrupt archive is committed. This PR is a correctness/UX fix: the misclassified warning text and needless read-retries of a repository error are wrong regardless. (In borg2/master the same wrapping caused silent data loss because borgstore has no equivalent rollback; fixed separately in #9853.)
Fix
Drop the outer
backup_io('read')wrapper aroundprocess_file_chunks(). Source reads stay per-file warnings (backup_io_iteris unchanged); repositoryOSErrors are now left unwrapped and therefore critical, aborting promptly with the correct error.Audited all 23
with backup_ioblocks inarchive.py/archiver.py(including indirect repo access viafetch_many,preload,add_item,write_part,maybe_checkpoint): this regular-file backup path was the only one wrapping a repository operation. The stdin/pipe and import-tarprocess_file_chunkscall sites were already unwrapped, and the extract path deliberately keeps the repo read (fetch_many) outsidebackup_io('write').Testing
testsuite/archive.py(38) and create-relatedtestsuite/archiver.pytests (52) pass.read: [Errno 28]retry warnings, then rolled back.checkok). Normal backups and unreadable-source-file handling (per-file warning, archive still created) are unchanged.🤖 Generated with Claude Code