Skip to content

fix(node): de-flake ranking, frame-read and duplicate-draw loopback tests - #2311

Merged
thiras merged 4 commits into
mainfrom
fix/flaky-node-origin-tests
Oct 5, 2026
Merged

thiras merged 4 commits into
mainfrom
fix/flaky-node-origin-tests

Conversation

@thiras

@thiras thiras commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Three intermittent decdn-node test failures, one commit each.

#2268: sub-ms probe RTT erases the price signal (product fix)

compute_score multiplies the rate by rtt_ms, and a probe faster than 1 ms truncates to 0. That has two effects:

  • Two loopback peers both score 0, so the tier-3 coin flip orders them.
  • A dear peer at 0 ms outranks every cheaper peer at 1 ms or more.

The score now uses max(rtt_ms, 1) (ADR 001 sentence + CHANGELOG). The floor is applied in compute_score, so cached candidates get it too.

The tests no longer depend on probe timing:

  • node_origin_not_found_refusal_does_not_tar_upstream now uses build_origin_seeded_ranking.

  • Three tests must rank on a live cold probe:

    • a_probe_cache_hit_still_honours_the_negative_cache
    • a_partial_cached_budget_falls_through_to_the_cold_path_and_meters_once
    • a_probe_cache_hit_still_honours_the_wedged_provider_filter

    Each pits rate 1 against RANK_LAST_RATE = 1000. PROBE_TIMEOUT is 500 ms and the floor is 1 ms, so two accepted probes differ by less than 500× in RTT. That makes the order provable under any load.

#2306: cancel-unsafe frame reads under timeout

support::BufferedClientReader keeps every byte it reads in a buffer that survives across calls, mirroring the node's BufferedProofReader. Three loops read the same stream again after a timeout, and they now use it:

  • window_pull_through_sliver_voucher_leaves_the_rest_owed
  • client_loopback::pay_range_to_end
  • client_loopback::pay_and_read_to_end

Sites that stop reading after a timeout are unchanged.

#2307: duplicate first draw after a throwaway teardown

The duplicate is documented product behaviour (PrimedSource), and the sibling torn-down test already allows it. The shared-fill test now accepts at most one repeat, and only of the draw that starts at byte 0. Every later draw must still be fetched once. A stale comment ("learns of it on its next write") now names send.stopped().

Verification

  • cargo nextest run -p decdn-node: 1561/1561 passed.
  • clippy --all-targets --all-features -D warnings and cargo doc -D warnings are clean.
  • Contention loop: 25 iterations of the affected tests plus binary(client_loopback) with --retries 0, each run alongside a concurrent full -p decdn-node suite. 25/25 clean, 158 tests per iteration.

Closes #2268
Closes #2306
Closes #2307

🤖 Generated with Claude Code

thiras and others added 3 commits October 5, 2026 10:10
…l rank on price

A probe faster than 1 ms truncates to rtt_ms = 0, which zeroes the
selection score for any rate. Two such peers tied whatever they quoted,
and a dear one outranked every cheaper peer at 1 ms or more. The score
now uses max(rtt_ms, 1) (ADR 001), applied in compute_score so cached
candidates get it too.

The loopback tests that rank on price no longer depend on probe timing:
the NotFound-refusal test seeds its ranking, and the three cold-path
tests quote rate 1 against RANK_LAST_RATE (1000), which outweighs any
RTT ratio two accepted probes can show (< 500x under PROBE_TIMEOUT).

Closes #2268

Co-Authored-By: Claude Opus 5.5 <[email protected]>
read_frame reads a varint length and then read_exacts the payload, so it
is not cancel-safe. Three test loops wrap it in a timeout and read the
same stream again after the timeout fires: under load a ChunkData frame
straddles the deadline, its prefix is lost, and the next read decodes
garbage (postcard decode error).

support::BufferedClientReader keeps every byte it reads in a buffer that
outlives each call, mirroring the node's BufferedProofReader. The
sliver-voucher test and client_loopback's pay_range_to_end and
pay_and_read_to_end read through it. Sites that stop reading after a
timeout are unchanged.

Closes #2306

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…way tears down first

When the throwaway open's client closes, its serve leg sees send.stopped()
at once, and the last-out lease release cancels the fill and aborts the
in-flight first draw. wiremock has already recorded that GET. A real open
that claims after the cancel owns a fresh fill and GETs the first draw
again: the one duplicate draw that PrimedSource documents and that the
sibling torn-down test already allows.

The shared-fill test now accepts exactly that: at most one repeat, of the
draw that starts at byte 0. Every later draw must still be fetched once.
The stale "learns of it on its next write" comment now names
send.stopped().

Closes #2307

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 5, 2026 07:36
@thiras thiras self-assigned this Oct 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The duplicate-draw assertion can mistakenly permit a repeated serviceability probe instead of only the aborted data draw.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Stabilizes node tests by preserving ranking signals, making timed frame reads cancellation-safe, and allowing the documented duplicate first draw.

Changes:

  • Floors ranking RTT at 1 ms and updates tests/docs.
  • Adds buffered client-frame reading for timeout loops.
  • Relaxes the throwaway-fill assertion for one duplicate initial draw.
File Description
crates/​node/​src/​selection.rs Applies the RTT floor and adds regression tests.
crates/​node/​src/​node_origin/​mod.rs Documents RTT truncation behavior.
crates/​node/​tests/​support/​mod.rs Adds the cancellation-safe frame reader.
crates/​node/​tests/​node_origin_pull.rs Stabilizes ranking and timed-read tests.
crates/​node/​tests/​client_loopback.rs Uses buffered reads across timeouts.
crates/​node/​tests/​origin_range_pull.rs Allows one repeated initial range.
adr/​001-network.md Documents the RTT floor.
CHANGELOG.md Records the ranking correction.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/node/tests/origin_range_pull.rs Resolved
…e draw

The probe range also starts at byte 0, so a doubled probe satisfied the
one-repeat exception for the aborted first draw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit abae6bd in the fix/flaky-node-origi... branch remains at 87%, unchanged from commit 461e726 in the main branch.

Show a line coverage summary of the most impacted files.
File main 461e726 fix/flaky-node-origi... abae6bd +/-
crates/incentiv...eth_identity.rs 99% 98% -1%
crates/client/src/scheduler.rs 95% 95% 0%
crates/node/src...s/client/mod.rs 95% 95% 0%
crates/cli/src/.../bundle_pull.rs 81% 81% 0%
crates/client/s...c/connection.rs 97% 97% 0%
crates/node/src...gin/pull_leg.rs 91% 91% 0%
crates/node/src/selection.rs 97% 97% 0%

@thiras
thiras merged commit 07be3bf into main Oct 5, 2026
30 checks passed
@thiras
thiras deleted the fix/flaky-node-origin-tests branch October 5, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants