Skip to content

fix(cache,node): close the two-leg spine residuals from the #2064 review - #2162

Merged
thiras merged 4 commits into
mainfrom
feat/2069-two-leg-spine-residuals
Sep 26, 2026
Merged

thiras merged 4 commits into
mainfrom
feat/2069-two-leg-spine-residuals

Conversation

@yigitdot

@yigitdot yigitdot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What

Closes the four residuals the #2064 review collected in #2069.

  1. Encode-task panic → typed internal fault. OriginRangeWire::spawn catches the encode's unwind (catch_unwind, writer kept outside so the channel still closes only after the verdict is parked) and parks the new CacheError::Internal carrying the panic message (also used for a broken reader invariant and a closed permit pool). UnfinishedGuard covers cancel. The own-origin pull leg logs an Internal fault in the error chain at error! as a code bug; a Store fault (e.g. disk full) keeps the local-origin warning.
  2. Saturation and wait signals.
    • decdn_cache_range_pull_permit_waits_total counts draws that find the MAX_CONCURRENT_RANGE_PULLS pool full; a wait past 10 s logs one warning.
    • decdn_node_pull_through_wait_seconds records the length of each pacer pause (window full or min draw) in DownstreamWait; a pause past 30 s logs one warning. The client crate is unchanged (PacingWait is the seam).
    • Registry rows in adr/appendix-observability.md; dashboard targets in monitoring/dashboard-delivery.json.
  3. No-Range origin degrades before signing. New CacheEngine::origin_range_serviceable replaces origin_fetch_outboard_bytes in dispatch: outboard present AND a ranged read of the first chunk group succeeds. false falls through to the buffered whole-blob populate (ADR 037 fallback), Err hits the Reactive pull-through: a hard origin/store fault terminates as a signed CacheMiss (NotFound), not InternalError — both tiers #1129 fault latch. A per-origin origin_range_confirmed latch, keyed on the origin that served the outboard (set by any clean first window, probe or draw), makes the range read free after the first success. A wrong-length first window advances the origin chain. The origin-walk loop is factored out of origin_range_wire into open_range_cursor, shared by both.
  4. Duplicate egress on refused attach: resolved by analysis. The proposed "attach when the overlap is already present" rule buys nothing: the refused request's own fill computes its gaps from store.missing_ranges at start, so an already-present overlap is never re-fetched. The only duplicate is overlap not yet in the store, which is exactly where attaching starves. The rule stays; fill_not_coalesced now counts once per claim and only when the skipped session's covered range overlaps the request (previously per skipped session, disjoint ones included).

Closes #2069

Reviewer notes

  • Read first: crates/cache/src/engine.rs (origin_range_serviceable, open_range_cursor, range_pull_permit), then crates/cache/src/origin_range.rs (spawn, park_panic).
  • Cost of item 3: one ≤16 KiB ranged GET per origin, the first time it serves a cold own-origin miss in a process; latched afterwards. It can re-read a chunk group the node already holds (partial_serve shows this).
  • Test churn: 10 tests in origin_range_pull.rs and one in partial_serve.rs mocked only the exact Range header of the draw, so the probe GET 404'd and the node degraded. They now mount the probe via mount_range_probe, and GET counts exclude the probe header. no_range_origin_after_outboard_success_fails_cleanly (which pinned the old sign-then-fail behavior) is replaced by no_range_origin_degrades_to_buffered_before_signing.
  • The latch never clears: an origin that later drops Range fails a draw like any mid-life origin fault (documented on the field).
  • Wait timers use tokio::time::Instant so the paused-clock test measures the real pause.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo nextest run -p decdn-cache -p decdn-node --no-fail-fast — 1777 passed
  • cargo nextest run -p decdn-cli -p decdn-client — 1214 passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items — clean
  • contracts/ changed — n/a
  • User-visible change: CHANGELOG.md entry added
  • Design change: adr/appendix-observability.md registry rows added/updated
  • PR title uses an allowed type

🤖 Generated with Claude Code

yigitdot and others added 2 commits September 25, 2026 19:59
- Encode-task panic: the range-wire encode catches its own unwind and parks
  a CacheError::Store carrying the panic message; UnfinishedGuard now covers
  cancel only. The own-origin pull leg logs a Store fault in the chain as an
  internal fault (error!), not as a local-origin fault.
