Repository navigation
Description
Summary
Serve-miss pull legs run on ephemeral, per-serve current-thread runtimes that the orchestration drops the instant a serve finishes. Those runtimes own long-lived connection driver tasks (a task cannot outlive its runtime), so a connection first driven on one serve's runtime is stranded when that runtime is dropped — breaking a concurrent serve that shares it. We have now hit this on two transports, patched each locally. This issue tracks the real fix: give pull legs a stable, long-lived runtime so connection drivers never die mid-serve.
Why the per-serve runtime exists
decdn_client_pull::drive's fill future is !Send (the IngestStore fill is deliberately non-Send), which the iroh ProtocolHandler::accept bound forbids on the serve/accept task. So serve_via_window_pull_through / serve_via_backend_origin (crates/node/src/handlers/client/window.rs) each spawn a fresh OS thread with its own new_current_thread runtime and block_on the pull leg there. That runtime is dropped when the pull returns and the thread closure ends.
The two instances
-
HTTP origin (own-origin pull) — Flaky serve-miss coalescing tests under CI coverage contention (early-eof / peer hang, B3 #1656) #1673, fixed in this PR.
HttpOrigin(crates/cache/src/origin/http.rs) holds ONE sharedreqwest::Client(cloned across serves). reqwest's per-host idle keep-alive pool binds a connection's hyper dispatch task to the runtime that opened it. Two concurrent disjoint own-origin serves shared a pooled connection; when the first finished and its runtime dropped, the second's in-flight GET failed withclient error (SendRequest): dispatch task is gone: runtime dropped the dispatch task, which the paying client saw asread frame: early eof. CI coverage-starvation widened the drop-while-in-flight window (CI-only flake).
Workaround:pool_max_idle_per_host(0)— no idle connection is retained, so none is reused across runtimes. Correct, but gives up origin keep-alive (fresh TCP+TLS per request). -
QUIC upstream (peer pull) — the "abandon drain".
run_pull_leg(crates/node/src/node_origin/pull_leg.rs) already documents the same disease: a cancelled/erroreddriveleaves the upstream iroh connection's QUIC driver on the ephemeral runtime, which the caller drops immediately, so theCONNECTION_CLOSEis never flushed andEndpoint::close()could hang forever. Workaround: a fixedABANDON_DRAINsleep before returning, to let the connection flush on the runtime that owns it.
Both are point patches for the same architectural smell.
Proposed direction
Run pull legs on a single, long-lived runtime (or a small pool) owned for the node's lifetime, instead of a throwaway runtime per serve. Because drive is !Send, the natural shape is a dedicated current-thread runtime on its own thread that all pull legs are dispatched onto (e.g. via a LocalSet / an mpsc of boxed !Send local jobs constructed on that thread), rather than N ephemeral runtimes. With a stable runtime:
- the reqwest connection pool (and any iroh connection driver) lives as long as the node, so no mid-serve teardown strands anyone — we can restore origin keep-alive (drop
pool_max_idle_per_host(0)); - the QUIC abandon-drain sleep can likely be removed too;
- coalescing/lease/
set_pull_handlejoin semantics need re-thinking (today the last-out observer joins the pull thread; with a shared runtime there is no per-pull thread to join — cancellation + completion signalling viaFillSessionstill applies).
Alternatives considered and rejected for now: per-pull-leg reqwest::Client (isolates HTTP but not the general problem, and doesn't help QUIC); keeping per-serve runtimes but never sharing anything across them (fragile, easy to regress).
Not urgent
The two local workarounds are correct and low-cost at current scale (own-origin pulls fetch few, large ranges, so per-request handshake overhead amortizes). This is a cleanup/robustness item, not a live defect. Filing so the shared root cause is tracked rather than rediscovered on a third transport.
Acceptance
- Pull legs no longer run on runtimes that are dropped mid-connection-lifetime.
pool_max_idle_per_host(0)and theABANDON_DRAINsleep can both be removed with the disjoint-serve and endpoint-close no-hang tests still green.
References
- Flaky serve-miss coalescing tests under CI coverage contention (early-eof / peer hang, B3 #1656) #1673 (both flaky serve-miss classes), PR fix(node): window-pause lost-wakeup hang + instrument the serve-miss early-eof (#1673) #1674 (the two fixes + this analysis)
crates/node/src/handlers/client/window.rs(per-serve runtime spawn)crates/node/src/node_origin/pull_leg.rs(run_pull_legabandon-drain,run_local_pull_leg)crates/cache/src/origin/http.rs(pool_max_idle_per_host(0)workaround)
Activity
diag(node): remove DIAG#1673 instrumentation now both flakes are root…
fix(node): window-pause lost-wakeup hang + instrument the serve-miss …
thiras commentedon Aug 24, 2026
Counter-evidence for the "Not urgent … not a live defect" framing: the QUIC half of this (the
ABANDON_DRAINworkaround) is currently the single reason thetestjob goes red onmain.Three runs, two of them on
mainwith no PR involved, all withdecdn-node::node_origin_pull::a_wedged_channel_open_does_not_starve_the_candidate_loopburning the full 300 s nextest backstop while every other test passes:mainb68d4c05— job 97260091428mainb4a08d16— job 9703966920571fecd61— job 97275920605Filed as #1779 with the detail. One finding there is relevant to the acceptance criteria here: the test-side stopgap from #1718 is in place and fires (
shutdown: endpoint close timed out after 10s (0/4 drained)), yet the test still runs the full 300 s — so boundingEndpoint::close()relocated the wedge rather than removing it. The stable-runtime work proposed here looks like the actual fix.fix(node,client-pull): bound test teardown, observe the abandon drain (…
yigitdot commentedon Aug 26, 2026
Concrete sighting from the warn channel this issue relies on, recorded while working #1830.
Running
cargo nextest run --workspace --no-fail-fastlocally (14-core darwin, no coverage instrumentation),support::shutdownreports the stranded-driver signature on:0/M endpoints closedafter the tasks reaped cleanly is theEndpoint::close()half — the abandoned upstream connection's QUIC driver never forwarded the endpoint's draining event, exactly the mechanism described in the issue body. The test deliberately stalls a candidate, so it is a natural producer.It is intermittent and contention-dependent: three breaches on one full-workspace run, one on the next, and none on a
-p decdn-node-only run. The test passes either way — the breach only warns.Worth noting alongside it: #1832 raised
support::SHUTDOWN_TIMEOUTfrom 10s to 15s because it equalledABANDON_DRAIN_CAP(10s). With the two tied, a single ceilinged abandon drain could consume the whole test teardown budget before the firstep.close()was even attempted, and the warn line would then print0/M endpoints closedfor a run in which nothing was actually stranded. So readings from before that change are ambiguous between "stranded driver" and "ran out of budget getting there"; the sighting above is from after it, and is a true positive.No action requested here — filing the observation so this issue has a named reproducer rather than only the counter.
test(node): de-flake the DHT integration suite and unpin two teardown…
test(node,client-pull): close the #1832 review findings
test(node): de-flake the DHT integration suite and unpin two teardown…
test: make the stalled-close teardown test falsifiable and scale the …
test(node): cover the reaped half of shutdown's breach line
test: calibrate the watchdog deadline and pin shutdown's teardown rep…
thiras commentedon Sep 26, 2026
Production sighting: SIGTERM never completes, systemd SIGKILLs at the stop cap
First sighting of this outside CI. On a rolling restart of our 7-node testnet fleet (
main@3ebf5f17, iroh 1.0.0, systemdKillSignal=SIGTERM,TimeoutStopSec=300), 5 of 7 nodes never finished graceful shutdown and were SIGKILLed at the 300s cap.Timeline (2026-09-26, UTC)
graceful shutdown completeat 20:27:07.83 (0.27s)graceful shutdown completeat 20:32:11.14 (0.6s)closing router;State 'stop-sigterm' timed out. Killing.at 20:32:06–10Journal from one of the stuck nodes (lon1). Nothing between these two groups except
multiplexed_pollerlines:Where it's stuck
The chain poller kept logging
eth_getLogs window failed; retryingfor the full five minutes after SIGTERM (fra1: 20:29:31, 20:31:02, 20:31:32 …).poller.shutdown()is only called afterrouter.shutdown().awaitreturns (crates/node/src/runtime/mod.rs:2589at3ebf5f17), so the process was parked insiderouter.shutdown()for the whole window.No decdn
ProtocolHandleroverridesshutdown(), and iroh 1.0's router cancels the remainingacceptfutures before its next step. That leavesendpoint.close().awaitas the only unbounded await, which is the stranded-driver half described in this issue. Nodes that serve from their own origin or see no traffic exited cleanly, and the ones doing cache/peer-pull work hung.Caveat: I have no stack from a stuck process, so this is inferred from log ordering rather than proven. Peer-pull activity at INFO level was only visible on 3 of the 5 hung nodes (fra1, lon1, ash1; nbg1 and hel1 had none logged), so INFO logs alone can't confirm or rule out a stranded upstream connection on every hung node. Next time I'll try to capture
eu-stack/gdbbefore the cap.Why this is worse in production than in CI
In CI the breach only warns (
support::shutdownteardown budget). In production the hang sits in front of every durability step inshutdown(): the finalpayment_service.shutdownredeem sweep, thechannel_state_store.flush(), the receipt-writer tail flush (#803), the warming-creditor drain andcache.shutdown(). So the supervisor's SIGKILL skips exactly the flushes the generous stop timeout is there to protect. RaisingTimeoutStopSecdoesn't help because the wait is unbounded, and lowering it only makes the kill come sooner.The nodes restarted cleanly afterwards, so nothing visibly broke this time. But every restart of a node carrying a stranded connection currently costs the full stop cap plus a hard kill.
Until the stable-runtime fix lands, a cheap mitigation would be to bound
router.shutdown()with a timeout (as the post-routerdrainalready is withSHUTDOWN_DEADLINE) and warn on overrun. A stranded connection would then only cost the peer a QUIC idle timeout, instead of the node losing its final flushes.thiras commentedon Sep 27, 2026
A successful pull leg also strands its QUIC driver (
abandon_drain.rs"What is not covered"). That has a higher-impact effect now:router.shutdown()→Endpoint::close()→wait_all_draining()waits forever, so every testnet node that finished a node-to-node pull since boot gets SIGKILLed at the 5-min systemd timeout on each deploy. The SIGKILL skips the redeem sweep and the lane-store flush. Tracked in #2185, which also proposes boundingrouter.shutdown()independently of this fix.thiras commentedon Sep 28, 2026
The QUIC half of this is resolved by #2187 (closes #2185). Pull legs still run on per-serve current-thread runtimes, but every upstream dial now runs on the node's main runtime (
PeerSource::with_dial_runtime+NodeOriginDeps.dial_runtime), so each connection's QUIC driver outlives the leg. TheABANDON_DRAINwait (theabandon_drainmodule) and its counter are removed, androuter.shutdown()is bounded bySHUTDOWN_DEADLINE.Still open here: the HTTP half —
pool_max_idle_per_host(0)incrates/cache/src/origin/http.rs. A reqwest keep-alive connection still binds its hyper dispatch task to the per-serve runtime that opened it, so origin keep-alive stays off until pull legs get a long-lived runtime (or HTTP origin fetches move off the pull runtime the same way).docs(cache): document the origin runtime contract on S3Origin::new an…