Repository navigation
fix(client): start the size open's lane before any other lane builds - #2742
Merged
Merged
Conversation
…2740) A fetch with no size hint opens the whole blob on one holder for its signed size, primes that pull on the lane, and parks the lane. The download's first leg adopts the pull only when the leg is the whole blob. The parked lane reached the acquire loop through `connect`, as a build future beside the other holders' fresh builds, and the loop plans the work across every build that has finished when it looks. When another holder's lane built just as fast, the first batch held two lanes, the blob was split between them, and the parked lane's first leg was half the blob. `PrimedSource` then closed the primed pull after the node had written the blob into it, and the two legs pulled it again. This is the `peer_store_probeless` double write (397476 bytes for a 198610-byte pull): in a 10-run loop, the one failure was the one run whose first batch held two lanes. `SourceProvider::built` (default `None`) hands over a lane the provider built before the set. The acquire loop starts such a lane in the pass that starts its provider, before it polls any build, so the first batch holds it alone and the plan gives it the whole blob. `LaneSources` returns its parked lane there. ADR 039 states the rule. #2724 did not introduce the race; it unmasked it. The batching and the `connect` path are unchanged by it, and a discovery future is polled after the builds. Before #2724, a slow fetch also let the first-pass discovery probe the holders mid-transfer, so a slow run failed at the probe assertion first. Closes #2740 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 5 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the scheduling change that prioritizes the primed lane to avoid duplicate downloads.
No open issues 🎉
What changed in this PR
Fixes #2740 by starting the client lane that supplied the blob’s size before polling other lane builds. This lets its first download leg reuse the primed whole-blob pull instead of splitting the work and downloading bytes twice.
Changes:
- Adds a prebuilt-lane handoff from source providers to the scheduler.
- Adds a regression test covering a primed lane beside an immediately completing build.
- Updates the ADR, changelog, and end-to-end test comments to describe the scheduling rule.
| File | Description |
|---|---|
crates/e2e/tests/peer_store_probeless.rs |
Clarifies the lane-start ordering in test comments. |
crates/client/src/source_set.rs |
Adds provider and source-set support for taking prebuilt lanes. |
crates/client/src/scheduler/tests.rs |
Tests primed-pull reuse when another lane builds immediately. |
crates/client/src/scheduler.rs |
Starts prebuilt lanes before polling pending builds. |
crates/client/src/lane_sources.rs |
Exposes the parked size-open lane through the prebuilt handoff. |
CHANGELOG.md |
Records the duplicate-download fix. |
adr/039-multi-source-parallel-fetch.md |
Documents first-leg planning for the retained lane. |
Review effort: Balanced
5 of 6 tasks
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
peer_store_probelessfailed about 1 run in 5 to 10 at the served-bytes check of journey 1's fetch #2. The holders wrote 397476 bytes for a 198610-byte pull, so they served the blob twice.Cause. A fetch with no size hint opens the whole blob for its signed size, primes the pull on the answering lane, and parks the lane for the download's first leg to adopt. The parked lane reached the acquire loop through
connect, as a build future beside the other holders' fresh builds. The loop plans the work across every build that has finished when it looks (now_or_neverbatching). When another holder's lane built just as fast, the first batch held two lanes and the plan split the blob. The parked lane's first leg was then half the blob, soPrimedSourceclosed the primed pull after the node had written the blob into it, and the two legs pulled the blob again.Client debug log of the failing fetch #2:
Every passing run logs
lanes=1 pending=0+197842and opens no leg.Fix.
SourceProvider::built(defaultNone) hands over a lane the provider built before the set. The acquire loop starts such a lane in the pass that starts its provider, before it polls any build (SourceSet::take_built). The first batch then holds that lane alone, and the plan gives it the whole blob.LaneSourcesreturns its parked lane there. ADR 039 states the rule.#2724 unmasked the race; it did not introduce it. #2724 changed only the discovery trigger. The batching and the
connectpath are unchanged, and the biasedselect!polls a discovery future after the builds. Before #2724, a slow fetch also let the first-pass discovery probe the holders mid-transfer, so a slow run failed earlier, at the probe assertion. The one failing run here was also the slow run (total_ms=984against 125 to 176 ms).Test plan
scheduler::tests::a_size_opens_lane_adopts_its_primed_pull_beside_a_lane_that_builds_at_once: a kept lane with a primed whole-blob pull beside a lane whose build resolves at once. Mutation check: with the scheduler'stake_builtbranch removed, it fails with[(0, 2097152), (0, 1048576)], the same half-blob re-open as the e2e. Restored from a copy and touched.peer_store_probeless: 10 runs before the fix, 1 failed. 20 runs with the fix, 20 passed (1 test each, run under concurrent clippy and test load).cargo nextest run -p decdn-client --no-fail-fast: 1201 passed.cli_fetch_multi_source,cli_fetch_stdout,cli_fetch_resume,cli_fetch_recovers_one_holder,gateway_concurrent_pulls,gateway_pointer,gateway_public,origin_stream_while_store,warm_upstream_connectionandpeer_store_probelesspass.cli_bundle_pull_multi_sourceflakes with and without this change (2 of 6 runs with the fix disabled), filed as e2e: cli_bundle_pull_multi_source flakes: no single pull splits the large entry across both holders #2741.cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo fmt -- --check,CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items, and thedecdn-clientpublic API snapshot.Closes #2740
🤖 Generated with Claude Code