Repository navigation
fix(client): skip rediscovery while a full-coverage set's lanes are still building - #2724
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain to block approval of the peer-store discovery change.
No open issues 🎉
What changed in this PR
Fixes unnecessary mid-transfer discovery on peer-store fast-path fetches, addressing #2677. The client now counts connecting and building lanes’ coverage when deciding whether to rediscover sources, while preserving discovery for genuinely uncovered ranges.
Changes:
- Adds building-lane coverage to the scheduler’s discovery check without changing lane-start or pull-through decisions.
- Adds regression tests and adjusts the shared-pool top-up test double.
- Improves probe-free end-to-end test diagnostics and documents the fix.
| File | Description |
|---|---|
crates/e2e/tests/peer_store_probeless.rs |
Captures fetch logs, checks pre-transfer probe timing, and retains the zero-probe assertion. |
crates/client/src/scheduler/tests.rs |
Tests full and partial building-lane coverage and updates the top-up test double. |
crates/client/src/scheduler.rs |
Includes connecting and building lanes’ coverage in discovery decisions. |
CHANGELOG.md |
Records the fast-path rediscovery fix. |
Review effort: Balanced
…till building The acquire loop asks for a discovery when a pending range has no holder to serve it (`Work::uncovered`). It judged that against running lanes only. On the first pass of a peer-store fast-path fetch every lane is still connecting or building and no probe round is pending, so every range read as uncovered. The loop then ran `LaneSources::discover`, a registry read plus a full probe round, mid-transfer. A small blob could finish before those probes landed, which made the probe-count assertion in `peer_store_probeless` racy. The discovery trigger now counts the coverage of the lanes still connecting or building (`Work::uncovered_beside`). Discovery still runs for a range no running or building lane covers, and when no source can start. The `peer_store_probeless` fast-path fetch now captures its stderr and asserts that its `fetch timings` event names no probe round. The sibling top-up test's double tops up only after its lane is built, because the first discovery no longer runs on the first pass. Closes #2677 Co-Authored-By: Claude Opus 5.5 <[email protected]>
thiras
force-pushed
the
fix/2677-no-rediscovery-while-lanes-build
branch
from
October 28, 2026 22:02
8a17b1d to
8b64fb6
Compare
This was referenced Oct 28, 2026
thiras
added a commit
that referenced
this pull request
Oct 28, 2026
…2742) fix(client): start the size open's lane before any other lane builds (#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]>
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
A fast-path fetch no longer starts a probe round while its first lanes are still building.
Closes #2677
Root cause. The acquire loop asks for a discovery when a pending range has no holder to serve it. It made that check (
Work::uncovered) against running lanes only. On the first pass of a peer-store fast-path fetch:Work::newstarts with every missing range pending and no lanes.uncoveredis therefore true.arrivalsisNone.wants_discovery(now, deposit, 0, true)returns true.LaneSources::discoverruns withrediscover = true. It skips the peer store, reads the registry and probes every holder, all mid-transfer.A small blob can finish before those probes land, which is the race in
peer_store_probeless. A temporary debug line at the discovery start confirmed this. A failing run loggeduncovered=true seeded=false running=0 connecting=3. The fetch timings in that run had noprobe_start_ms, so the probe came during the transfer, not before it.This contradicts:
SourceSet::wants_discovery: discovery runs when "a missing range has no usable holder".Fix. The discovery trigger now also counts the holder coverage of every lane still connecting or building (
Work::uncovered_beside). A range one of those lanes covers already has its holder. Discovery still runs in these cases:Work::uncovered, which decides lane starts and pull-through, is unchanged.Reviewer notes
crates/client/src/scheduler.rs: the change is the newWork::uncovered_besideand the discovery trigger inacquire.crates/client/src/scheduler/tests.rs:full_holders_still_building_ask_for_no_discovery: three whole-blob holders whose builds take 200 ms run no discovery.a_range_no_building_lane_covers_asks_for_discovery: a holder of block 0 only still gets a discovery while its lane builds, before 200 ms.a_building_lane_covers_its_blocks_for_discovery: a unit test ofuncovered_beside.a_sibling_top_up_on_a_shared_lane_revives_a_priced_out_sourcehad a test double that assumed a discovery on the first pass. It skipped the top-up on the first call, and that first-pass discovery is the bug. The double now tops up on any call after its lane is built, and the test also asserts that a top-up happened. Removing the top-up still fails the test with "funding needed".crates/e2e/tests/peer_store_probeless.rs: fetch docs: Generalize architecture to content-agnostic CDN, refocus slashing on bad edges #2 now runs throughrun_fetch_logged, the same helper journey 3 uses. It asserts thefetch timingsevent has noprobe_start_ms, and it still assertsprobes == 0. Both failure messages include the fetch's stderr.run_fetch_oncehad no other caller, so it is removed.Verification
touched afterwards:full_holders_still_building_ask_for_no_discoveryfails (1 discovery against 0).a_range_no_building_lane_covers_asks_for_discoveryfails (first discovery at 200 ms).peer_store_probeless, aftercargo build -p decdn-cli -p decdn-node, looped withcargo nextest run -p decdn-e2e --features anvil-e2e --retries 0 -E 'binary(peer_store_probeless)':fetch #2 probed the holders 1 time(s), and 1 of 2 more runs failed with the diagnostic line.cargo nextest run -p decdn-client --no-fail-fast: 1196 of 1196 passed.cli_bundle_pull_multi_source,cli_fetch_multi_source,cli_fetch_recovers_one_holder,payment_pool_probe_selector,peer_store_probeless): 6 of 6 passed.cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo fmt -- --check, andCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items: all clean. The pre-commit hooks passed too.CHANGELOG.md: a Fixed entry is added.🤖 Generated with Claude Code