Skip to content

fix(node): give an admit getPool fault a short negative-cache window - #2322

Merged
thiras merged 2 commits into
mainfrom
fix/2318-fault-negative-ttl
Oct 5, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/2318-fault-negative-ttl

Conversation

@thiras

@thiras thiras commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #2318.

The admit-path getPool negative cache in ResolvingPoolView::status held a pool for the full 60 s whether getPool answered "absent/closed" or merely failed / timed out. One slow read on a live, solvent pool refused every request on that pool for a minute, and the cache-hit path logged nothing.

  • Per-reason windows. Each entry records a NegativeReason: a Verdict (absent / Closed) keeps RESOLVE_VERDICT_TTL (60 s, renamed from RESOLVE_NEGATIVE_TTL); a Fault (RPC error or timed timeout) uses RESOLVE_FAULT_TTL (5 s). The cap-prune applies each entry's own window.
  • Coalesced reads. A 5 s fault window shorter than the 10 s read bound would let every request during a hung-RPC outage start and wait out its own getPool. Reads are now coalesced per pool (ReadSlot / InflightRead, a watch channel that closes when the read's guard drops): waiters re-check the projection and the negative cache the reader wrote, and a cancelled reader hands the read to a waiter.
  • Visibility. A cache hit logs its reason at debug; the fault WARN's suppressed_for names the 5 s window (its fix(node): bound admit-path chain reads and keep the RPC failure class in logs #2278 log test now asserts suppressed_for=5s).
  • Cap enforced. remember_negative skips an insert when the cache is still full after the prune, matching AUTH_CACHE_MAX; previously the map could grow past RESOLVE_NEGATIVE_CACHE_MAX.

Not in scope: a separate fault-refusal counter (the issue's optional item). PoolView::status returns Option<PoolStatus>, so the handler cannot tell why it got None; splitting the counter needs a trait change.

Test plan

  • cargo nextest run -p decdn-node — 1597 passed
  • cargo clippy --workspace --all-targets --all-features -- -D warnings, cargo fmt -- --check, RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • New tests: fault lapses before a verdict; per-reason prune; cap skip-insert; absent and Closed record Verdict and suppress past the fault window; RPC error records Fault; fresh fault suppresses the re-read; faulted live pool admitted after the RPC recovers; 8 concurrent requests → 1 getPool; waiter takes over a cancelled read
  • Mutation-checked: disabling coalescing, the Verdict record, fault suppression, the in-flight entry removal, or the cap skip each fails at least one test

🤖 Generated with Claude Code

The admit-path negative cache held a pool for the full 60 s whether
getPool answered "absent/closed" or merely failed or timed out. One slow
read on a live, solvent pool refused every request on it for a minute,
and the cache-hit path logged nothing.

Each entry records why it exists. A verdict keeps RESOLVE_VERDICT_TTL
(60 s); a fault uses RESOLVE_FAULT_TTL (5 s), so a live pool is admitted
again soon after the RPC recovers. A cache hit logs its reason at debug.

Admit getPool reads are coalesced per pool: a request that finds a read
in flight waits for it and re-checks the projection and the negative
cache, and a cancelled reader hands the read to a waiter. Without this a
fault window shorter than the 10 s read bound would let every request
during a hung-RPC outage wait out a read of its own.

The negative cache skips an insert when it is still full after the
prune, so it no longer grows past RESOLVE_NEGATIVE_CACHE_MAX.

Closes #2318

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 5, 2026 14:45
@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

A full negative cache causes coalesced waiters to repeat completed reads serially because no result is retained.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Splits getPool negative-cache windows by failure reason and coalesces concurrent pool reads.

Changes:

  • Uses 60-second verdict and 5-second fault TTLs.
  • Adds per-pool read coalescing and cache-hit diagnostics.
  • Expands tests for expiry, capacity, concurrency, and cancellation.
File Description
crates/​node/​src/​payment_settlement.rs Implements reason-aware caching, coalescing, and tests.
crates/​node/​src/​chain_events/​mod.rs Adds counted hanging-provider test support.

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

Comment thread crates/node/src/payment_settlement.rs Resolved
@github-code-quality

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

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 1b84cc1 in the fix/2318-fault-negat... branch is 88%. The line coverage in commit e2413d7 in the main branch is 87%.

Show a line coverage summary of the most impacted files.
File main e2413d7 fix/2318-fault-negat... 1b84cc1 +/-
crates/node/src/dht/publish.rs 92% 92% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/protocol/src/framing.rs 97% 97% 0%
crates/client/s...c/connection.rs 98% 98% 0%
crates/node/src...gin/pull_leg.rs 91% 91% 0%
crates/node/src...t_settlement.rs 89% 90% +1%
crates/node/src...n_events/mod.rs 98% 99% +1%

Updated October 05, 2026 15:09 UTC

Waiters re-derived the read's outcome from the projection and the
negative cache. When the cache was full of in-window entries the read's
negative was not recorded, so each waiter found nothing, started a read
of its own, and N concurrent requests ran N reads in turn.

The reader now sends its answer on the in-flight channel before it ends
the read, and a waiter returns it. A read that ends unanswered was
cancelled, so a waiter re-checks and takes it over.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit 5f5605d into main Oct 5, 2026
30 checks passed
@thiras
thiras deleted the fix/2318-fault-negative-ttl branch October 5, 2026 15:19
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.

node: a getPool fault negative-caches a live pool for the full 60 s verdict TTL

2 participants