Repository navigation
fix(node): fail a recovery top-up at once while a topUp settle holds the slot - #2497
Merged
Merged
Conversation
…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
There was a problem hiding this comment.
🟢 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
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 6 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two follow-ups from the #2492 review, sharing one piece of state.
settle_unconfirmed_top_upholds the top-up slot, a funding recovery step fails at once withTopUpHeld, markedLocalPullFault. Before this, it joined the settlingtopUpand waited until its deadline dropped it.top_up_pool_by's recovery closure, so everytop_up_at_leastiteration hits it. It also sits inrecover_pool's sibling wait (recovery_in_flight).join_or_spawn_topupstays infallible, so a refill still joins and does nothing. The refill logs its funding line only when it spawns thetopUp.top_up_at_leastreturns that headroom instead of failing the fill.topUpbefore 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, whereunless_heldalso fails earlier joiners.OpenHoldbecomesSlotHold, which carries the gauge it publishes (SlotHold::open()/SlotHold::top_up()). Itdebug_assert!s a single holder.decdn_buyer_topup_unresolvedgauge.HeldGuardclears it on drop, so an aborted funding task clears it too.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/devopsPR 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_byfails on its first poll withTopUpHeld+LocalPullFault, spawns nothing, and claims nothing.a_recovery_fails_at_once_while_a_refill_settles: the common production path throughrecover_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_outcometop_up_at_least_held_call_before_any_landing_fails,top_up_at_least_held_call_after_a_landed_join_returns_what_landedan_aborted_top_up_settle_clears_the_gaugetopUpend-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 docwith warnings denied, and pre-commit are green.Closes #2493
Closes #2494
🤖 Generated with Claude Code
https://claude.ai/code/session_0123DU1V2G3UnrwF2o9g4XHa