- Observability: decdn_cache_range_pull_permit_waits_total counts draws that
  find the range-pull pool full, with a warning past 10 s; the pacer hook
  records decdn_node_pull_through_wait_seconds per pause and warns once past
  30 s. Registry rows and dashboard targets added.
- No-Range origin: origin_range_serviceable probes the first chunk group
  before the node signs, so an origin that publishes {H}.obao4 but declines
  Range degrades to the buffered whole-blob pull. A per-origin latch makes
  the probe free once an origin has served a clean range window.
- Refused attach: an already-present overlap is never re-fetched (the owner's
  gaps come from missing_ranges), so no smarter attach rule helps without
  reintroducing starvation. fill_not_coalesced now counts once per claim and
  only when the skipped fill overlaps the request.

Closes #2069

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 25, 2026 18:41

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-code-quality

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

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit b7f25b3 in the feat/2069-two-leg-sp... branch is 86%. The line coverage in commit ce98e34 in the main branch is 85%.

Show a line coverage summary of the most impacted files.
File main ce98e34 feat/2069-two-leg-sp... b7f25b3 +/-
crates/cache/src/engine.rs 94% 94% 0%
crates/cache/sr...fill_session.rs 96% 96% 0%
crates/client/src/scheduler.rs 95% 95% 0%
crates/node/src...gin/pull_leg.rs 89% 90% +1%
crates/node/src...ent/dispatch.rs 81% 82% +1%
crates/cache/sr...origin_range.rs 87% 88% +1%

Updated September 25, 2026 22:06 UTC

yigitdot and others added 2 commits September 26, 2026 00:11
- Add CacheError::Internal for code bugs (caught encode panic, broken
  reader invariant, closed permit pool). The own-origin pull leg flags only
  Internal as a code bug; a store fault such as a full disk stays Store.
- Key the range-probe latch on the origin that served the outboard, not on
  the outboard cache, which never holds an empty outboard (blobs of one
  chunk group) or one over 256 MiB. The probe hands that outboard to the
  cursor, so it no longer reads an uncacheable outboard twice.
- A wrong-length first window advances the origin chain instead of
  shadowing a healthy later origin.
- Record a pull pause's length from a drop guard, so a cancelled pause is
  observed too; log full error chains; debug-log a range decline.
- Tests: small-blob latch, range-declining and short-first-window origins
  ahead of a healthy one, permit wait past the warning, a range-probe
  timeout refusing InternalError, and the degrade test tied to the probe.
- Docs: ADR 037 serviceability and fallback conditions, stale comments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yigitdot

Copy link
Copy Markdown
Contributor Author

Addressed the review findings in b7f25b3:

  • Internal-fault signal was too broad. CacheError::Store also carries store faults (disk full, iroh-blobs I/O), which were logged as a code bug. Added CacheError::Internal for caught panics, broken invariants and a closed permit pool; is_internal_fault matches only that.
  • Probe latch missed small and huge blobs. It keyed through the outboard cache, which never holds an empty outboard (blob ≤ 16 KiB) or one over 256 MiB, so those blobs re-probed on every miss and the large ones read the outboard twice. The latch now keys on the origin that served the outboard, and the probe hands that outboard to the cursor.
  • A wrong-length first window from one origin no longer shadows a healthy later origin; the chain advances.
  • Pause histogram records from a drop guard, so a cancelled pause is observed. Full error chains are logged, and a range decline is debug-logged.
  • Tests added: small-blob latch, range-declining and short-first-window origins ahead of a healthy one, permit wait past the warning, a range-probe timeout refusing InternalError, and the degrade test now asserts exactly one probe read.
  • Docs: ADR 037 serviceability/fallback conditions, stale comments, CHANGELOG.

Gate: clippy --all-targets and cargo doc -D warnings clean; cache/node/cli/client: 3045 passed.

Note: the HTTP adapter maps any non-206 ranged answer (a 500 included) to a clean decline, so an HTTP 5xx on the probe degrades rather than latching fault_seen. That is pre-existing adapter behavior; the new fault test uses a read-budget timeout.

@yigitdot
yigitdot requested a review from thiras September 26, 2026 13:54
@thiras
thiras merged commit dd30114 into main Sep 26, 2026
30 checks passed
@thiras
thiras deleted the feat/2069-two-leg-spine-residuals branch September 26, 2026 18:26
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.

two-leg spine residuals from the #2064 review

3 participants