Skip to content

Flaky deadlock: node-origin pull-leg abandon-drain races Endpoint::close(), hangs test job under CI load (node_origin_pull::a_probe_cache_hit_drops_a_provider_no_longer_admitted) #1718

Closed

Description

@alpergundogdu

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_on at the test's ep_*.close().await teardown 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

Impact

  • Intermittent multi-hour hangs of the test job → 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_DRAIN sleep 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::close to 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).

Activity

  1. added
    kind:bug
    rust
    kind:test
    on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:bugkind:testrust

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions