Skip to content

feat(core): retry a failed connection's own range instead of the whole batch - #596

Merged
linroid merged 3 commits into
mainfrom
feat/per-range-retry
Oct 18, 2026
Merged

linroid merged 3 commits into
mainfrom
feat/per-range-retry

Conversation

@linroid

@linroid linroid commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

A connection that fails with a retryable KetchError (other than a 429) no longer cancels the whole segmented batch:

  • It releases its lane (SegmentLedger.release) and waits RetryPolicy.delayMs while the other connections keep running.
  • The next connection to finish takes the released bytes whole, whatever their size.
  • Once it has waited, the failed connection rejoins: it takes its own lane back if nobody took it, otherwise it splits another lane's tail like a finished connection, or it ends. It stops waiting early once another connection ended for lack of work.
  • Its retries count from zero again after a transfer that wrote bytes.

The batch still fails, and DownloadExecution retries the run from saved segments, when:

  • the connection runs out of retryCount;
  • the error is not retryable;
  • it is a 429, so HttpDownloadSource lowers the connections;
  • no other connection is transferring (an outage, not one connection).

This applies to HTTP, FTP, WebDAV and Metalink mirrors, which all go through SegmentedDownloadHelper, and only with range support. It covers the first part of roadmap item 3 (Lane scheduler).

Tests

  • New SegmentedDownloadHelperTest cases cover: a failed range retried alone while the others keep running, a finished connection taking a failed one's bytes, retries running out, retries counted again after progress, 429, non-retryable errors, every connection failing, and no range support (the batch fails).
  • ./gradlew :library:core:jvmTest :library:ftp:jvmTest :library:webdav:jvmTest :library:metalink:jvmTest passes.

…e batch

A connection that fails with a retryable KetchError other than a 429 releases its lane
(SegmentLedger.release) and waits RetryPolicy's delay while the other connections keep running.
The next connection to finish takes the released bytes whole; the failed one then rejoins its own
lane, or splits another's when it was taken, and stops waiting early once a connection ended for
lack of work. Its retries count from zero after a transfer that wrote bytes. The batch still fails,
for DownloadExecution to retry the run, when a connection runs out of retries, the error is not
retryable, it is a 429 (so HttpDownloadSource lowers the connections), or no other connection is
transferring.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T08:14:11.344204Z 1147d69 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 18, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1147d69ad9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…' ranges

A connection that received nothing in its last measured lane already takes over no tail and
closes. It now leaves a released range alone too, so the bytes wait for their own connection to
retry instead of going whole to a stalled one.
…s lane

A connection could take the released bytes, finish them and end before the failed one read the
count, which then waited out its whole retry delay with nothing left to do. The wait now starts
from the count before the release, and ends early only once the lane was taken, so a connection
ending while the lane is still free never skips the backoff.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 2 191 files  ± 0   2 219 suites  ±0   57m 29s ⏱️ -31s
15 218 tests +36  14 950 ✅ +36  268 💤 ±0  0 ❌ ±0 
18 567 runs  +36  18 299 ✅ +36  268 💤 ±0  0 ❌ ±0 

Results for commit cf3bc9a. ± Comparison against base commit 4e6c7ae.

@linroid
linroid merged commit 9c9bcd7 into main Oct 18, 2026
14 checks passed
@linroid
linroid deleted the feat/per-range-retry branch October 18, 2026 08:39
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