Skip to content

fix(node): fail a recovery top-up at once while a topUp settle holds the slot - #2497

Merged
thiras merged 2 commits into
mainfrom
fix/topup-settle-hold
Oct 17, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/topup-settle-hold

Conversation

@thiras

@thiras thiras commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two follow-ups from the #2492 review, sharing one piece of state.

  • fix(node): fail a recovery top-up at once while a topUp settle holds the slot #2494: fail fast. While settle_unconfirmed_top_up holds the top-up slot, a funding recovery step fails at once with TopUpHeld, marked LocalPullFault. Before this, it joined the settling topUp and waited until its deadline dropped it.
    • The check sits in top_up_pool_by's recovery closure, so every top_up_at_least iteration hits it. It also sits in recover_pool's sibling wait (recovery_in_flight).
    • join_or_spawn_topup stays infallible, so a refill still joins and does nothing. The refill logs its funding line only when it spawns the topUp.
    • If a later funding call finds the slot held after an earlier join already landed, top_up_at_least returns that headroom instead of failing the fill.
    • Deliberate: a recovery that spawned or joined the topUp before the settle began still waits for its outcome. Issue fix(node): fail a recovery top-up at once while a topUp settle holds the slot #2494 asks for this. It differs from the open path, where unless_held also fails earlier joiners.
  • feat(node): export a gauge while a topUp settle holds the top-up slot #2493: gauge. OpenHold becomes SlotHold, which carries the gauge it publishes (SlotHold::open() / SlotHold::top_up()). It debug_assert!s a single holder.
    • The top-up hold publishes the new decdn_buyer_topup_unresolved gauge. HeldGuard clears it on drop, so an aborted funding task clears it too.
    • Docs: a live row in adr/appendix-observability.md, a runbook entry that moves with the open-slot entry to after the Cause (2) procedure, and CHANGELOG entries.

The dashboard panel and alert go in a separate decdn/devops PR once a release ships the gauge, because devops only names released metrics.

Tests

New paused-clock tests in buyer_pool/tests.rs:

  • a_settling_top_up_refuses_a_recovery_at_once: top_up_pool_by fails on its first poll with TopUpHeld + LocalPullFault, spawns nothing, and claims nothing.
  • a_recovery_fails_at_once_while_a_refill_settles: the common production path through recover_pool. It makes no chain read and opens no replacement pool.
  • a_recovery_waiting_on_a_settling_sibling_fails_at_once: a recovery waiting on a sibling's settling recovery top-up fails the same way.
  • a_recovery_joined_before_the_settle_gets_its_outcome
  • top_up_at_least_held_call_before_any_landing_fails, top_up_at_least_held_call_after_a_landed_join_returns_what_landed
  • an_aborted_top_up_settle_clears_the_gauge
  • The settle harness and the dropped-topUp end-to-end test now assert that the gauge and the hold are set and then cleared.

Mutation checks: removing the hold checks and the hold() call fails 7 tests. Reverting the partial-result return fails 1, and removing the closure check fails 2.

cargo nextest run -p decdn-node: 1683 passed. Workspace clippy --all-features -D warnings, cargo doc with warnings denied, and pre-commit are green.

Closes #2493
Closes #2494

🤖 Generated with Claude Code

https://claude.ai/code/session_0123DU1V2G3UnrwF2o9g4XHa

…the slot

A funding recovery step that found the top-up slot held by
settle_unconfirmed_top_up joined the settling topUp and waited for the
whole settle, so each such cache miss spent its budget on every
candidate. The open path's hold (OpenHold) becomes SlotHold, which also
marks the top-up slot held while a topUp settles. A recovery caller that
finds it held fails at once with TopUpHeld, marked LocalPullFault, from
join_or_spawn_topup or from the sibling wait in recover_pool. A refill
still joins and does nothing; a recovery that joined before the settle
began still gets its outcome.

The hold publishes the new decdn_buyer_topup_unresolved gauge, cleared
by a drop guard so an aborted funding task clears it too. The ADR
observability appendix and the runbook describe it.

Closes #2493
Closes #2494

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0123DU1V2G3UnrwF2o9g4XHa
Copilot AI balanced review requested due to automatic review settings October 17, 2026 13:17
@thiras thiras self-assigned this Oct 17, 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.

🟢 Approval recommended

The targeted hold checks and gauge cleanup match the intended behavior, with regression coverage and no unresolved findings.

No open issues 🎉

What changed in this PR

Makes funding recovery fail immediately when an unresolved top-up holds the node’s funding slot, and exposes that state to operators.

Changes:

  • Adds fail-fast recovery checks while preserving existing waiters and refill behavior.
  • Shares hold tracking and drop-based gauge cleanup.
  • Adds regression tests and operator documentation.
File Description
docs/​runbook.md Explains unresolved top-ups and operator actions.
crates/​node/​src/​metrics.rs Exports the unresolved top-up gauge.
crates/​node/​src/​buyer_pool/​tests.rs Tests fail-fast behavior, existing waiters, and cleanup.
crates/​node/​src/​buyer_pool.rs Implements recovery checks and shared slot holds.
CHANGELOG.md Records recovery and monitoring changes.
adr/​appendix-observability.md Registers the new gauge and its meaning.

Review effort: Balanced

@github-code-quality

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

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main f06c246 fix/topup-settle-hol... 9532ae8 +/-
76% 76% 0%
View coverage of the 6 most impacted files.
File main f06c246 fix/topup-settle-hol... 9532ae8 +/-
crates/client/src/scheduler.rs 94% 94% 0%
crates/client/src/lib.rs 89% 89% 0%
crates/cache/src/engine.rs 91% 91% 0%
crates/node/src/metrics.rs 91% 91% 0%
crates/node/src/buyer_pool.rs 79% 80% +1%
crates/node/src...s/client/mod.rs 89% 90% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 17, 2026 13:43 UTC

- The recovery closure in top_up_pool_by checks the hold, so
  join_or_spawn_topup stays infallible and the refill drops no Result.
- top_up_at_least returns what an earlier join landed when a later
  funding call finds the slot held, instead of failing the fill.
- SlotHold::hold asserts a single holder in debug builds.
- The refill logs its funding line only when it spawns the topUp.
- Docs: the re-send needs USDC as well as gas; a restart leaves a larger
  on-chain deposit on the tracked pool, not a stranded pool; the
  PoolNotOpen exit; the refused-step counter; doc rot in recover_pool,
  top_up_pool_by and TopUpFunder::Refill. The unresolved-gauge runbook
  paragraphs move after the Cause (2) procedure.
- Tests: a held call before and after a landed join, a recovery while a
  refill settles, and the gauge on the dropped-topUp path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0123DU1V2G3UnrwF2o9g4XHa
@thiras
thiras merged commit f521155 into main Oct 17, 2026
31 checks passed
@thiras
thiras deleted the fix/topup-settle-hold branch October 17, 2026 13:46
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): fail a recovery top-up at once while a topUp settle holds the slot feat(node): export a gauge while a topUp settle holds the top-up slot

2 participants