Skip to content

refactor(client,cli,node): one acquire loop for fetch recovery, size as a hint - #2239

Merged
thiras merged 56 commits into
mainfrom
claude/failover-fetch-recovery-e786c4
Sep 30, 2026
Merged

thiras merged 56 commits into
mainfrom
claude/failover-fetch-recovery-e786c4

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Ready for review, and for a staging deploy. Deploy nodes and the CLI from the same commit, because the range semantics change on both sides. Every task passed a spec and quality review, and the final whole-branch review found no remaining issues.

Why

A single blip used to end decdn fetch and decdn bundle pull. Recovery was split across six stacked layers, each with its own stop rule:

  • driver leg retirement
  • a one-pass candidate loop
  • a one-shot rediscovery
  • a multi-source to single-source fallback
  • entry retry rounds
  • a second range-lane engine

With one or two holders, one reset per node used up the list.

A CLI command carries an intent: "get me these bytes". It now stops only when one of these happens:

  • the bytes are done;
  • a fault needs the user to fix it (voucher rejection, blacklist, size cap, no affordable holder, local disk fault);
  • the idle limit expires. A terminal has no limit. A script stops after 10 min, exits 75, and prints "rerun to resume". --give-up-after-secs sets the limit.
  • the user presses Ctrl-C.

What changed

  • One acquire loop over a SourceSet (decdn-client). A node that faults cools down, starting at 2 s and doubling up to 60 s. It is never dropped. Lane builds and discovery run alongside the streaming lanes.
    • Stops are unanimous and proven, never voted. Every holder priced out → NoAffordableSource. Every non-holder saying NotFound three times → NoSourceHasBlob, which ends that item only.
  • Faults are classified by classify into Fatal(Command | Item), Source, Unaffordable and Transient. The command-wide PeerHealth and StopPolicy are shared by every bundle entry.
  • decdn fetch (file and -o -) and decdn bundle pull (manifest, whole-file entries and range-dedup entries) all run through acquire. Deleted:
    • fetch_over's loop, the rediscovery pass and the multi-source fallback
    • --entry-retries
    • SessionWalk, drive_range_lanes and retry.rs
    • the flags --stall-timeout-ms, --unit-deadline-ms, --min-throughput-bps, --multi-source-min-bytes and --(no-)multi-source
  • A size claim is a hint:
    • Nodes serve a request up to the blob's end instead of refusing it.
    • The client store is keyed by offset. It verifies each leg under its sender's own claim, so a verified final chunk proves the size. .obao4 is gone, and finalize is a whole-file BLAKE3 check.
    • The planner trusts the first claim. The first claim is the probe's hint. With no hint (a pinned node, or the fast path), a header-only open supplies it.
    • The planner grows the bound by max(bound + 64 MiB, C0 + 2 * extra), and shrinks it when a leg proves a smaller size.
    • Claims are clamped to --max-blob-mb. A blob truly over the cap ends that item with BlobTooLarge.
    • The size-consensus code is deleted. A bundle entry whose true size differs from its manifest succeeds with a warning.
  • Coverage is a preference. A block no chosen lane covers goes to any lane, which serves it by pull-through.
  • A busy lane can take one extra stream for a dead node's remainder. A node is charged once per outage.
  • A local store error ends the fetch as our own fault. It never cools the node.
  • Terminal output: the progress bar is unchanged. Recovery details log at debug. Only faults the user can act on print.

How to read it

Commits are grouped by phase:

  1. recovery units (fault, health, stop, source_set)
  2. acquire and decdn fetch
  3. bundle pull
  4. range-dedup
  5. final-review fixes
  6. range clamp and offset-keyed store
  7. the merge of main (fix(node): stop partial holders pulling a blob from each other in a loop #2227 kept; fix(client,cli): log each lane fault where it happens and grow a busy lane for its remainder #2231's lane-growing is re-done on acquire in Task 16)

Suggested file order:

  1. crates/client/src/{fault,health,stop,source_set}.rs
  2. crates/client/src/scheduler.rs (acquire)
  3. crates/client/src/ranged_store.rs
  4. crates/cli/src/commands/cli_sources.rs
  5. fetch.rs and bundle_pull.rs
  6. ADR 039 / 037 / appendix-bundles

Staging scenarios

  • Kill the sole holder mid-fetch and restart it. The fetch completes (e2e cli_fetch_recovers_one_holder).
  • Start a fetch while the sole holder is down, then start the holder. The fetch completes.
  • Fetch a mistyped hash. It stops with "no provider holds this blob".
  • Run with stderr redirected and no progress for 10 min. The command exits 75.
  • A bundle whose manifest size is wrong completes with a warning.
  • Run nodes and the CLI from the same commit. Task 14 changes range semantics on both sides.

Issues

Closes #2223, closes #2215, closes #2214, closes #2225, closes #2213. Refs #2218 (client side fixed here; the node pull-leg handshake is covered by #2227) and #2230 (the serial tail and the logging are fixed; the cause of the 10 s proof gap is still open).

Also in this PR

  • One connection per node for a whole command. A stall, a timeout or a closed connection unpins that connection, and the next leg redials. Node pull legs dial per leg until Pull legs run on ephemeral per-serve runtimes, stranding shared connection drivers (HTTP + QUIC) #1675 is fixed. --max-lane-streams is limited to 1..=64.
  • A finalize hash mismatch retries once. The first mismatch clears the claims and keeps the file, then the command re-fetches. A second mismatch ends the item.
  • An existing final file at -o is trusted only if its BLAKE3 matches. A leftover file of another blob is never reported as success.
  • Clean-up and docs: the CHANGELOG entry lists the flag and SDK breaks, and ADRs 005, 037 and 039 and appendix-bundles describe the new behaviour.

Known follow-ups (not in this PR)

🤖 Generated with Claude Code

alpergundogdu and others added 30 commits September 28, 2026 15:52
…quire

Move the Downloader and Streamer faces onto acquire over a SourceSet, add
first_open (a signed header-only open with acquire's recovery), and add the
CLI's SourceProvider (CliSources). decdn fetch (file and stdout) learns the
blob's signed size through first_open, then runs one acquire under a
StopPolicy: a terminal waits, a script gives up after 10 minutes, and
--give-up-after-secs overrides both. A give-up exits 75.

Delete multi_source_fetch, multi_source_fetch_until, SourceLane,
MultiSourceConfig, download_first_unit, PullConfig::download_unit_deadline,
the fetch_over failover loop and rediscovery pass, the multi-source gate,
CLI lane priming, and the --stall-timeout-ms, --unit-deadline-ms,
--min-throughput-bps, --multi-source-min-bytes and --[no-]multi-source flags.
The node's ranged assembly and the driver classify faults with classify.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a lane permit

- StreamDrive keeps the fetch's typed error (take_error), and decdn fetch -o -
  surfaces it in place of the reader's message, so a give-up exits 75 and the
  remedy hints attach.
- The stop clock holds while a stream waits on its consumer (ClockHold), so a
  paused downstream is not a stall.
- A CLI lane takes its provider's stream permit without waiting, the first
  open's lanes included; a taken cap fails the build and the source set backs
  it off.
- The node's ranged assembly reassigns an open-time InsufficientDeposit; only
  a fatal fault or PoolExhausted ends it.
- Drop ResolvedTargets::skipped_registry_read, Probed::total_bytes and the
  Downloader's unused PullConfig parameter; fix stale docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ering lane

- A lane parked on the consumer holds the stop clock only while verified
  bytes sit unread ahead of the cursor. Once the consumer has read everything
  present, the clock runs, so a gap whose only holder is dead ends in GaveUp.
- The first open parks only the lane that answered; every other lane drops
  with its lease, freeing its provider's stream permit for sibling entries.
- Fix a stale Probed::coverage doc and an em-dash in the delegated remedy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ADR 037 and ADR 039 described fetch recovery as sequential
single-source failover, a multi-source engagement gate with a size
floor, and separate stall/throughput-floor deadlines. Rewrite those
passages to describe the single acquire loop: per-holder cooling
(2 s doubling to 60 s, reset on a verified byte), a fixed 10 s lane
watchdog, 5 s-5 min rediscovery backoff, and a whole-fetch stop
policy (no limit on a terminal, 10 min for a script,
--give-up-after-secs override). Multi-source always runs; a single
holder is a lane set of size one, not a separate code path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fetch-recovery rewrite in adr/039-multi-source-parallel-fetch.md
named "a shared-pool exhaustion" as a stop condition, which is not
one, and omitted the size-cap, disk-fault, and no-affordable-holder
cases. State the five faults that end a fetch, and the separate
no-holder-has-the-blob condition, exactly. Reword the two Negative
consequences bullets that still assumed a single-source path exists.
Split the semicolon-joined sentences added in the previous commit,
and remove the two remaining em-dashes on lines that commit touched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
"item" appeared in the fault-list passage with no definition. Define
it before its first use: one blob the command fetches, an entry in a
bundle pull, or the whole fetch for decdn fetch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The bundle pull total bar no longer folds a file's landed prefix across
retry rounds: every fetch of an entry reports into one bar. The e2e
multi-source comment names the acquire loop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…elete the range-lane engine

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On the wire NotFound also means load shed, a per-signer cap, or a pool
the node cannot confirm yet. A probed holder (or a pinned --node-id)
that answers NotFound now only cools; a pull-through target is marked
absent after three NotFound answers with no verified byte between them.
The NoSourceHasBlob stop carries the last absent refusal as its source,
so the CLI's cache-miss hints still attach.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A sole holder that was down when decdn fetch or a bundle entry started
made the command exit 1 at once, because the initial holder resolution
sat outside the recovery loop. A resolution that fails for any reason but
the configuration (missing capacity_bond, a malformed --node-id, probe
signatures that do not recover) now starts with no holder, and the loop
discovers with backoff under the stop policy.

first_open runs discovery beside its attempt in one select!, so a slow
discovery never holds back a source whose cooldown ended, and an empty
holder set discovers until one appears. signed_size hands the holders its
discovery found on to the fetch. A Downloader accepts an empty holder
set; StaticSources refuses one instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
acquire dropped lane builds still in flight when it returned. A build can
be in the middle of the CLI's low-water topUp, which escrows funds the
buyer store never records. On every exit the loop now stops its lanes and
awaits each build still in flight, for at most 30 s; a lane built there
never starts and drops at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ps exactly

- The acquire loop reads the pool deposit as the larger of its own watch
  and every started lane's context, so a top-up a sibling bundle entry
  credits to the shared lanes reaches it.
- A leg's first byte gets a 30 s grace before the 10 s lane watchdog
  applies, so a cold miss whose first byte waits on the node's upstream
  is not a stall.
- GaveUp prints whole minutes only for an exact minute; 90 s prints as
  "90s", not "1m".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nodes

- Downloader::new takes the lane cap explicitly. The CLI passes
  --max-sources and keeps every other holder as a reserve, so a holder
  discovery adds later can take a free lane; the cap no longer shrinks to
  the starting holder count.
- holders_from replaces an operator's stored node on rediscovery, so the
  next lane build dials the node the latest probe ranked. A lane already
  built keeps its node.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
decdn fetch keyed its store once, from the nearest holder's header. A
holder that signs a wrong size then wedged the fetch: its own bytes never
verify, and every other holder is excluded as wrong-size.

The download now names the provider that signed its size. When every
other known holder signs a different size and the signer delivered no
verified byte, the SourceSet ends the target with NoSourceAgreesOnSize.
decdn fetch then excludes that signer, persists what the lanes paid,
discards the wrong-size .partial, and runs the first open again from the
next holder, at most once per distinct signer. Bundle entries keep their
manifest size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
No caller primes a lane's first unit any more, so the reservation path is
unreachable. Delete StreamCandidate::first_unit, stream_first_unit, the
scheduler's reserve_first_units / honours_first_unit and Work::first, and
their tests. PrimedSource stays: the node's pull leg primes through it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Replace every "spec §" reference in code comments and rustdoc with an
  ADR 039 section, or drop it where no ADR section applies. The working
  spec is not in the repo.
- ADR 039: a fetch with no usable source waits for one and stops only on
  a fault the user must fix, a unanimous verdict, or the stop policy
  (acceptance criterion 3 and the failure-handling text); lanes join as
  sources become usable instead of all up front; the client cools a
  faulted source and never drops it; drop the segment-size rule the code
  does not have.
- ADR 037: the failure stamp feeds the next run's fast path; in-run
  cooling is the in-memory PeerHealth.
- Fix the stale ScriptedSource::stall_after doc and the bundle multi-source
  e2e header.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-code-quality

github-code-quality Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit c7ec111 in the claude/failover-fetc... branch is 87%. The line coverage in commit 4904d7c in the main branch is 86%.

Show a line coverage summary of the most impacted files.
File main 4904d7c claude/failover-fetc... c7ec111 +/-
crates/client/src/driver.rs 97% 96% -1%
crates/client/src/scheduler.rs 96% 95% -1%
crates/cli/src/.../bundle_pull.rs 77% 80% +3%
crates/cli/src/...mmands/fetch.rs 54% 70% +16%
crates/cli/src/.../cli_sources.rs 0% 51% +51%
crates/client/s...c/source_set.rs 0% 95% +95%
crates/client/src/fault.rs 0% 97% +97%
crates/client/s...c/first_open.rs 0% 98% +98%
crates/client/src/health.rs 0% 99% +99%
crates/client/src/stop.rs 0% 100% +100%

Updated September 30, 2026 01:41 UTC

alpergundogdu and others added 13 commits September 29, 2026 21:36
…r, and fix stale docs

- `AcquireEnv::max_blob_bytes` (with `Downloader::max_blob_bytes` and
  `Streamer::max_blob_bytes`; the CLI passes `--max-blob-mb`) clamps a size
  claim to the cap before the store or any coverage bitmap is sized, and
  growth never raises the bound past it. A bound at the cap with no size
  proven ends the item with `BlobTooLarge`.
- An extra stream whose lane's own worker has stopped is the lane's last
  live worker: its fault is recorded and cools the node (#2231).
- `ClientRangedStore::set_bound` does nothing once a size is proven.
- A pinned `--node-id` builds its targets in `pinned_targets`; tests pin
  that it and the peer-store fast path carry no size hint.
- Docs: `build_completed_updates` gets its doc back; the scheduler, the
  open-lock and the first-claim docs, and ADR 039, state the current rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…roven size

- `acquire` keeps the providers charged a fault since their last verified
  byte. An extra stream's fault after its lane's own worker stopped cools
  the node only when the node is not already charged for this outage.
- A proven size past `max_blob_bytes` ends the item with `BlobTooLarge`: a
  cap off the chunk-group grid lets a leg that ends at it prove a size up to
  one group past it.
- Tests: one charge per outage, a blob exactly at the cap, and a proven size
  past an unaligned cap. `ScriptedSource::delaying_open` holds one open.
- Rewrap a long `fetch_over` doc line; ADR 039 drops "signed" from the
  size-disagreement sentence and states the once-per-outage charge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A whole-blob target cut from the first claim C0 was not a tail when a
resumed record's bound or proven size was past C0, so acquire returned
with [0, C0) present and finalize failed Incomplete on every rerun.
Want::new now takes C0: a range that reaches min(C0, bound) is a tail and
runs to the bound.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A node that signed a size of zero for a bounded open failed the wire
bound's alignment, and the error carried LocalPullFault, so one node
ended the whole command. The open now refuses any range that asks for
bytes at or past the signed size with ResumeOffsetPastEnd, and
aligned_wire_len no longer marks its errors local: every input to it is
the peer's signed size or our own cap.

A leg that proves a smaller size between a caller's bound read and its
missing-ranges query no longer turns into a fatal RangeOutOfBounds: the
query re-reads the bound and clips to it (missing_below_bound). The
ClientRangedStore contract stays strict, as the shared conformance suite
requires.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A bound that overshoots the blob sends pieces past its true end, and an
honest pull-through node refuses them with NotFound. Those refusals
counted toward ABSENT_AFTER_NOT_FOUND, so honest nodes could be marked
absent and the item could end with a wrong "check the hash". A lane
fault now carries LaneRange::past_end: the faulted piece starts at or past
the proven size, or with none proven at or past min(first claim, bound).
Such a NotFound still cools the node and never counts toward absent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…very error exit

A finalize whose whole-file hash does not match clears every claim and
keeps the file. The Downloader now runs acquire and finalize once more,
so bytes that drifted on disk after they verified are fetched again in
the same command; a second mismatch ends the target. Every bundle drive
and fetch finalizes through the Downloader, so they all get the retry.

Acquire flushes the present record once after its loop on any error, so
the ? exits (clip, regrow, missing_chunks, all_present) keep the bytes
that landed recorded for a resume.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
build() returned the lane the first open parked before it set the
stream-cap widen hook. The hook is now set on every lane build() returns
that does not carry one, the parked lane included, so a faulted lane's
remainder can take an extra stream on it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ClientRangedStore::missing_ranges and read align with
align_range_clamped, as the node's store does: an end past the bound
clamps to it, so a bound that shrinks under a caller that read it first
does not fail the query. A start at or past the bound stays an alignment
error, as the shared conformance suite requires.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rewrite the comments of this range in present tense without em-dashes or
the plan label: a size is a first claim, a hint, never a store key. Name
the first claim in first_open, the bundle range driver, the bundles
appendix and ADR 037. Add the missing CHANGELOG items: one connection per
node per command, the extra lane stream (#2231), the 1..=64 bound of
--max-lane-streams, the finalize retry and the decdn-client SDK breaks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alpergundogdu
alpergundogdu marked this pull request as ready for review September 29, 2026 22:52
Copilot AI balanced review requested due to automatic review settings September 29, 2026 22:52

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

🔵 Needs a closer look

It is a large cross-crate refactor of payment-adjacent fetch/serve range semantics whose core acquire/source_set/scheduler logic is only partially visible in the diff and which requires coordinated node+CLI deployment, warranting human review.

Review effort: Balanced
Findings: None

What changed in this PR

This PR collapses six stacked decdn fetch / decdn bundle pull recovery layers into a single acquire loop over a SourceSet, and reframes a blob's claimed size as a hint rather than a hard bound. A faulting node now cools down (2 s doubling to 60 s) instead of being dropped, faults are classified into Fatal/Source/Unaffordable/Transient by a shared classify, and a script-mode idle limit exits 75 ("rerun to resume"). Nodes serve a range clamped to the blob's end instead of refusing an end past the blob, the client verifies each leg under its sender's own size claim (dropping the .partial.obao4 sidecar for a whole-file BLAKE3 finalize), and the size-consensus machinery plus several recovery flags are deleted. It fits the deCDN paid-pull architecture where the daemon is itself a paying client on its cache-miss leg, so the range-semantics change must land on nodes and CLI from the same commit.

Changes:

  • One acquire loop with per-provider PeerHealth cooldowns and unanimous, proven stops (NoAffordableSource / NoSourceHasBlob); removes SessionWalk, drive_range_lanes, retry.rs, and several flags.
  • "Size is a hint": new align_range_clamped threaded through cache/node serve tiers; client store keyed by offset and verified under the sender's claim; size-consensus deleted; claims clamped to --max-blob-mb.
  • Give-up/idle policy with exit code 75, single warm connection per node, --max-lane-streams constrained to 1..=64, and ADR/CHANGELOG updates.
File Description
crates/​bao-range/​src/​lib.rs Adds align_range_clamped + shared build_aligned_range; the single source of truth for the size-as-hint clamp.
crates/​client/​src/​fault.rs (new) Fault/classify/says_absent/is_local_disk_fault driving acquire-loop stop decisions.
crates/​client/​src/​health.rs (new) Per-provider PeerHealth cooldown math (2 s→60 s).
crates/​client/​src/​stop.rs (new) ProgressClock/StopPolicy/GaveUp idle-limit and exit-75 logic.
crates/​client/​src/​source.rs IngestStore trait gains claimed_total.
crates/​client/​src/​retry.rs (deleted) Failover-classification module removed.
crates/​node/​src/​node_origin/​pull_leg.rs ends_the_assembly replaces shared_pool_disposition; PrimeLeg saturating_add(...).min(total).
crates/​node/​src/​handlers/​client/​dispatch.rs range_out_of_bounds now via align_range_clamped; bounds gate clamps.
crates/​node/​src/​handlers/​client/​serve_encoder.rs serve_end/encoded_ranges clamp serve span to blob end.
crates/​cache/​src/​{engine,ranged_store,fill_session}.rs Clamp missing_ranges/read via align_range_clamped.
crates/​node/​src/​node_origin/​admit_store.rs Node ingest ignores upstream claimed_total (verifies under its own size).
crates/​common/​src/​cli/​bundle.rs max_lane_streams: u16 with range(1..=64); entry_retries removed.
crates/​cli/​src/​{main.rs,commands/​*} exit_code_for routes GaveUp→75; fetch/bundle run through acquire; removed flags.
ADRs 005/​012/​022/​037/​039, appendix-bundles, CHANGELOG.md Document size-as-hint, one acquire loop, removed flags, exit 75.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

alpergundogdu and others added 2 commits September 30, 2026 00:10
The two #2231 outage tests order B's own-leg fault and its extra
stream's fault on explicit gates instead of timing. ScriptedSource
gains holding_fault(nth, gate): a refusal waits inside open, and a
parked mid-range fault waits after the reader's last byte, until the
gate opens. The own leg's fault is released once the extra stream has
opened, and the extra's fault once the own worker's fault is recorded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-recovery-e786c4

# Conflicts:
#	crates/client/src/driver.rs
#	crates/client/src/source.rs

@thiras thiras left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Live smoke run on this branch (Mistral bundle, 2026-09-30 00:54 UTC)

58f545e1 CLI against the 09-29 05:43 fleet build: 6m48s, 0 failed, 17.1 GB downloaded / 29.0 GB reconstructed (same as every prior run). Served bcl 7.0 / ash1 3.5 / nbg1 2.8 / fra1 2.4 / hel1 1.6 / lon1 0.9 GB. No client WARNs beyond IPv6 sendmsg NetworkUnreachable noise. Node-side WARN/ERROR in the window: only dRPC code 19 poller restarts.

Two findings, one of them in this PR's code.

1. Steal ping-pong opens the same remainder on both lanes and cancels it before paying (this PR)

Every re-plan of a two-lane pair produced this shape in the client debug log (four opens within 200 µs):

00:59:56.859629 peer=bcl  hash=ad7f7e byte_offset=1233125376 byte_len=310378496
00:59:56.859728 peer=nbg1 hash=ad7f7e byte_offset=1233125376 byte_len=310378496
00:59:56.859773 peer=bcl  hash=ad7f7e byte_offset=1350565888 byte_len=192937984
00:59:56.859825 peer=nbg1 hash=ad7f7e byte_offset=1233125376 byte_len=117440512

Node-side Tempo serve_stream spans for the first two read write failed: frame I/O error: sending stopped by peer: error 0 at 0.0–0.1 s, before any voucher. Same shape at 01:00:06, 01:00:11 and 01:00:12. Over the last 24 h Tempo holds 7 sub-300 ms pre-payment cancels fleet-wide; 6 are this CLI's peer id. Every one counts as decdn_streams_failed_total on the node (nbg1: 14 in the run) and burns a signer-cap slot.

Mechanism (walked through the code, the numbers above reproduce exactly):

  • Work::in_flight stays the whole picked range and never advances as bytes land (scheduler.rs ~1452, stated in the comment there).
  • steal_split picks the largest picked range and splits it at its midpoint (segment.rs:203), never looking at the victim's delivered frontier.
  • When the victim has already delivered past the midpoint, the stolen "second half" contains the victim's entire missing remainder R. The stealer's store_missing gap is R, non-empty, so it passes the gaps.is_empty() guard, calls cancel_victim, and opens R.
  • The victim is trimmed to [start, mid), which is fully present, so requeue_missing re-queues nothing. It picks again with nothing pending, steals back half of the stealer's range, which again contains all of R, and opens R while cancelling the stealer.
  • This alternates, halving each round, until the split point passes the frontier. Cost ≈ log2(picked ÷ remaining) wasted opens per steal, and the first round kills the victim's productive long-running leg.

At 00:59:56: nbg1 held [0, 1472M) with frontier 1176M. bcl steals [736M, e) → opens R. nbg1 trimmed to [0, 736M), all present, steals [1104M, e) → opens R. bcl trimmed, steals [1288M, e) = 1350565888. nbg1 finally re-queues its real missing part [1233125376, +112M). All four lines accounted for.

This is also what produced the halving cascade on 998030 (nbg1 legs 889 → 373 → 149 → 66 → 28 MB, each stop+reopen 1–3 s).

Fix direction, either:

  • split the still-missing remainder rather than the picked range (advance in_flight to the checkpointed frontier, or run steal_split over store_missing of each in-flight range), or
  • decline the steal when the victim's trimmed part [start, half.start) has no missing bytes, since that steal would take the victim's whole remaining work.

Either way the steal path needs a log line. A successful steal is logged nowhere (not in Work::pick, not in the victim's Cancelled → requeue_missing path); the only related line is the "steal victim moved on; cancel skipped" debug that fires when a cancel is skipped. With RUST_LOG=decdn_client=debug the whole run's log is 158 × "opening a paid leg" and nothing else from the scheduler.

2. decdn_probe_hold_slots_used freezes between probes (node side, not this PR)

The gauge is set only inside the probe handler (crates/node/src/handlers/probe.rs:640), so it reports the last probe's value until the next probe. nbg1 read 8 for ~10 h yesterday and 11 for 10+ min after this run with zero active streams, although PROBE_HOLD_DURATION is 35 s. Engine::probe_hold_slots_used documents that the gauge "reflects live holds even with no probe traffic", but nothing samples it then. Filing separately unless you want it here.

Also seen, nothing new

All 7 nodes up, 19.2 h uptime, no restarts. Firing alerts are all dRPC code 19/30. bcl's watchers restart ~2× the others (143 poller errors / 6 h) with no other bcl symptom, and bcl logs 274 IPv6 NetworkUnreachable WARNs per 6 h (no IPv6 route, iroh tries peers' advertised v6 addrs). Dashboard audit 337/350 targets OK, 13 NaN are idle histogram/ratio divisions.

🤖 Generated with Claude Code

Comment thread crates/client/src/scheduler.rs Resolved
Comment thread crates/client/src/scheduler.rs Resolved
Comment thread crates/client/src/scheduler.rs Resolved
…ked range

`steal_split` split a lane's picked range at its midpoint. Once the victim
had delivered past that midpoint, the stolen half held the victim's whole
missing remainder: the trimmed victim re-queued nothing, stole back half of
the thief's range, and the two lanes cancelled each other's legs before any
voucher, halving each round.

The argmax and the split now count each in-flight range's missing bytes,
read from a store snapshot taken before the pick. The thief takes the
aligned second half of the victim's missing remainder, the victim is
trimmed to end at that split, and a split that would leave the victim no
missing byte declines the steal. A steal and a cancelled leg's requeue log
at debug.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras enabled auto-merge (squash) September 30, 2026 02:48
@thiras
thiras merged commit 2dab1f5 into main Sep 30, 2026
32 checks passed
@thiras
thiras deleted the claude/failover-fetch-recovery-e786c4 branch September 30, 2026 02:49
alpergundogdu added a commit that referenced this pull request Sep 30, 2026
…2245)

The gauge was written only by the probe handler, so it held the last
probe's value until the next probe arrived (nbg1 read 8 for ~10 h on
testnet). The node now attaches its cache engine to Metrics and samples
probe_hold_slots_used() in encode(), next to the existing scrape-time
uptime and watcher down-seconds recomputes. The read sweeps expired
holds, so the gauge returns to 0 once holds lapse with no probe traffic.
The per-probe gauge writes are gone.

Probe-hold expiries run on the tokio clock so a paused test clock can
drive them; the new test takes a hold, advances past
PROBE_HOLD_DURATION, and asserts the scrape reads 0.

Found in review 5360334012 on #2239.

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

3 participants