Skip to content

fix(node): stop a live stream as soon as its pool turns Closing - #3006

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/stream-closing-logic-ca0ad7
Nov 26, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/stream-closing-logic-ca0ad7

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Problem

The mid-stream pool re-check (#2812) kept serving a Closing pool until its dispute deadline came inside the redeem margin. With the default 48h window, a stream that started before initiateClose could keep running for almost two days. Admission already refuses any Closing pool, so a client that reconnected was refused anyway.

Change

  • pool_recheck_stop holds the admission rule for the whole stream: a pool that is not Open (or that the view no longer holds) stops the stream as ServeStop::PoolClosed, with PoolExhausted on the wire. It no longer reads the dispute deadline or inside_expiry_margin.
  • Rotating a pool means draining it, not closing it under live streams. Stopping at Closing leaves the node the whole dispute window to redeem what it holds; the periodic sweep (at most 6h) runs many times inside it.
  • ADR 003, ADR 005, the observability appendix and the PoolClosed / metric docstrings now describe the rule. decdn_serve_stream_midstream_pool_closed_total now also flags owners who close under live streams.

Tests

  • Unit: a Closing pool stops at its deadline and two days before it; the margin-boundary test is gone.
  • Loopback: the cache-hit, serve-miss and slow-payer Closing tests use a far deadline (u64::MAX) and still stop in-band. The "Closing a day out serves to StreamEnd" test is removed: that behaviour is gone.
  • cargo nextest run -p decdn-node: 1623 passed. Clippy --all-targets --all-features -D warnings, fmt and cargo doc with warnings denied are clean.

Makes #3004 / #2813 (a redeemer wake at the close deadline minus the margin) unnecessary.

🤖 Generated with Claude Code

The mid-stream pool re-check holds the admission rule for the whole
stream: a pool that is not Open stops the stream. A Closing pool takes no
top-up, so its owner is winding it down; rotating a pool means draining
it, not closing it under live streams. Stopping at Closing leaves the node
the whole dispute window to redeem what it holds, so the re-check no
longer reads the dispute deadline or the redeem margin.

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

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main e720fbb claude/stream-closin... a0e85ab +/-
78% 78% 0%
View coverage of the 5 most impacted files.
File main e720fbb claude/stream-closin... a0e85ab +/-
crates/protocol/src/framing.rs 93% 92% -1%
crates/client/src/lib.rs 89% 89% 0%
crates/client/s...undle/engine.rs 51% 51% 0%
crates/node/src...gin/pull_leg.rs 84% 84% 0%
crates/node/src...s/client/mod.rs 89% 89% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@alpergundogdu
alpergundogdu merged commit 5ae6c96 into main Nov 26, 2026
36 checks passed
@alpergundogdu
alpergundogdu deleted the claude/stream-closing-logic-ca0ad7 branch November 26, 2026 17:38
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.

1 participant