Skip to content

create file retries: do not sleep before giving up on the last try#9874

Merged
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:retry-no-sleep-on-last-try
Jul 7, 2026
Merged

create file retries: do not sleep before giving up on the last try#9874
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:retry-no-sleep-on-last-try

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

In _process_any's retry handler (from #7351), the sleep happens before checking whether this was the last try. When all retries are used up, the error is re-raised anyway, so that final sleep is pointless — and it is the longest one of the backoff sequence: retry 9 sleeps 10^4.5 ms ≈ 31.6 s. On a source with many permanently failing files (e.g. a disk returning I/O errors), that adds ~31.6 s per failing file on top of the earlier backoff sleeps.

Check last_try first and re-raise immediately; only sleep (and log the retry warning) when another attempt will actually follow. The if retry < MAX_RETRIES - 1 / else split around the warning becomes unnecessary, since the handler now only reaches that point when a retry follows.

No behavior change for retried files: same backoff sleeps, same warning messages.

🤖 Generated with Claude Code

When all retries for a file were used up, the error is re-raised anyway,
so sleeping before that is pointless - on the last try, the sleep was up
to ~31.6s (retry 9) per permanently failing file, e.g. on a disk that
gives I/O errors for many files.

Check last_try first and re-raise immediately; only sleep (and log the
retry warning) when another attempt will actually follow.

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

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.14%. Comparing base (88f470e) to head (9bd2690).
⚠️ Report is 4 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/archiver/create_cmd.py 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9874      +/-   ##
==========================================
+ Coverage   85.12%   85.14%   +0.01%     
==========================================
  Files          93       93              
  Lines       15459    15479      +20     
  Branches     2337     2343       +6     
==========================================
+ Hits        13159    13179      +20     
  Misses       1599     1599              
  Partials      701      701              

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

@ThomasWaldmann ThomasWaldmann merged commit a968a3d into borgbackup:master Jul 7, 2026
18 of 19 checks passed
@ThomasWaldmann ThomasWaldmann deleted the retry-no-sleep-on-last-try branch July 7, 2026 09:28
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