Repository navigation
fix(node,client): dial pull-leg upstreams on the main runtime so SIGTERM never hangs - #2187
Conversation
…ERM never hangs A serve-miss pull leg runs on a throwaway current-thread runtime. An upstream dial made there spawned the connection's QUIC driver on that runtime, which dropped with the leg, so the connection never reached draining and `Endpoint::close` parked `router.shutdown()` until systemd SIGKILLed the node, skipping the redeem sweep, lane flush, receipt tail and cache close. - decdn-client: `connection::dial` runs the connect on a caller-chosen runtime (abort-on-drop, span-instrumented; a panicked or cancelled dial task is a `LocalPullFault`). `PeerSource::with_dial_runtime` replaces `with_dial_observer`/`DialObserver`; `open_progressive_pull` and `WarmConnection::connect` take `dial_runtime`. - decdn-node: `NodeOriginDeps.dial_runtime` (the main runtime) is used by every `PeerSource` the node builds. The abandon-drain wait, its counter `decdn_node_pull_abandon_drain_timeout_total` and its dashboard series are removed. `close_router` bounds the router close by `SHUTDOWN_DEADLINE` and logs an error when it gives up. - tests: test-support `shutdown` fails on a teardown breach (it only warned, which hid this hang in CI); new dial / close_router / strict teardown tests; the node-to-node e2e now SIGTERMs the server. Closes #2185 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Two unresolved moderate findings must be addressed before approval.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Fixes node shutdown hangs by routing upstream dials to the main runtime and bounding router shutdown.
Changes:
- Adds caller-selected dial runtimes and updates the client API.
- Removes abandon-drain handling and metrics.
- Strengthens teardown checks and adds SIGTERM regression coverage.
Review findings:
- Moderate: the e2e log assertion may pass before detached tee threads flush the router-timeout error (4 votes).
- Moderate: router-close failures no longer have a replacement metric or dashboard signal (1 vote).
| File | Summary |
|---|---|
monitoring/grafana-dashboard.json |
Removes obsolete drain metric panel. |
monitoring/dashboard-delivery.json |
Removes obsolete drain metric panel. |
crates/node/tests/support/mod.rs |
Makes teardown breaches fatal. |
crates/node/tests/support_teardown.rs |
Adds strict teardown tests. |
crates/node/tests/probe_loopback.rs |
Restores real-time teardown clocks. |
crates/node/tests/node_origin_pull.rs |
Updates dial runtime usage. |
crates/node/tests/dht_integration.rs |
Uses strict endpoint teardown. |
crates/node/tests/client_loopback.rs |
Updates warm connection API usage. |
crates/node/src/runtime/mod.rs |
Adds bounded router shutdown. |
crates/node/src/node_origin/pull_leg.rs |
Routes pull-leg dials to the main runtime. |
crates/node/src/node_origin/mod.rs |
Wires the main runtime dependency. |
crates/node/src/node_origin/abandon_drain.rs |
Removes obsolete drain workaround. |
crates/node/src/metrics.rs |
Removes obsolete drain counter. |
crates/e2e/tests/node_to_node_coalesce.rs |
Adds SIGTERM shutdown coverage. |
crates/e2e/src/node.rs |
Adds daemon termination support. |
crates/e2e/Cargo.toml |
Adds signal dependency. |
crates/client/tests/snapshots/public_api__public_api.snap |
Regenerates the public API snapshot. |
crates/client/src/source.rs |
Stores and propagates the dial runtime. |
crates/client/src/lib.rs |
Updates pull dial plumbing. |
crates/client/src/connection.rs |
Implements runtime-bound dialing. |
CHANGELOG.md |
Documents runtime and API changes. |
Cargo.lock |
Updates dependency metadata. |
.config/nextest.toml |
Updates teardown documentation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit f69b7e3 in the Show a line coverage summary of the most impacted files.
Updated |
…ate returns The stdout/stderr tee threads were detached, so a child's exit did not order its last lines into the captured log: the SIGTERM stage's negative check for a router give-up line could read the log before the line landed. `DaemonLog` now keeps its reader handles, and `NodeFixture::terminate` returns only once both have read to EOF. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
On the overview's second finding ("router-close failures no longer have a replacement metric or dashboard signal"): leaving this as a log line on purpose. |
…estore HTTP keep-alive (#2308) * fix(cache): run origin request sends on the node's main runtime and restore HTTP keep-alive (#1675) A serve-miss pull leg runs on its own current-thread runtime, which drops when the leg returns. hyper spawns a pooled connection's dispatch task, its pool-return task and the pool's idle reaper onto whichever runtime polls the request send. A connection opened by one pull leg therefore died with that leg's runtime, and a concurrent serve that reused it lost its in-flight request ("dispatch task is gone", #1673). HttpOrigin worked around this with pool_max_idle_per_host(0), which paid a fresh TCP and TLS handshake per request. S3Origin kept its shared hyper pool with no workaround, so the race was still live for S3 origins. Both origins now capture the runtime they are built on (IoRuntime, the node's main runtime via build_cache) and run every request send there, following the dial_runtime pattern from #2187. The response body stays on the caller's runtime: hyper feeds it through a channel. HttpOrigin drops the keep-alive workaround. New tests in crates/cache/tests/origin_runtime_keepalive.rs cover both backends against a raw keep-alive server. Two pull legs on throwaway runtimes share one connection, and a leg mid-body survives the runtime drop of the leg that opened its connection. All four fail with the spawn bypassed: a second connection, an error, or a hang. Closes #1675 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(cache): harden origin IoRuntime faults and cover every origin send path (#1675) Review follow-ups for the origin IoRuntime change: - A task the shut-down main runtime cancels is a permanent fault. A shut-down runtime cancels every later spawn, so retrying only waited out the budget and raised a false "retry budget exhausted" error. - A panicking request task keeps its JoinError (task id and panic message) as the error source and logs at error level. - HttpOrigin's headers timeout runs on the caller's runtime, so it also fires when the owning runtime stops polling the send. - S3 task faults name the operation (GetObject / HeadObject). - IoRuntime uses tokio-util's AbortOnDropHandle (workspace tokio-util gains the `rt` feature). - The keep-alive tests run every sending operation (fetch, range, outboard, size) as the connection opener, for HTTP and S3, against a server that honours Range; in-flight tests cover fetch and range. Each leg has a deadline, and a leg that fails early surfaces its own error. Bypassing any one S3 send site fails its matching test. - Docs: pull-leg runtimes drop when the leg returns; idle connections are reaped normally, it is the owning runtime that lives with the node; S3Origin::from_parts is not test-only; constructor `# Errors` sections. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(cache): document the origin runtime contract on S3Origin::new and list it as breaking (#1675) S3Origin::new documents that its pooled connections live on the runtime it runs on and that it fails outside a tokio runtime. The constructor changes move from Fixed to Changed (BREAKING) in the changelog. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>

What
decdn-nodehung inrouter.shutdown()on SIGTERM on every node that had done a node-to-node pull since boot, until systemd SIGKILLed it at the 5-minute stop timeout — skipping the final redeem sweep, lane-store flush, receipt tail andcache.shutdown.Root cause: serve-miss pull legs run on a throwaway current-thread runtime. An upstream dial made there spawned the connection's noq
ConnectionDriveron that runtime; when the leg returned the runtime dropped, the driver died before the connection reached draining, and iroh'sEndpoint::close→wait_all_draining()waited forever. The old abandon-drain wait covered only the cancel/error paths, so its counter read a false zero.connection::dialruns the connect on a caller-chosen runtime — abort-on-drop, instrumented with the caller's span; a dial task that panics or is cancelled by its runtime shutting down is aLocalPullFault, never the peer's.PeerSource::with_dial_runtime(Handle)replaceswith_dial_observer/DialObserver;open_progressive_pullandWarmConnection::connecttakedial_runtime: Option<&Handle>(public-API snapshot regenerated).NodeOriginDeps.dial_runtime(the main runtime) is used by everyPeerSourcethe node builds, handshakes included. Theabandon_drainmodule,decdn_node_pull_abandon_drain_timeout_totaland its two dashboard series are removed.close_routerbounds the router close bySHUTDOWN_DEADLINEand logs anerror!when it gives up, so redeem/flush/cache close always run.shutdownnow fails on a teardown breach (it only warned). New tests for the dial (+ strand control), abort-on-drop, dial on a shut-down runtime, warm dial,close_router(+ control), strict teardown. Thenode_to_node_coalescee2e now SIGTERMs the server and requires a clean exit with no router give-up line.Closes #2185
Reviewer notes
crates/client/src/connection.rs(dial), thencrates/node/src/node_origin/{mod.rs,pull_leg.rs}andclose_routerincrates/node/src/runtime/mod.rs.mainCI runs,window_pull_through_handshake_is_the_first_pull_legloggedteardown exceeded 15s (… 1/3 endpoints closed)— the success-path strand — and passed because teardown only warned. With this PR it stays clean, and a recurrence now fails. That test also moves to a multi-thread runtime.window_pull_through_*error-path tests; reverting the populate-thread dial failsnode_origin_oversized_blob_aborts_on_received_bytes_without_scoring.systemctl stop decdn-nodeon fra1/lon1 after deploy.support_teardowncases, and three oversubscribed runs (32 threads) of the teardown-heavy suites were clean.cache/src/origin/http.rs) is untouched and stays open.Verification
cargo fmt -- --checkcargo clippy --workspace --all-targets -- -D warnings(clean). Not run with--all-features: theanvil-e2etargets carry pre-existing warnings; the files this PR touches under that feature (crates/e2e/src/node.rs,node_to_node_coalesce.rs) lint clean.cargo nextest run --workspace— 4149 passedcargo nextest run -p decdn-client --features public-api-test --test public_api— passed (snapshot regenerated)RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemscargo nextest run -p decdn-e2e --features anvil-e2e --test node_to_node_coalesce— passed (server stops in ~100 ms)CHANGELOG.mdentries added (Fixed + Changed (BREAKING) for thedecdn-clientAPI)contracts/changed — n/afixwith a lowercase subject🤖 Generated with Claude Code