Skip to content

flaky: two_concurrent_pulls_to_one_provider_share_the_channel_ledger fails under coverage instrumentation #1826

Closed

Description

@yigitdot

decdn-node::node_origin_pull two_concurrent_pulls_to_one_provider_share_the_channel_ledger failed once on the coverage-instrumented test job, then passed on a plain re-run of the same commit.

Failing run: https://github.com/decdn/decdn/actions/runs/32906535499/job/97991821441 (commit 9e9733a)

FAIL [ 12.919s] (2813/3027) decdn-node::node_origin_pull two_concurrent_pulls_to_one_provider_share_the_channel_ledger
Error: the first concurrent pull returned NOTHING — its voucher collided with the other pull's on `prior_nonce + 1` and the upstream rejected it StaleNonce
  at ./tests/node_origin_pull.rs:9740:5

Two observations.

The runtime is the tell. The failing attempt took 12.9s; the same test takes ~0.7s locally and passed 40/40 in a local stress loop. It only fails on the test job, which runs under cargo llvm-cov instrumentation with the whole workspace in parallel — so whatever the cause is, it needs the pull path to be an order of magnitude slower than it is unloaded.

The message asserts a cause it does not verify. The anyhow::ensure! at crates/node/tests/node_origin_pull.rs:9740 fires on any OriginFetch that is not AlreadyAdmitted, but its text states flatly that the voucher collided on prior_nonce + 1 and was rejected StaleNonce. A pull that returns nothing because open_or_reuse_pool blew its 5s CHANNEL_OPEN_CALLER_BUDGET (crates/node/src/selection.rs:72) — the far more likely reading of a 12.9s run — reports the same sentence, which sends a reader hunting a ledger-sharing bug that may not be there. The 12.9s attempt is roughly two of those budgets.

Worth doing either way:

  • Make the failure distinguish the two outcomes, so the next occurrence says whether the upstream rejected a voucher or the pull never got a channel. OriginFetch::Nothing alone cannot carry that; the fixture already records retirements and settlements, and the PullMiss verdict is the thing that separates BelowMargin / PoolOpenPending from a real StaleNonce.
  • Then decide whether the underlying event is a genuine ledger-sharing race (BuyerLedgers::get_or_seed keys by LaneKey, and both pulls should resolve the same one) or just the caller budget expiring on a slow runner. The current message cannot tell you.

Not blocking anything right now — re-running the job cleared it.

