Skip to content

fix(client,cli): retry lane growth until a faulted remainder finds a stream - #2273

Merged
thiras merged 3 commits into
mainfrom
fix/2230-lane-growth-retry
Oct 2, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/2230-lane-growth-retry

Conversation

@thiras

@thiras thiras commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What

A faulted lane's remainder in decdn bundle pull now starts as soon as a stream frees, instead of waiting behind a busy lane's whole range or for the dead node's next fault. This is #2230 item 3, building on #2231 (LaneWiden / growth_wanted).

Refs #2230

Root cause

Three gaps in crates/client/src/scheduler.rs:

  1. Growth was asked only once. want_growth was set only by an own-worker fault and cleared when the loop read it. A grow(1) that found no free permit was never asked again. A permit that a sibling bundle entry gives back wakes nothing in this acquire's loop.
  2. Leases were held until the acquire returned. ReleaseLeases::drop released every lane's LaneLease together. So a faulted or idle lane held its provider's stream permit from sibling entries for the whole fetch.
  3. Only covering lanes could grow. growth_wanted offered only lanes that covers the segment. Once the faulted lane parks, a remainder that only it covered has no candidate, even though any unbarred lane could serve it by pull-through.

Changes

  • 3a, retry. Every worker end and every landed build ask for a growth pass (Growth). The one exception is an extra-stream fault that its lane outlives (a refused extra), which arms that lane's backoff instead. When a pass leaves a range waiting after a grow granted nothing, the loop adds GROWTH_RETRY (1 s) to its wake and asks again then.
  • 3b, lease per lane. A lane with a LaneWiden releases its lease when its own (non-extra) worker ends, through a ReleaseLease guard in that worker's future (Hold::Own). A lane restarts from the SourceSet lane cache, not through connect, so a restart whose lease is no longer held takes its stream through widen.grow(1) and holds it as a ReleaseGrant. If no permit is free, the start waits a flat GROWTH_RETRY (SourceSet::start_retry, separate from the build backoff) and logs the first refusal at info. A lane without a LaneWiden keeps its lease until the acquire returns, as before.
  • 3c, uncovered remainder. The growth_wanted candidate predicate is now (orphan && !barred(lane)) || covers(lane, seg), the same rule idle workers use. An extra worker's pick reaches the existing uncovered branch, and barred(i) reads the lane's bar through lane_of. A NotFound or size-ceiling refusal of an uncovered range on an extra stream counts toward the pull-through bar (SourceSet::record_extra_refusal), without cooling the node.
  • Refused extra streams back off. Per lane, from GROWTH_RETRY doubling to EXTRA_RETRY_CAP (30 s); a verified byte on an extra stream clears it; the third refusal in a row logs at info. add_extra reuses the lane's ended extra slot, so Work stays bounded.
  • Waiting log. "a queued range waits for a stream" names the ranges, logs when they change and every 30 s while unchanged, and says whether candidates refused or none existed.

Reviewer notes

  • Read first: Growth / GrowthPass, the batch-start loop in acquire (restart grant), the worker-end arm (extra refusals), and Hold / ReleaseLease.
  • Deviation from the plan (3b). The plan said a restarted lane takes a lease again through cli_sources.rs lane_lease. That does not work here. Restarted lanes come from SourceSet::cached_lane and never reach connect/build. A rebuild would open a fresh lane, which adds a new FaceLaneHandle and a new pool-view entry. So the restart takes its permit through the lane's own LaneWiden, which holds the same per-provider semaphore and never waits. LaneWiden keeps its contract: one release per granted stream.
  • Deviation (3a). A refused extra stream does not ask for growth at once; it arms a per-lane backoff. Without this, a node that refuses extra streams would be re-asked in a tight loop.
  • Scope note. Because every worker end now asks for growth, a busy lane can grow for any queued range that has no idle taker, not only a fault's remainder. This is still bounded by free permits and one extra per lane.
  • No pub item changed. The decdn-client public-api snapshot passes unchanged.
  • I did not touch the flush arm or the final flush, which are being edited in another PR.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run -p decdn-client -p decdn-cli: 1367 passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • cargo nextest run -p decdn-client --features public-api-test --test public_api: passes, no snapshot change
  • pre-commit run --files <changed files>
  • User-visible change: CHANGELOG.md entry added under Fixed
  • PR title uses an allowed type with a lowercase subject

New tests in scheduler.rs. Each was checked to fail with its fix disabled:

  • growth_is_asked_again_once_a_stream_frees: grow fails at the fault, and a permit frees 300 ms later. The extra opens on the retry clock, before the dead node returns from its cooldown and faults again.
  • a_remainder_only_the_faulted_lane_covered_goes_to_a_busy_lanes_extra: a Work-level test. A barred busy lane is not asked. An unbarred busy non-covering lane is asked, and its extra's pick returns the remainder with uncovered = true. A barred lane's extra takes nothing.
  • a_lanes_lease_is_released_when_its_own_worker_ends: the lease drops while the fetch still runs. The lane restarts on a granted stream, and every grant comes back.
  • a_node_refusing_every_extra_stream_is_asked_less_often: extra opens at 0, 1, 3, 7, 15 s; each wait doubles.
  • extra_stream_refusals_of_an_uncovered_range_bar_the_lane: a busy partial holder refusing an orphan block with NotFound is asked at most ABSENT_AFTER_NOT_FOUND times (6 times in 50 s without the fix).
  • a_lane_refused_a_stream_starts_again_once_one_frees: a restart with no free permit starts within one GROWTH_RETRY of a sibling freeing one; asks stay about one per second; grants balance. Plus source_set::a_lane_refused_a_stream_waits_a_flat_retry.
  • a_busy_lane_runs_at_most_one_extra_stream: with a hook that would grant 3, peak held grants stay at 1. The Work test also checks the one-extra bound and extra slot reuse.
  • every_lease_is_released_when_acquire_returns is unchanged in behavior. Its doc now says it covers lanes without a LaneWiden.

Still to do after merge (from the plan): a live bundle pull run, compared with the 497–659 s baseline.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz

Copilot AI balanced review requested due to automatic review settings October 1, 2026 21:05
@thiras thiras self-assigned this Oct 1, 2026

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.

Copilot review overview

🟡 Changes recommended

The broadened growth policy conflicts with ADR 039’s canonical concurrency invariant and requires an ADR update.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Improves bundle-pull recovery when lanes fault or stream permits are temporarily unavailable.

Changes:

  • Retries lane growth and permits uncovered remainder reassignment.
  • Releases lane leases earlier and reacquires permits for restarts.
  • Adds focused scheduler tests and user-facing release notes.
File Description
crates/​client/​src/​streamer.rs Documents revised lease and widening behavior.
crates/​client/​src/​source_set.rs Adds restart backoff helpers.
crates/​client/​src/​scheduler.rs Implements growth retries, permit handling, reassignment, and tests.
crates/​cli/​src/​commands/​bundle_pull.rs Documents bundle-pull permit ownership.
CHANGELOG.md Records the recovery improvement.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/client/src/scheduler.rs Resolved
@github-code-quality

github-code-quality Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 6548498 in the fix/2230-lane-growth... branch remains at 87%, unchanged from commit 3a565c1 in the main branch.


Updated October 02, 2026 02:59 UTC

thiras and others added 3 commits October 2, 2026 05:26
…stream

A faulted lane's remainder could wait minutes in bundle pull. Three gaps
kept it from starting when capacity freed:

- Growth was asked only at the fault. A `grow(1)` that found no free
  permit was never asked again, and a permit a sibling entry frees wakes
  nothing in the acquire loop. Every worker end and every landed build
  now ask again, and while a `grow` granted nothing and a range still
  waits, the loop asks again every GROWTH_RETRY (1 s). The info line
  "a faulted lane's remainder waits" logs only when the count changes.
- Leases were released only when acquire returned, so a faulted or idle
  lane held its provider's permit from sibling entries for the whole
  fetch. A lane with a LaneWiden now releases its lease when its own
  worker ends. Its restart from the source set's lane cache takes its
  stream through `grow`, held as a ReleaseGrant, and backs off like a
  build that found every permit taken when none is free. A lane without
  a LaneWiden keeps its lease until the acquire returns.
- growth_wanted offered only lanes that cover the range, so a remainder
  only the faulted lane covered had no candidate. It now applies the
  idle-worker rule: a busy lane not barred from pull-through may grow for
  a range no running lane covers, and its extra worker takes it through
  pick's uncovered branch.

Refs #2230

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz
ADR 039 limited the additional stream to a busy source that covers a
faulted source's remainder. The acquire now offers it for any queued
range no idle source takes, lets any busy source not barred from
pull-through take a range no running source covers, asks again as
streams end and every second while a grant fails, and gives a lane's
permit back when its first stream stops. State that, and keep the
in-flight bound at most two streams per active source. The bundles
appendix says a lane gives its permit back when it stops.

Refs #2230

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz
…sals

Review fixes for the lane growth retry:

- A NotFound or size-ceiling refusal of an uncovered range on an extra
  stream counts toward barring the lane from pull-through
  (SourceSet::record_extra_refusal), without cooling the node. A busy
  partial holder that cannot pull through is no longer asked for an
  orphan range every second.
- A lane whose node refuses its extra stream waits from GROWTH_RETRY,
  doubling to EXTRA_RETRY_CAP (30 s), before it is asked again; a
  verified byte on an extra stream ends the wait. The third refusal in a
  row logs at info. The retry clock takes the earliest of its triggers,
  and add_extra uses the lane's ended extra slot again, so Work stays
  bounded.
- The waiting log names the ranges, logs when they change and every 30 s
  while they stay, says whether candidates refused or none existed, and
  speaks of a queued range, not a faulted lane's remainder.
- A lane refused a stream to start again retries on a flat GROWTH_RETRY
  (SourceSet::start_retry), apart from the build backoff, and logs the
  first refusal at info.
- The own worker's future holds a ReleaseLease guard, so the lease
  follows the worker's lifetime with no slot lookup; a restarting lane
  that still holds its lease starts on it.
- ExtraPermits::release_one warns (and debug-asserts) on a release with
  none held; a closed semaphore warns.
- ADR 039, the bundles appendix, the CHANGELOG and the docs state the
  partial-uncovered rule, the bar, the refusal backoff, the restart
  retry and the in-flight bound as the code has them.

Tests: refused extras back off by doubling, uncovered refusals on extra
streams bar the lane, a refused restart starts within a retry of a freed
stream, a busy lane holds at most one extra grant, the restart cadence
in SourceSet, extra slot reuse and the one-extra bound in Work.

Refs #2230

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz
@thiras
thiras force-pushed the fix/2230-lane-growth-retry branch from 6c22d29 to 6548498 Compare October 2, 2026 02:52
@thiras
thiras merged commit dc1c210 into main Oct 2, 2026
30 checks passed
@thiras
thiras deleted the fix/2230-lane-growth-retry branch October 2, 2026 03:04
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.

2 participants