Skip to content

fix(node,cache): let a serve-miss pull draw for its parked leg past a sibling's demand - #2219

Merged
alpergundogdu merged 3 commits into
mainfrom
claude/serve-miss-demand-behind-frontier
Sep 28, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
claude/serve-miss-demand-behind-frontier

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

  • Bug: a serve-miss pull stops drawing when another stream for the same blob waits further down. Every serve leg's demand went to every live fill of the hash as one high-water mark (fetch_max). A sibling's far demand hid the leg parked at this pull's frontier, the WindowPacer treated the demand as "not blocked on this pull", paced to Wait, and both legs waited on each other until the client's 30 s stall timer. No WARN fires, because each sibling demand move restarts the pause.
  • Fix (decdn-cache): Demand keeps one standing demand per serve leg and reads the nearest. Each serve leg holds a DemandSlot that routes its demand only to the live fill whose covered range holds the awaited byte, and withdraws it once the leg moves again or ends. DownstreamWatch::past wakes on any change of the nearest demand.
  • decdn-node: the coherent frame producer stands its demand while starved and withdraws it when encoded bytes flow again.
  • ADR 037 and the pacer/serve-leg docs updated. decdn-client's public API is unchanged (doc-only edit on DownstreamFrontier::serve_demand).

Evidence (testnet, 2026-09-28)

  • Tempo trace 25b99fa1928371c8be9dd767f3f3ac89 (lon1, proxying 7cbb… for a bundle pull): the stream's pull drew 6 legs from bcl (~1 MiB each, 10:07:40.9–10:07:47.0), bcl completed all 6, then lon1 opened nothing for 31 s. upstream_stream idle 37.4 of 37.5 s, outcome cancelled. The client logged upstream stalled: no progress for 30s and failed over.
  • lon1 held none of the blob at the start (the client chose it as a non-holder), and no other stream overlapped the range. Concurrent lon1 streams for the same hash further down (bcl served lon1 a leg at 13,126,057,984 at 10:07:46) supplied the masking demand.
  • A single-stream replay (4.66 GB pinned to lon1) and gap/held/gap layouts in a local harness did not stall, which is consistent with needing a sibling fill.

Test plan

  • RED then GREEN: fill_session::…::a_sibling_fills_far_demand_does_not_hide_a_near_one (the near fill saw the sibling's 6G instead of its own G).
  • RED then GREEN: pull_leg::downstream_wait_tests::a_full_window_draws_for_its_parked_leg_despite_a_far_sibling (WindowPacer returned Wait; now draws PULL_WINDOW_FLOOR).
  • New: a_fill_reads_its_nearest_standing_demand, demand_reaches_the_live_fill_that_produces_the_byte, a_nearest_demand_change_wakes_a_parked_pull_and_a_farther_one_does_not; rewrote the tests that pinned the high-water behavior.
  • cargo nextest run --workspace: 4216/4216 passed.
  • cargo clippy --workspace --all-targets --all-features, cargo fmt --check, RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items clean.
  • cargo test --no-run -p decdn-e2e --features anvil-e2e builds.

🤖 Generated with Claude Code

… sibling's demand

Every serve leg's demand went to every live fill of the hash as one
high-water mark. A sibling stream parked further down the same blob raised
it past a pull's frontier, so the leg parked AT that frontier could no
longer ask for its one-floor draw: the pull paced to Wait, the serve leg
waited on the pull, and neither moved until the client's 30 s stall timer.
On the testnet lon1 proxying 7cbb… stopped drawing after 6 legs and the
client failed over (Tempo trace 25b99fa1928371c8be9dd767f3f3ac89).

- decdn-cache: `Demand` holds one standing demand per serve leg and reads
  the nearest. A `DemandSlot` per serve leg routes its demand only to the
  live fill whose covered range holds the awaited byte, replaces it on each
  park, and withdraws it on demand or drop. `DownstreamWatch::past` wakes
  on any change of the nearest demand. `FillSession::demand_up_to` is gone.
- decdn-node: the coherent frame producer stands its demand while starved
  and withdraws it once encoded bytes flow again or the encode ends.
- ADR 037 and the pacer/serve-leg docs describe the per-leg demand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 28, 2026 11: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

🟢 Approval recommended

The functional changes are well-scoped, covered by targeted new regression tests, and I only found minor comment-style nits.

Review effort: Lite
Findings: 2 Low severity

Open (2)
What changed in this PR

This PR fixes a deadlock-style stall in node pull-through serving when multiple concurrent streams for the same blob create competing downstream “serve demand” signals. The change makes serve demand per-serve-leg (with explicit stand/withdraw semantics) and ensures each pull reacts to the nearest relevant demand for the bytes it can actually produce, preventing a far sibling demand from masking a near parked leg.

Changes:

  • Replace the “single high-water mark” serve-demand behavior with per-leg DemandSlots routed to the live fill that produces the awaited byte, and have pulls read the nearest standing demand.
  • Update node coherent serving so the frame producer stands demand only while starved and withdraws it as soon as encoded bytes flow again (or on drop).
  • Update downstream wakeup semantics + documentation (node docs, client pacer docs, ADR 037, changelog) and add/adjust regression tests.
File Description
crates/​node/​src/​node_origin/​pull_leg.rs Updates downstream-wait tests and adds a regression test for the “far sibling demand masks near parked leg” case.
crates/​node/​src/​handlers/​client/​serve_leg.rs Documentation update describing per-leg demand slot semantics and nearest-demand wakeups.
crates/​node/​src/​handlers/​client/​serve_encoder.rs Switches coherent frame producer from publishing a monotonic demand to standing/withdrawing per-leg demand via DemandSlot.
crates/​client/​src/​pacer.rs Updates DownstreamFrontier::serve_demand semantics/docs to “nearest standing demand” (node-side) while remaining 0 on client path.
crates/​cache/​src/​lib.rs Re-exports Demand and DemandSlot as part of decdn-cache API surface.
crates/​cache/​src/​fill_session.rs Implements Demand + DemandSlot, replaces FillSession::demand_up_to, changes watch wake condition to “served_paid advances OR serve_demand changes”.
CHANGELOG.md Adds a release note describing the stall fix and the internal API change in decdn-cache.
adr/​037-regional-proxy-warming.md Updates ADR narrative to match new serve-demand routing/nearest-demand behavior.

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

Comment thread crates/cache/src/fill_session.rs Resolved
Comment thread crates/node/src/node_origin/pull_leg.rs Resolved
@github-code-quality

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

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 8aca17b in the claude/serve-miss-de... branch remains at 86%, unchanged from commit ece7897 in the main branch.


Updated September 28, 2026 12:09 UTC

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