Repository navigation
Description
Summary
The Rust test CI job can hang indefinitely (no panic, no error — the test binary just never returns) on the test decdn-node::node_origin_pull::a_probe_cache_hit_drops_a_provider_no_longer_admitted (crates/node/tests/node_origin_pull.rs:12249). This is a flaky, scheduling-sensitive pre-existing deadlock in the node-origin pull-leg teardown — not caused by any particular PR.
It was surfaced by PR #1708's CI (run 32071318012, test job): every other job went green, but test sat on the "Run tests (with coverage instrumentation)" step for ~59 min — the single test above was SLOW-labelled every 60s (escalating >180s … >3120s) while all 2673 other tests finished — until the job was cancelled. PR #1708 is a red herring (details below); re-running its test job will very likely pass.
Root cause
The wedge is an iroh Endpoint::close() hang on a stranded upstream QUIC connection, exactly the hazard the abandon-drain in crates/node/src/node_origin/pull_leg.rs:608-626 is meant to prevent:
// pull_leg.rs:608
// Abandon drain. On cancel the `drive` future above is dropped
// mid-transfer, which queues an upstream `Connection::close` (via
// `UpstreamPull::drop`) but does NOT drive it to completion. That connection's
// QUIC driver lives on THIS pull-thread current-thread runtime, which the caller
// (`window.rs`) drops the instant we return. Without a drain the close frame is
// never flushed: the connection is stranded with no driver, so it can never reach
// "closed or timed out", and the node's own `Endpoint::close()` … would wait forever …
if cancelled || result.is_err() {
tokio::time::sleep(ABANDON_DRAIN).await; // ABANDON_DRAIN = 3s
}The node-origin pull leg runs drive on a dedicated OS thread with its own current-thread runtime. On cancel/error the dropped drive future only queues the upstream Connection::close; the CONNECTION_CLOSE must be flushed on that pull-thread runtime before it is torn down. The mitigation is a fixed ABANDON_DRAIN = 3s sleep (pull_leg.rs:83). Under heavy CI parallelism (coverage instrumentation + many concurrent tests), that fixed-duration drain loses the race: the sleep elapses (or the pull-thread runtime is starved) before the close frame actually flushes, the connection is stranded with no driver, and the test's teardown ep_a.close().await / ep_b.close().await (e.g. node_origin_pull.rs:1275-1276) then waits forever with every tokio worker idle.
Reproduction & evidence
- The hung test is unambiguous in the CI log: it is the only test that never produced a result on job 95515004450.
- Reproduced locally under artificial CPU saturation (6 busy loops on 4 cores): the test wedges ~1 in 3–9 runs. A gdb attach shows the runtime parked in
Runtime::block_onat the test'sep_*.close().awaitteardown with all tokio workers idle. - In isolation / normal load it passes reliably (~0.5s; ~37s for the full binary in parallel), which is why it is rarely seen.
This affects main, not just PR #1708
- The same stress reproduction wedges on
main(a11f1c4) too (~1/30), so the defect is independent of PR feat(payments): narrow wire voucher amount/bytes_delivered to u64 (#1705) #1708. - PR feat(payments): narrow wire voucher amount/bytes_delivered to u64 (#1705) #1708 (narrow voucher
amount/bytes_deliveredtou64) is behaviorally irrelevant here: the test moves ~1.5 MiB atRATE=10, so cumulative amounts are ~15 — orders of magnitude belowu64::MAX, round-tripping losslessly with no truncation. The conflict-merge invoucher.rs/client_loopback.rsdropped/duplicated no logic; it hung only because CI scheduling pressure happened to lose the drain race on that run.
Impact
- Intermittent multi-hour hangs of the
testjob → wasted runner time and false-looking "stuck" PRs, with the blame landing on whatever PR happened to run. - Because it reproduces on
main, any PR can hit it.
Suggested direction
The fix belongs in the pull-leg teardown, not in any caller:
- Replace the fixed 3s
ABANDON_DRAINsleep with a deterministic wait for the upstream connection to actually reach closed/timed-out (await the connection's close/closed()future with a bounded timeout) before the pull-thread runtime is dropped — so a starved scheduler can't let the drain "complete" while the frame is still unflushed. - Alternatively, drive the abandoned
Connection::closeto completion on the owning runtime explicitly rather than relying on a timed yield. - As a test-side stopgap, bound the teardown
Endpoint::close()with a timeout so a stranded connection surfaces as a failure instead of an infinite hang. (Mitigation only — the product-side race is the real bug.)
Related: #1714 (other main CI breaks — distinct, deterministic failures).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity