Repository navigation
feat(node): split probe-hold refusal metric by cause — disabled vs exhausted (#739) - #754
Conversation
…hausted (#739) `ProbeHoldOutcome::BudgetExhausted` conflated two operationally distinct causes of a `has_blob: false` answer for a present blob: - `max_probe_holds == 0` — holds intentionally disabled by config - `max_probe_holds > 0` but every slot live — genuine budget pressure Both bumped `decdn_probe_hold_violations_total`, whose alert remedy is "increase max_probe_holds" — nonsensical (and a false alarm) when an operator has deliberately turned holds off. Split the outcome into `BudgetExhausted` (kept on `probe_hold_violations`, now a clean "raise the budget" signal) and a new `HoldsDisabled` variant counted by `decdn_probe_holds_disabled_total`. Each refusal path emits a structured debug log naming its cause. Holds are never pre-empted mid-flight (a held hash is invisible to the LRU driver), so the split is at the grant point, not on expiry. Updated appendix-observability.md (new counter row, corrected the violations description, cross-reference entry). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request distinguishes between probe holds refused due to genuine budget pressure (BudgetExhausted) and those refused because holds are intentionally disabled by configuration (HoldsDisabled when max_probe_holds == 0). This prevents intentional disables from triggering alerts meant for budget exhaustion. The changes update the ADR documentation, cache engine, probe handler, metrics, and tests. The review feedback highlights three key improvement opportunities: avoiding lock contention in the debug log by removing the redundant probe_hold_slots_used() call, optimizing performance by checking for disabled holds early before acquiring the lock, and removing an unused hashes vector in the test setup.
There was a problem hiding this comment.
Pull request overview
This PR refines probe-hold observability by separating “probe hold refused” events into two operationally distinct causes—holds disabled by config vs budget exhausted under load—so operators can distinguish intentional configuration from actionable pressure signals.
Changes:
- Split
ProbeHoldOutcome::BudgetExhaustedintoBudgetExhaustedvs newHoldsDisabled(max_probe_holds == 0) indecdn-cache. - Instrument
decdn-nodeto emit a new counterdecdn_probe_holds_disabled_total, keepdecdn_probe_hold_violations_totalfor true exhaustion, and add cause-specific debug logs. - Update loopback probe tests and the observability appendix to cover/describe the new metric and semantics.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
crates/node/tests/probe_loopback.rs |
Adds end-to-end tests asserting the correct counter increments for disabled vs exhausted probe-hold refusal. |
crates/node/src/metrics.rs |
Introduces probe_holds_disabled counter and a helper method to increment it. |
crates/node/src/handlers/probe.rs |
Maps HoldsDisabled vs BudgetExhausted to distinct counters and emits structured debug logs per cause. |
crates/cache/src/probe_hold.rs |
Extends ProbeHoldOutcome with HoldsDisabled and updates variant semantics docs. |
crates/cache/src/engine.rs |
Implements the new split outcome in try_probe_hold and updates cache-level tests. |
adr/appendix-observability.md |
Documents the new counter, updates probe_hold_violations semantics, and adds a canonical-name mapping entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 89.51% (was 89.49%, ▲ +0.02%) — 23826/26619 lines
History
|
…ck, doc/test cleanups Bot review (gemini-code-assist, Copilot): - engine: return `HoldsDisabled` early when `max_probe_holds == 0`, before the lock and fast path. Beyond skipping the O(N) sweep, this fixes a latent inconsistency: the fast path would refresh and re-sign an existing hold even with holds disabled, so a runtime `set_max_probe_holds(0)` didn't fully take effect. `max == 0` is now an unconditional "never sign has_blob:true". New test `runtime_disable_overrides_existing_probe_hold` covers it. - probe handler: drop `probe_hold_slots_used()` from the budget-exhausted debug log — it re-locked `probe_holds` + swept on the refusal hot path for a foregone ~`max` value (the gauge is already published once per probe). - docs/comments: update `try_probe_hold` doc and the handler match comment for the three-cause split; clarify the Slash-Safety section intro (counters vs gauges; violations is an availability signal, not a slash risk). - test: drop the unused `hashes` vector in `cache_with_two_blobs`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…fix stale docs Multi-agent review (code/tests/comments/errors/types): - Add `absent_blob_is_unavailable_even_when_holds_disabled` regression test (test-analyzer's one blocking gap): pins that the `max == 0` early return sits *after* `has()`, so an absent blob is `Unavailable`, not a `HoldsDisabled` config-disable event. Verified the test has teeth by temporarily reordering the checks (it failed), then reverted. - Fix stale `set_max_probe_holds` doc: `try_probe_hold` returns `HoldsDisabled` for a present blob, not "`false`". - Reframe the "config reload" framing in the early-return and test comments: `cache.max_probe_holds` is restart-required (not in the SIGHUP reload set), so the only post-startup caller is the test — the invariant is what matters, not a non-existent hot-reload path. - Document that the `max == 0` early return is slash-safe despite skipping the under-lock `is_evicted` re-check: a concurrently-evicted blob is still answered `has_blob: false`, so the misclassification is a metric-only miscount, never a phantom `true`. No behavior change beyond the added test. 509 tests pass, clippy + fmt clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ck, doc/test cleanups Bot review (gemini-code-assist, Copilot): - engine: return `HoldsDisabled` early when `max_probe_holds == 0`, before the lock and fast path. Beyond skipping the O(N) sweep, this fixes a latent inconsistency: the fast path would refresh and re-sign an existing hold even with holds disabled, so a runtime `set_max_probe_holds(0)` didn't fully take effect. `max == 0` is now an unconditional "never sign has_blob:true". New test `runtime_disable_overrides_existing_probe_hold` covers it. - probe handler: drop `probe_hold_slots_used()` from the budget-exhausted debug log — it re-locked `probe_holds` + swept on the refusal hot path for a foregone ~`max` value (the gauge is already published once per probe). - docs/comments: update `try_probe_hold` doc and the handler match comment for the three-cause split; clarify the Slash-Safety section intro (counters vs gauges; violations is an availability signal, not a slash risk). - test: drop the unused `hashes` vector in `cache_with_two_blobs`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Closes #739.
Problem
ProbeHoldOutcome::BudgetExhaustedconflated two operationally distinct reasons a node answershas_blob: falsefor a blob it actually holds:max_probe_holds == 0— the eviction-hold path is disabled by config (an operator decision).max_probe_holds > 0but every slot is live — genuine budget pressure.Both incremented
decdn_probe_hold_violations_total, whose alert remedy inappendix-observability.mdis "reduce load or increasemax_probe_holds". That remedy is nonsensical — and the alert a false alarm — when an operator has intentionally turned holds off. Operators couldn't tell a misconfiguration from real cache pressure, which is exactly what the issue asks for.Change
cache: splitProbeHoldOutcome::BudgetExhaustedintoBudgetExhausted(positive budget, all slots live) and a newHoldsDisabled(max == 0) variant.node: mapHoldsDisabledto a newdecdn_probe_holds_disabled_totalcounter; keepBudgetExhaustedondecdn_probe_hold_violations_total(now a clean "raise the budget" signal). Each refusal arm emits a structureddebuglog naming its cause.adr/appendix-observability.md: new counter row in Probe Metrics, correctedprobe_hold_violationsdescription, cross-reference entry.Checklist (from the issue)
reasonfield, matching the existing enum style).violationsnow only for genuine exhaustion; newprobe_holds_disabledcounter for the disabled case.appendix-observability.md.Testing
TDD throughout (watched each test fail first):
decdn-cache:probe_hold_disabled_when_budget_zeronow assertsHoldsDisabled, distinct from the sibling exhaustion test.decdn-node: two end-to-end probe tests assert the disabled and exhausted paths bump only their respective counter (the other stays 0).cargo nextest run -p decdn-cache -p decdn-node→ 507 passed.cargo clippy --all-targetsandcargo fmt --checkclean.Conflict avoidance
Contained to the
cache/nodeprobe-hold path. No overlap with the in-flight payment-channel PRs (#753, #752, #743), which live in node settlement +incentive.🤖 Generated with Claude Code