Activity

  1. self-assigned this
    on Aug 26, 2026
  2. moved this from Backlog to In progress in deCDNon Aug 26, 2026
  3. moved this from In progress to Done in deCDNon Aug 26, 2026
  4. yigitdot commented on Aug 26, 2026

    @yigitdot
    ContributorAuthor

    Recurred on the coverage-instrumented test job, and this time the improved diagnostic from the fix paid off — it excludes both hypotheses it was written to distinguish.

    Sighting: run https://github.com/decdn/decdn/actions/runs/32943714091 (job 98105888611), on the merge of #1832 with main — a test-only PR that touches neither the pull path nor this file.

    FAIL [ 10.846s] (2816/3040) decdn-node::node_origin_pull two_concurrent_pulls_to_one_provider_share_the_channel_ledger
    Error: second concurrent pull returned NotFound (expected AlreadyAdmitted); AmountRegression would
    retire the channel and cap cumulative at one pull's wire bytes, while CHANNEL_OPEN_CALLER_BUDGET
    expiry increments node_pull_pool_open_pending_total and surfaces NotFound — check pending=0
    timeout=0 stalled=0
    recorded=[(0x08ae7a0806b2118825da10b14d5554e6a014db8e, 2627520, 26),
              (0x08ae7a0806b2118825da10b14d5554e6a014db8e, 2627520, 26)]
    retired=[]
    

    What the numbers say

    Healthy baseline, captured locally by printing the two derived constants on a passing run:

    single_wire=1578944  combined_wire=3157888
    entries=[(0x5983…, 3157888, 32), (0x5983…, 3157888, 32)]
    

    Against that baseline:

    healthy failing run
    recorded cumulative 3157888 (= combined_wire) 2627520
    third field 32 26
    retired [] []

    Three conclusions follow.

    1. Neither documented cause fired. retired=[] rules out AmountRegression (it would retire the channel). pending=0 rules out CHANNEL_OPEN_CALLER_BUDGET expiry, which is what the 12.9s runtime in the original report pointed at. timeout=0 stalled=0 too. This is a third mode, and the enriched message is what makes that visible — the old text would have blamed StaleNonce.

    2. The ledger sharing itself WORKED. The recorded cumulative is 2627520, which is strictly greater than single_wire (1578944). Two separate ledgers would each cap at 1578944; this one carried past it, so both pulls demonstrably drew on one ledger. The property the test exists to prove was holding at the moment it failed.

    3. The second pull aborted partway with NotFound, at a suspiciously round offset.

      2627520 − 1578944 = 1048576 = exactly 1 MiB
      

      So the first pull settled its full wire total and the second got exactly 1 MiB further before returning NotFound. The voucher count moved 26 vs 32 in step with it. An exact power-of-two boundary is not what CPU starvation looks like — it points at a window / interval boundary in the pull path rather than at a scheduling artifact, even though the trigger is still coverage contention.

    Reproduction status

    Not reproducible locally: 0/12 failures for this test under 16 spinning background loops on a 14-core darwin box, and it passes in ~1.3s there versus 10.8s on the runner. Same amplification gap the original report noted. The lead above comes from the numbers, not from a repro.

    Why this is reopened rather than fixed

    I hit this while getting #1832 (a flaky-test cleanup for #1830) green. It is not caused by that PR and the fix is not test hygiene — conclusion 3 suggests a real early-termination path in the pull leg, which deserves its own diagnosis rather than being absorbed into an unrelated branch.

  5. added
    kind:bug
    rust
    kind:test
    prio:medium
    on Aug 26, 2026
  6. removed their assignment
    on Aug 26, 2026
  7. yigitdot commented on Sep 1, 2026

    @yigitdot
    ContributorAuthor

    Closing: the flake is real, but the two conclusions that reopened this do not survive a read of the code, and the conditions behind both sightings are gone from main.

    The exact 1 MiB is forced by the fixture, not a lead

    CHUNK_BYTES == MB_BYTES == 1_048_576 is the protocol payment quantum (crates/protocol/src/client.rs:44-56): the buyer signs one voucher per chunk boundary, plus a closing voucher for the remainder. PAYLOAD_LEN is 1.5 MiB (crates/node/tests/node_origin_pull.rs:84), whose own comment says it "crosses one 1 MiB chunk plus a closing voucher".

    So the shared ledger can only ever read single_wire, single_wire + 1048576, or combined_wire. 2627520 is the only value available to "first pull complete, second pull past its one and only mid-stream boundary and short of its closing voucher". The amounts agree exactly: at RATE = 10 one pull costs 10 + ceil(530368 * 10 / MiB) = 16, so healthy is 32 and the failing 26 is 16 + 10 — one chunk voucher. A starvation-induced abort lands on that same round number, because settlement granularity IS 1 MiB. Conclusion 3 is withdrawn.

    "Neither documented cause fired" is a limit of the message, not evidence

    The assertion prints three counters. pull_verdict / classify_pull_error (crates/node/src/node_origin/mod.rs:2300-2440) carries about ten verdicts, and the rest meter counters the message never shows: node_pull_refused, node_pull_refused_unattributable, node_pull_voucher_rejected, node_pull_local_fault, node_pull_corruption, node_pull_unreachable. Every one of them reaches NotFound through miss_answer (mod.rs:708).

    The best fit is PullVerdict::Unreachable, the ladder catch-all for any error that is not a typed PullTimeout / PullStalled / UpstreamRefused / UpstreamVoucherRejected / HashMismatch — i.e. a raw transport failure, which is exactly what llvm-cov starvation produces on a live QUIC stream. Checked against the tree at the failing commit (eb9d1b2): that arm only calls record_outcome(.., Outcome::Unreachable), metering decdn_node_pull_unreachable_total, which the diagnostic does not print. SettleOnDrop has meanwhile persisted the watermark at the last chunk boundary. That reproduces the entire observation: recorded at 2627520, retired=[], pending=0 timeout=0 stalled=0.

    The three zeros therefore exclude two verdicts and leave eight unexamined. Not a third mode.

    Fixed since the last sighting

    No recurrence since.

    If it returns

    Widen the diagnostic rather than chasing the 1 MiB: dump every non-zero decdn_node_pull_* counter instead of three named ones, reusing the metrics.encode() scrape in counter_value (node_origin_pull.rs:1029) with a prefix walk. That also removes that helper reading an absent line as 0, which makes a renamed metric indistinguishable from one that never moved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:bugkind:testprio:mediumrust

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions