Skip to content

fix(client): skip rediscovery while a full-coverage set's lanes are still building - #2724

Merged
thiras merged 1 commit into
mainfrom
fix/2677-no-rediscovery-while-lanes-build
Oct 28, 2026
Merged

thiras merged 1 commit into
mainfrom
fix/2677-no-rediscovery-while-lanes-build

Conversation

@thiras

@thiras thiras commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

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:

  1. Work::new starts with every missing range pending and no lanes.
  2. Every lane is still connecting or building.
  3. uncovered is therefore true.
  4. The fast path leaves no pending probes, so arrivals is None.
  5. wants_discovery(now, deposit, 0, true) returns true.
  6. LaneSources::discover runs with rediscover = 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 logged uncovered=true seeded=false running=0 connecting=3. The fetch timings in that run had no probe_start_ms, so the probe came during the transfer, not before it.

This contradicts:

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:

  • a range no running or building lane covers (real partial coverage);
  • no source is running and none can start;
  • the unanimous or exhausted set (ADR 039 § Failure handling).

Work::uncovered, which decides lane starts and pull-through, is unchanged.

Reviewer notes

  • crates/client/src/scheduler.rs: the change is the new Work::uncovered_beside and the discovery trigger in acquire.
  • New tests in 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 of uncovered_beside.
  • a_sibling_top_up_on_a_shared_lane_revives_a_priced_out_source had 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 through run_fetch_logged, the same helper journey 3 uses. It asserts the fetch timings event has no probe_start_ms, and it still asserts probes == 0. Both failure messages include the fetch's stderr. run_fetch_once had no other caller, so it is removed.
  • No public API change.

Verification

  • Mutation checks, each restored from a copy and touched afterwards:
    • Passing no building coverage: full_holders_still_building_ask_for_no_discovery fails (1 discovery against 0).
    • Treating every building lane as a whole-blob holder: a_range_no_building_lane_covers_asks_for_discovery fails (first discovery at 200 ms).
  • peer_store_probeless, after cargo build -p decdn-cli -p decdn-node, looped with cargo nextest run -p decdn-e2e --features anvil-e2e --retries 0 -E 'binary(peer_store_probeless)':
    • Before the fix: 1 of 8 runs failed with fetch #2 probed the holders 1 time(s), and 1 of 2 more runs failed with the diagnostic line.
    • After the fix: 15 of 15 runs passed.
  • cargo nextest run -p decdn-client --no-fail-fast: 1196 of 1196 passed.
  • Discovery-heavy e2e binaries (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, and CARGO_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

@thiras thiras self-assigned this Oct 28, 2026
Copilot AI balanced review requested due to automatic review settings October 28, 2026 19:57

Copilot AI 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.

🟢 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

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main f2bc01c fix/2677-no-rediscov... 8a17b1d +/-
77% 77% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

…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
thiras force-pushed the fix/2677-no-rediscovery-while-lanes-build branch from 8a17b1d to 8b64fb6 Compare October 28, 2026 22:02
@thiras
thiras merged commit 73a2c5c into main Oct 28, 2026
36 checks passed
@thiras
thiras deleted the fix/2677-no-rediscovery-while-lanes-build branch October 28, 2026 22:02
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]>
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.

e2e: peer_store_probeless fetch #2 intermittently counts holder probes

2 participants