Repository navigation
fix(node,cache): let a serve-miss pull draw for its parked leg past a sibling's demand - #2219
Merged
Merged
Conversation
… 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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
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
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.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
6 tasks done
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.

Summary
fetch_max). A sibling's far demand hid the leg parked at this pull's frontier, theWindowPacertreated the demand as "not blocked on this pull", paced toWait, 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.Demandkeeps one standing demand per serve leg and reads the nearest. Each serve leg holds aDemandSlotthat 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::pastwakes on any change of the nearest demand.decdn-client's public API is unchanged (doc-only edit onDownstreamFrontier::serve_demand).Evidence (testnet, 2026-09-28)
25b99fa1928371c8be9dd767f3f3ac89(lon1, proxying7cbb…for abundle 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_streamidle 37.4 of 37.5 s, outcomecancelled. The client loggedupstream stalled: no progress for 30sand failed over.Test plan
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).pull_leg::downstream_wait_tests::a_full_window_draws_for_its_parked_leg_despite_a_far_sibling(WindowPacerreturnedWait; now drawsPULL_WINDOW_FLOOR).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-itemsclean.cargo test --no-run -p decdn-e2e --features anvil-e2ebuilds.🤖 Generated with Claude Code