fix(backup): retry EMFILE on source scan instead of skipping directories - #572
Open
BradKollmyer wants to merge 1 commit into
Open
BradKollmyer wants to merge 1 commit into
BradKollmyer wants to merge 1 commit into
Conversation
When ignore/walkdir cannot opendir a source path because the process is out of file descriptors, backup currently logs a scan error and omits that tree from the snapshot. Retry a couple of times, then abort so we do not save a snapshot that silently dropped directories. Vanished paths and other source errors are still counted and skipped, as before (rustic-rs#561).
BradKollmyer
marked this pull request as ready for review
September 20, 2026 19:45
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.
Summary
raw_os_error()is oftenNone)opendir/File::opena couple of times after asking the cache layer to drop pack FDserror: scanand omitting that directory from the snapshotrelease_cached_open_files()is a no-op on currentmain(cache files are opened per blob). Callers still go through it so a pack-handle cache (see #566) can hook in without changing the backup path again.Why
A backup of many sibling date directories (
…/2021-07-01,…/2021-07-23, …) hitNo file descriptors available (os error 24)while scanning. rustic mapped that to a source-walk error, skipped the directory, and still saved a snapshot. That looks like a successful backup of a tree with holes.restic-style incomplete backups should be detectable. Skipping a whole directory because of a transient FD limit is worse than skipping one unreadable file: the next snapshot treats those paths as deleted.
Validation
cargo test --all-features -p rustic_core --lib -- --test-threads=1 retry_on_too_many wrap_ignore rustic_error_from_io walk_lists walk_emfilecargo test --all-features -p rustic_core --test integration -- --test-threads=1 test_backup_aborts_on_emfile test_backup_saves_snapshot_after_vanished test_backup_unreadable_fileNOFILE=64returns EMFILE instead of a successful partial listingReadSourcethat yields EMFILE does not save a snapshot; ENOENT still doesNotes
This is independent of the prune pack-FD cache in #566. That stack is where a 1024-FD process can hold hundreds of pack handles during backup parent-tree reads; this PR is the backup correctness side (do not omit source trees).