Repository navigation
fix(node,payments): close the floor-loss error-path and in-memory residuals - #1786
Merged
alpergundogdu merged 2 commits intoAug 24, 2026
Merged
alpergundogdu merged 2 commits into
alpergundogdu merged 2 commits into
Conversation
…iduals Review follow-ups on the #1781/#1782 fix: - forget_pool_floor: a failed forget_loss leaves the closed pool's row with no tombstone, open to permanent re-insertion by a late drop-dispatched record_loss — the #1781 leak through the error path. Count it under floor_loss_persist_failures so DecdnFloorLossPersistFailures covers this mode, and surface a corrupt payment store at error!, mirroring the drop-time persist. Outcome handling lives in note_forget_outcome; metric docs, the registry row, and the alert text now name both write paths. - release_live_repaid: get_mut instead of entry().or_default(), so a repayment that lands after forget_pool_floor removed the pool's entry cannot re-insert a default state for the closed pool — the in-memory face of the same resurrection race, which the drop guard already avoids. - sweep_forgotten: drop the separate read-transaction existence probe; the write transaction's no-op abort already rolls back table creation, the same property record_loss's in-transaction check relies on. - Reword two test docstrings into present-tense counterfactuals. - New tests: a repaid release after forget leaves the map untouched, and a failed forget bumps the persist-failure counter. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_013d9kpLBeSy4kRmBazVEy7x
There was a problem hiding this comment.
Pull request overview
This PR tightens the node’s payment-floor dead-charge accounting by closing two resurrection paths (durable and in-memory) around pool reclaim, and by aligning observability text with the fact that both record_loss and forget_loss failures are now part of the same operator-facing failure signal.
Changes:
- Add
note_forget_outcometo ensureforget_lossfailures incrementfloor_loss_persist_failuresand surface corruption aterror!, preventing the #1781 error-path leak from being silent. - Prevent in-memory
PoolFloorStateresurrection by switchingrelease_live_repaidtoget_mut(matching the drop guard’s semantics). - Simplify
sweep_forgottenby removing the extra read-txn probe and relying on the write-txn abort rollback behavior; update metrics/alert/docs wording and add targeted tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| monitoring/prometheus-alerts.yml | Updates the alert narrative to cover both persist and forget paths for dead-charge write failures. |
| crates/node/src/metrics.rs | Expands metric docs/recorder docs to describe both dead-charge write paths under the same counter. |
| crates/node/src/handlers/client/mod.rs | Fixes in-memory resurrection on repaid release; adds note_forget_outcome and tests for both scenarios. |
| crates/node/src/channel_store.rs | Streamlines sweep_forgotten to use a single write transaction with abort rollback for no-op sweeps. |
| adr/appendix-observability.md | Updates the observability registry row so the metric definition matches the new semantics. |
Suppressed comments (2)
monitoring/prometheus-alerts.yml:376
- The alert now covers both drop-time persists and reclaim-time forgets, but the annotation summary still says “persists”. Consider updating the summary to “writes” so the alert text matches the expanded scope.
Dead-charge totals are not reaching disk ("floor dead-charge
persist failed" in the logs), or a closed pool's row could not be
deleted and tombstoned ("pool dead-charge forget failed"). The
in-memory accumulator still bounds this process, but a restart
crates/node/src/metrics.rs:485
- This metric description’s “pairs with…” note still references only the drop-time log message. Since the counter now includes
forget_lossfailures too, the referenced log messages should include both persist and forget paths.
/// `lanes.redb` file refuses writes (a prior failed commit latches redb
/// until the file is closed and reopened — restart the node) or is corrupt;
/// pairs with the per-drop `warn!`/`error!` ("floor dead-charge persist
/// failed"). Operator-visible name:
/// `decdn_floor_loss_persist_failures_total`.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Review-bot follow-up on the failure-signal wording: the alert header and summary say "writes", not "persists", and both the alert comment and the counter's field doc cite the warn!/error! pair for the persist and forget paths. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_013d9kpLBeSy4kRmBazVEy7x
alpergundogdu
added a commit
that referenced
this pull request
Aug 24, 2026
…t failures (#1784) * fix(node,payments): tombstone forgotten floor-loss rows, meter persist failures Close the forget_loss/record_loss resurrection race (#1781): a FloorReservation drop snapshots its cumulative total under the floor lock, then persists it from an independent blocking task, so the write could land after forget_pool_floor's durable delete and re-insert a row for a closed pool — permanent since #1780 made record_loss monotonic. forget_loss now deletes the row and tombstones the pool id in one redb transaction, and record_loss checks the tombstone inside its own write transaction, making the late write a no-op. Handler bring-up sweeps the tombstones before hydration — the one point where no persist can be in flight — bounding their growth to one process lifetime. Instrument the drop-time persist (#1782): a new decdn_floor_loss_persist_failures_total counter fires on every failed record_loss, both dispatch paths log the µUSDC total that failed to reach disk, and redb corruption maps to StoreError::Corrupt and logs at error! — a corrupt or write-latched lanes.redb fails every later persist until the file is reopened, unlike a transient fault. Registry row in the observability appendix and a Prometheus alert added. Add the missing integration coverage (#1783): record_loss racing the lane flush on the shared redb file, two sequential drops through the real Drop guard driving the store's monotonic contract, the #1781 interleaving made deterministic with a gated store, and restart hydration distinguishable from overwrite semantics (the smaller total lands last). Closes #1781. Closes #1782. Closes #1783. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EtAhosYcK8HGWFRUCT2QfJ * docs(adr): anchor the ADR 003 pool-solvency cross-link in the metrics registry The appendix registry row for decdn_floor_loss_persist_failures_total linked 003-payments.md bare; the ADR reference-hygiene gate requires every cross-ADR link to carry a resolving #heading anchor. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EtAhosYcK8HGWFRUCT2QfJ * docs(node): correct tombstone-sweep comments in the floor-loss store The sweep's existence probe distinguishes "table never created" from "no tombstones" — any committed record_loss creates the table empty as a side effect of its in-transaction check — and the per-tombstone row removal is a defensive no-op, not a repair of leaked rows (a row without a tombstone is untouched by the sweep). Say both accurately, and keep forget_loss's no-early-return rationale in present tense. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EtAhosYcK8HGWFRUCT2QfJ * fix(node,payments): close the floor-loss error-path and in-memory residuals (#1786) * fix(node,payments): close the floor-loss error-path and in-memory residuals Review follow-ups on the #1781/#1782 fix: - forget_pool_floor: a failed forget_loss leaves the closed pool's row with no tombstone, open to permanent re-insertion by a late drop-dispatched record_loss — the #1781 leak through the error path. Count it under floor_loss_persist_failures so DecdnFloorLossPersistFailures covers this mode, and surface a corrupt payment store at error!, mirroring the drop-time persist. Outcome handling lives in note_forget_outcome; metric docs, the registry row, and the alert text now name both write paths. - release_live_repaid: get_mut instead of entry().or_default(), so a repayment that lands after forget_pool_floor removed the pool's entry cannot re-insert a default state for the closed pool — the in-memory face of the same resurrection race, which the drop guard already avoids. - sweep_forgotten: drop the separate read-transaction existence probe; the write transaction's no-op abort already rolls back table creation, the same property record_loss's in-transaction check relies on. - Reword two test docstrings into present-tense counterfactuals. - New tests: a repaid release after forget leaves the map untouched, and a failed forget bumps the persist-failure counter. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_013d9kpLBeSy4kRmBazVEy7x * docs(node): name both dead-charge log lines in the alert and metric docs Review-bot follow-up on the failure-signal wording: the alert header and summary say "writes", not "persists", and both the alert comment and the counter's field doc cite the warn!/error! pair for the persist and forget paths. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_013d9kpLBeSy4kRmBazVEy7x --------- Co-authored-by: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
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.
Review follow-ups for #1784, stacked onto its branch. The core tombstone fix stands; these close the residuals the review surfaced — two of them the same #1781 resurrection race, one layer out each.
Error path re-opened the leak (correctness)
forget_pool_flooronlywarn!-logged a failedforget_loss. A failed forget leaves the closed pool's row with no tombstone, so a drop-dispatchedrecord_lossstill in flight can re-insert the row and nothing ever deletes it again — the exact #1781 outcome, through the error path. Andfloor_loss_persist_failurescounted onlyrecord_lossfailures, soDecdnFloorLossPersistFailuresnever saw this mode.floor_loss_persist_failuresand surface a corrupt payment store aterror!, mirroring the drop-time persist closure.note_forget_outcome(also keeps clippy's cognitive-complexity lint quiet and makes the accounting unit-testable).adr/appendix-observability.md, and the alert comment + description now name both write paths.In-memory resurrection (correctness)
release_live_repaidusedentry(pool_id).or_default(): a repayment landing afterforget_pool_floorremoved the pool's entry re-inserted a defaultPoolFloorStatefor the closed pool — the in-memory face of the same race, which the drop guard already avoids viaget_mut. Nowget_muthere too: a reclaimed pool's live reservation went with its entry, so there is nothing to release.Minor
sweep_forgotten: the separate read-transaction existence probe is gone — the write transaction's no-op abort already rolls back table creation, the same abort-rolls-back propertyrecord_loss's in-transaction check relies on. One transaction instead of two at bring-up.Tests
repaid_release_after_forget_does_not_resurrect_entry— a repaid release on a reclaimed pool leaves the map untouched, and so does the subsequent drop.floor_forget_failure_bumps_the_counter— a failed forget reachesdecdn_floor_loss_persist_failures_total.Validation
cargo test -p decdn-node --lib— 717 passed (715 + 2 new);--test channel_state_store— 14 passed.cargo clippy --workspace --all-targets -- -D warningsclean,cargo fmt -- --checkclean, alerts YAML parses.🤖 Generated with Claude Code
https://claude.ai/code/session_013d9kpLBeSy4kRmBazVEy7x
Generated by Claude Code