Skip to content

fix(client,node): keep an answered probe when the direct-path wait outruns the timeout - #2345

Merged
thiras merged 3 commits into
mainfrom
fix/2329-probe-grace-budget
Oct 6, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/2329-probe-grace-budget

Conversation

@thiras

@thiras thiras commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The non-holders in #2329 can fill the miss. fra1, nbg1, hel1 and lon1 all run node-to-node pull-through and found bcl through the DHT. They refused because their upstream probe of bcl timed out after bcl had already answered.

#2248 made probe_once wait up to 500 ms for hole punching to pick a direct path, and that wait ran inside the caller's timeout. The node probes its upstream with PROBE_TIMEOUT = 500 ms. So a cold dial that answered on the relay timed out during the wait and lost its answer. If that peer was the only full source, the node had no candidate and refused with NotFound. That covers both the unlogged pull_leg_miss refusals and the coverage-gate refusals with candidates=2 (only partial holders left).

Fix:

  • timeout bounds only the connect and the exchange. The direct-path wait gets what is left of the timeout, capped at 500 ms. A probe that has its answer keeps the exchange RTT when the wait runs out.
  • probe_once returns ProbeRtt { ms, direct } (public-api .snap regenerated). direct is false when no direct path was selected in time, so the RTT can be the relay detour.
  • The ADR 030 region-latency penalty still applies to a relay RTT: the peer controls whether hole punching succeeds, so exempting relay RTTs would let a spoofer escape the penalty. The node logs a relay RTT at debug and the penalty log carries direct, so an operator can tell the two apart. The CLI's probe answered debug line carries rtt_direct.
  • ADR 001 (probe collection, region penalty) and ADR 005 (probe RTT negative) describe this.

Evidence (testnet, 2026-10-06, fleet on the 10-05 05:06 build)

  • Every refusal in 08:46–09:06 counts as cache_miss: hel1 ~16, fra1 2, lon1 2, nbg1 1. There were no load-shed, signer-cap, chain-stale or origin-denied refusals.
  • fra1's refused 260a5c42 span (Tempo 1f981e0f…) shows dht_lookup providers=1 taking 334 ms. The refusal came ~650 ms later and was not logged.
  • decdn_node_pull_unreachable_total rose in the 08:47 minute on fra1 (2), nbg1 (2), hel1 (4) and lon1 (2), and on hel1 again at 09:00 and 09:05. A failed upstream probe scores Unreachable.
  • lon1 refused the issue's 11e20da0 @3288334336 example at the coverage gate with candidates=2.

Test plan

  • Paused-time tests on exchange_within: answered probe with no direct path (regression; fails with probe timed out after 500 ms on the old composition), the 500 ms grace cap under a 5 s budget, lower and higher direct RTTs, an answer exactly at the deadline, an exchange past the budget, and the rate-limit sentinel passing through. The cap and .min tests each fail under their mutation.
  • cargo nextest run -p decdn-node passes (1617).
  • cargo nextest run -p decdn-client -p decdn-cli passes (1480).
  • probe_loopback, probe_warm_reconnect and node_origin_pull pass (118).
  • cargo clippy --workspace --all-targets --all-features -- -D warnings, cargo fmt --check and the rustdoc gate pass.
  • Testnet: fleet redeployed to 4d0a9db2, Whisper large-v3 re-pulled with --namespace 1 (results in the comment below).

Not in this PR

Closes #2329

🤖 Generated with Claude Code

… the timeout (#2329)

probe_once waited up to 500 ms for hole punching to select a direct path,
and the wait ran inside the caller's timeout. The node probes its upstream
with a 500 ms PROBE_TIMEOUT, so a cold dial that answered on the relay
timed out in the wait and lost its answer. When that peer was the only
full source (bcl on the testnet), the node had no candidate and refused
the client's pull-through request with NotFound.

The timeout now bounds the connect and the exchange. The direct-path wait
gets only what is left of it, and a probe that has its answer keeps the
exchange RTT when the wait runs out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 20:11
@thiras thiras self-assigned this Oct 6, 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

🟢 Approval recommended

The focused implementation matches the documented behavior and covers the regression and timeout boundaries.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents completed probes from being discarded while awaiting direct-path selection.

Changes:

  • Separates exchange timeout handling from the optional direct-path RTT wait.
  • Adds paused-time regression tests and updates ADR 005.
File Description
crates/​client/​src/​probe.rs Preserves answered probes and tests timeout behavior.
adr/​005-protocol.md Documents the revised probe timeout semantics.

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

@github-code-quality

github-code-quality Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 4d0a9db in the fix/2329-probe-grace... branch remains at 88%, unchanged from commit 9990ad4 in the main branch.

Show a line coverage summary of the most impacted files.
File main 9990ad4 fix/2329-probe-grace... 4d0a9db +/-
crates/client/src/lib.rs 92% 92% 0%
crates/node/src...s/client/mod.rs 95% 95% 0%
crates/cli/src/.../bundle_pull.rs 81% 81% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/node/src...gin/pull_leg.rs 91% 91% 0%
crates/protocol/src/framing.rs 97% 97% 0%
crates/cli/src/...mmands/fetch.rs 76% 76% 0%
crates/node/src...e_origin/mod.rs 91% 91% 0%
crates/client/src/probe.rs 98% 98% 0%
crates/client/s...c/connection.rs 97% 98% +1%

Updated October 06, 2026 20:48 UTC

A probe that keeps its answer after the direct-path wait runs out reports
its exchange RTT, which can be the relay detour. probe_once now returns a
ProbeRtt { ms, direct }. The node skips the ADR 030 region-latency penalty
for an RTT with no direct path behind it, so an honest same-region peer
behind a distant relay is not scored as a region spoofer, and it logs the
relay case at debug. The CLI logs the flag beside each probe answer.

Review follow-ups: tests for the 500 ms grace cap, a direct RTT above the
exchange RTT, an answer at the deadline and the rate-limit sentinel;
docs for REGION_LATENCY_MAX_MS, PROBE_TIMEOUT, PROBE_SETTLE_AFTER_HOLDER
and the probe_once caller note; ADR 001 and ADR 005 wording.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras thiras changed the title fix(client): keep an answered probe when the direct-path wait outruns the timeout fix(client,node): keep an answered probe when the direct-path wait outruns the timeout Oct 6, 2026
The previous commit skipped the region-latency penalty when no direct
path backed a probe RTT. The peer controls whether hole punching
succeeds, so a region spoofer could refuse direct paths and never be
penalized. The penalty applies to every probe RTT again; the debug
lines carry `direct` so an operator can tell a relay reading from a
direct one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras

thiras commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Testnet result

The fleet and the CLI both ran 4d0a9db2. The fleet was deployed by ansible at 20:52 UTC on 2026-10-06. I then pulled Whisper large-v3 with --namespace 1: 6m34s, 20/20 fetched, 0 failed, downloaded 20.7 GB → reconstructed 24.7 GB, and the client logged no warnings.

08:47 run (old build) 20:54 run (this PR)
Non-holder NotFound lane faults (client) 3 1
decdn_node_pull_unreachable_total fra1 2, nbg1 2, hel1 4, lon1 2 in the refusal minute fra1 2, every other node 0
decdn_node_region_latency_penalty_total — 0
  • Cold starts: 6 entries started cold on 2–5 non-holder pull-through targets and filled from upstream.
  • The one remaining refusal: fra1 refused an extra stream on 31d02d58 with path=pull_leg_miss cause=clean_miss. Its upstream pull found no source for that range, which is a different cause from the dropped probe this PR fixes. The client re-queued the range, so no bytes were lost.
  • Noise from another client: in the same window the nodes refused about 54 requests from another client (peer 61db2111…, pool 0xdb5db1…). 51 of them were for 5ce7b3f9…. None of them belong to this run.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(node): bonded non-holders refuse a pull-through serve with NotFound instead of filling from origin

2 participants