Repository navigation
fix(cli,client-pull): harden bundle pull failover, dedup complement, and data-dir guards - #2122
Merged
Merged
Conversation
…undle entries (#2086, #2118) daemon_marker stats each daemon store with symlink_metadata and returns a stat error other than NotFound instead of reading it as "not a node". classify_buyer_store and ChainAdoption::for_buy propagate it, so every money-moving refusal guard refuses when the owner is unknown. bundle pull walks candidates through one walk_candidates helper: a pool exhaustion fails over on both the whole-file and the range path, every failover logs a warning (the last one too), and the exhausting error names the candidate count. A new --entry-retries (default 2) re-runs retryably failed entries after the first pass, with 2 s doubling backoff capped at 30 s; each round re-probes and resumes the .partial. A retried entry's bar does not recount its landed prefix on the total. ensure_partial creates a real ranged store (with its .ranges record) instead of a bare .partial, so a later drive into the entry no longer truncates the donor bytes spliced into it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ranges over one warm session (#2063, #2119) The fetch prelude opened a throwaway whole-blob pull only to read total_bytes, dropped it, and let the drive open the same range again. The node treats every open as real (sign, claim a fill, start an origin draw), so every cold entry paid a duplicate draw and a delayed first byte. The prelude now opens exactly the drive's first leg (first_leg, built on the same leg_range the Draw arm uses) and parks it in a PrimedSource, whose first open of that exact hash and range adopts it. A dedup entry, whose manifest gives its size, opens a bounded first leg instead of the whole blob. A resume or a mismatched range drops the pull; a primed pull older than 2 s is never adopted. A range-dedup entry paid its ~1,300 boundary groups one drive at a time, each on a fresh QUIC connection and behind a fresh prelude. The CLI now opens one RangeSession per provider per entry and reuses it for every drive (complement, re-fetch, deferred fallback, self-heal). The session's PeerSource keeps one warm connection (redialled if it closes) and drive_range_set fills the merged gaps up to --max-lane-streams at once under one flush owner and one finalize. Without a shared pool the gaps stay serial so the top-up budget cannot multiply. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…2120) The throughput floor judged one stream at a time. A range-dedup entry's short legs are each briefly healthy and the wait between legs belongs to no stream, so an entry could deliver under 1 MB/s for 20 minutes with no stall, no failover and no warning. client-pull adds throughput_watchdog, the existing ThroughputFloor over a caller's counter with a pause flag. The CLI runs drive_fetch and every RangeSession drive under it (watched_drive), on an EntryWatch that folds the drive's reported position across every leg. A PausingFunder stops the clock from a top-up until the next byte lands. A trip ends the drive with EntryStalled (RetryElsewhere), flushes the present record the dropped drive skipped, and fails over; --entry-retries picks up an entry that runs out of providers. At -v a drive logs its position, rate and ETA every 10 s, and each bundle entry logs its size, time and rate. The driver's progress callbacks take a borrowed trait object so a caller can wrap its own. Adds a scattered-complement e2e that drives ~25 ranges four at a time and checks exact billing, and the CHANGELOG entries for #2063, #2086, #2118, #2119 and #2120. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved critical and moderate correctness issues remain in retry coordination, permit handling, watchdog accounting, and provider failure handling.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (5)
Avoid marking retryable donor groups as finished · New Prevent permit retention from deadlocking deferred reassembly · New Track concurrent top-ups to prevent incorrect stall failover · New Mark providers unhealthy on manifest size mismatch · New Preserve millisecond precision in stall timeout errors · New
What changed in this PR
Hardens bundle pulls with failover, retries, concurrent range deduplication, throughput monitoring, and fail-closed data-directory checks.
Changes:
- Adds entry retries, warm sessions, and concurrent range driving.
- Adds stall detection and improved progress reporting.
- Propagates ownership-classification errors and updates documentation.
| File | Description |
|---|---|
crates/node/tests/origin_range_pull.rs |
Updates origin-pull test documentation. |
crates/e2e/tests/cli_bundle_pull_range_dedup.rs |
Adds concurrent complement billing coverage. |
crates/common/src/data_dir.rs |
Makes daemon-marker stat failures explicit. |
crates/common/src/cli/bundle.rs |
Adds --entry-retries. |
crates/client-pull/src/source.rs |
Adds warm connections and primed pulls. |
crates/client-pull/src/progress.rs |
Adds drive-level throughput watchdog support. |
crates/client-pull/src/lib.rs |
Exports new driver and source APIs. |
crates/client-pull/src/driver.rs |
Adds first-leg and concurrent range driving. |
crates/client-pull/src/connection.rs |
Adds connection-closed detection. |
crates/cli/src/commands/pull_progress.rs |
Prevents retry progress double-counting. |
crates/cli/src/commands/pool.rs |
Propagates ownership-classification errors. |
crates/cli/src/commands/fetch.rs |
Integrates priming, sessions, and watchdogs. |
crates/cli/src/commands/buyer_store.rs |
Makes ownership guards fail closed. |
crates/cli/src/commands/bundle_pull.rs |
Adds retries, failover, sessions, and store protection. |
CHANGELOG.md |
Documents the fixes. |
adr/appendix-bundles.md |
Updates bundle concurrency and retry behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 84.02% (was 83.85%, ▲ +0.17%) — 91480/108878 lines
History
|
…cross gaps Review follow-ups on #2122. - A range session took every free permit for its provider when it opened and kept them through reconcile_deferred. A recipient could then hold all of provider P's permits while waiting on a donor blocked on P, a deadlock at the default --max-lane-streams. The extra permits are now taken per drive and returned when it ends. - Concurrent gaps can each start a top-up, and a byte from one gap cleared the drive watch's pause while another gap's top-up was still on chain. EntryWatch counts top-ups in flight and only progress with none pending ends the pause. - EntryStalled prints its window with sub-second precision. - A test pins that a donor retried after a recipient registered its chunk splices it rather than paying for it again. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Drive-level floor: - The floor raced the whole drive, so it also timed finalize's local re-hash of a complete blob: a paid multi-GB download could fail as EntryStalled, and its dropped flush could race an older record write. drive_range_set takes a `stop` future that races only the gap work; the pending flush lands, the final flush runs, finalize is untimed. drive_fetch now runs drive_range_set too, and both CLI drives share FetchPrelude::drive_watched/settle_drive. - EntryWatch::begin_topup owns the pause; observe re-checks after its store so a top-up starting between the check and the store stays paused. A failed drive stamps the peer store only when the peer caused it (not PoolExhausted / InsufficientDeposit). Money: - SharedPool gains topup_lock (the run's LaneLedgers::topup_lock, a local one for the scheduler and the node's pull legs). A lane that waited on it re-reads the deposit and decides again, so concurrent gaps no longer escrow twice or revert on a spent allowance. - A group re-run in a retry round is unmarked as finished, so a sibling deferring its chunk waits instead of paying for it too. - open_or_create uses try_exists: a failed stat of .ranges no longer reads as "no record" and truncates a paid .partial. Errors: - drive_range_set keeps the decisive gap error (terminal, then PoolExhausted) and logs the rest. - The warm-connection retry logs the first error and never re-asks a peer that sent a refusal. - entry_retryable also skips a ManifestSizeMismatch and a local disk fault; queued retries are logged with their entry and error, and the failover warnings name the entry. - PrimedSource and the progress fold map recover a poisoned lock instead of dropping state; an unused primed pull is logged. Types/tests/docs: - open_fetch_prelude derives the warm connection from PreludeLeg; RangeSession::open takes &LaneLedgers; GroupRun::fetch_failed; the session walk is a generic SessionWalk with a fake-driven unit suite. - New tests: warm PeerSource on one connection (node loopback), stop keeps landed bytes recorded, one top-up for concurrent gaps, error ranking, concurrent progress, primed + concurrent, retry settle and unmark, flag default, open_or_create stat failure; the scattered e2e counts the node's served opens (no open thrown away). - Fix doc comments split by inserted tests, stale "throwaway" prelude wording, the PeerSource concurrency claim, the drive_fetch doc sitting on select_watermark, --entry-retries help, ADR and CHANGELOG wording. Co-Authored-By: Claude Opus 5.5 (1M context) <[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.



Closes #2063
Closes #2086
Closes #2118
Closes #2119
Closes #2120
The four bundle-pull issues come from one testnet gpt-oss pull that crawled and failed silently. #2086 is a fail-open classifier on the pool guards that move USDC. One commit per concern.
#2086:
daemon_markerfails closeddaemon_markerreturnsio::Result<Option<_>>and stats withsymlink_metadata. OnlyNotFoundreads as absent.classify_buyer_storeandChainAdoption::for_buypropagate the error. A stat error therefore refuses escrow, sweep, implicit-node-dir buys and chain adoption.pool list --allshows the TRACKED column as unknown.#2118: failover, visible exhaustion,
--entry-retrieswalk_candidateshelper serves both the whole-file path and the range path.PoolExhaustednow fails over on the range path too, perretry_disposition's documented rule.all N candidate provider(s) failed, which shows in the end-of-run summary. The context wraps the original error, so classification still works.--entry-retries N(default 2): after the first pass, each retryably failed entry runs again. The backoff is 2 s, doubling, capped at 30 s..partial, so no byte is paid for twice.PoolExhaustedand terminal errors are not retried.ensure_partialcreated a.partialwith no.rangesrecord. A later drive'sopen_or_createthen truncated the spliced donor bytes, forcing a full-price self-heal. It now creates a real ranged store. A regression test fails without the fix (mutation-checked).#2063: the prelude's first open is the drive's first leg
PrimedSourceparks a live pull. The drive's first open of exactly that(hash, AlignedRange)adopts it.finishdrains and pays to stream end.first_legshares oneleg_rangehelper with the Draw arm, so the primed range always equals the range the drive would open.(0,0)open. It is adopted only when the first gap is the whole blob. A resume drops it, as before.probe_admitted_totalstill drops its size probe, because the scheduler's first unit is a segment, never(0,total). The node'shandshake_total_bytesis also unchanged.#2119: one warm session per entry, concurrent ranges
RangeSessionreplacesdrive_ranges.CtxRangeDriverkeeps one session per provider across every drive of an entry: complement, re-fetch, deferred fallback, self-heal.PeerSource::with_warm_connection()dials once and opens every pull as a new stream on that connection. It redials if the connection has closed, and retries an open once if the connection closed under it. An open sends no voucher, so the retry is money-safe.drive_range_setmerges the gaps of all ranges and fills them up to--max-lane-streamsat once. It uses one interval flush, one final flush (on failure too) and onefinalize.SharedPool, gaps stay serial, so the top-up budget cannot multiply.LaneStreamCap::try_extra, so they cannot deadlock againstpermit_set.#2120: drive-level throughput floor
throughput_watchdog(client-pull) runs the existingThroughputFloorover a caller's counter, with a pause flag.watched_drivewrapsdrive_fetchand everyRangeSessiondrive. It applies the same--min-throughput-bps/--stall-timeout-msfloor, measured on the drive's position across every leg and the gaps between them.PausingFunderstops the clock from a top-up until the next byte lands.EntryStalled(RetryElsewhere), flushes the present record the dropped drive skipped, and fails over.-v, each drive logs position, rate and ETA every 10 s, and each entry logs its size, time and effective rate when it finishes.Risks worth a look
fill_gap, which the multi-source scheduler already uses. The existing billing e2e and the new one both assert exact wire billing.max_topupsand the working-deposit ceiling.Tests
walk_candidates: success, terminal, exhaustion failover, context.entry_retryable, backoff,run_with_retries(paused clock).ensure_partialtruncation.try_extra.drive_range_set: concurrent (peak in flight between 2 and 4), merged gaps, serial without a pool, stop on fault.first_leg: fresh, resume, ceiling, all present.PrimedSource: adopted, mismatch, clear, stale.EntryWatch,PausingFunder,watched_drive.cli_bundle_pull_drives_a_scattered_complement_concurrently. 24 donor chunks interleaved with unique tails give about 25 complement ranges. It runs with--max-lane-streams 4and asserts byte-exact output and exact complement billing.-D warnings --all-targetspasses, includingdecdn-e2e --features anvil-e2e.-D warningspasses.nextest -p decdn-cli -p decdn-client-pull -p decdn-common --all-features: 1604 pass.-p decdn-node: 1245 pass.node_to_node_pull_through::upstream_hash_mismatch_is_rejectedflaked (failed, then passed on retry) in 2 of 5 full-suite runs on this branch and 0 of 4 onmain, wheresilent_upstreams_do_not_starve_the_candidate_loopflaked once instead. It passes alone. Its path (open_progressive_pull→decode_to_vec) touches no changed code. The failure is the lying upstream's own write or read hittingconnection lost, which looks like a race with the requester's early close. I did not prove that it is unrelated.Not yet confirmed on testnet. Re-running the gpt-oss
bundle pull -vshould show:original/model.safetensorscomplement finishing in minutes;Review follow-ups (6c14310, eab658a)
Drive-level floor
finalize's local re-hash of a complete blob, so a paid multi-GB download could fail asEntryStalled. The drop it caused could also race an older record write.drive_range_setnow takes astopfuture that races only the gap work. The pending flush lands and the final flush runs;finalizeis never timed.FetchPrelude::drive_watched/settle_drive.Money safety
SharedPool::topup_lock, backed by the run'sLaneLedgers::topup_lock. The waiting gap re-reads the deposit. This stops a double escrow, and without--max-approveatopUpreverting on a spent allowance.open_or_createusestry_exists, so a failed stat never truncates a paid.partial.--max-lane-streams.Error handling
PoolExhausted); the others are logged.Types, tests and docs
SessionWalkwith a fake-driven test suite;EntryWatch::begin_topup;GroupRun::fetch_failed;PreludeLeg.PeerSourceon one connection (node loopback);open_or_createstat failure;1 + complementopens, so no open is thrown away.Local: workspace clippy
-D warnings --all-targets --all-features, rustdoc-D warnings, 3,328 unit and node tests, and 12 anvil e2e all pass.🤖 Generated with Claude Code