Skip to content

fix(node,payments): close the floor-loss error-path and in-memory residuals - #1786

Merged
alpergundogdu merged 2 commits into
claude/issues-1781-1782-1783-iaxai2from
claude/pr-1784-review-lmmst6
Aug 24, 2026
Merged

alpergundogdu merged 2 commits into
claude/issues-1781-1782-1783-iaxai2from
claude/pr-1784-review-lmmst6

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

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_floor only warn!-logged a failed forget_loss. A failed forget leaves the closed pool's row with no tombstone, so a drop-dispatched record_loss still in flight can re-insert the row and nothing ever deletes it again — the exact #1781 outcome, through the error path. And floor_loss_persist_failures counted only record_loss failures, so DecdnFloorLossPersistFailures never saw this mode.

  • Failure outcomes now bump floor_loss_persist_failures and surface a corrupt payment store at error!, mirroring the drop-time persist closure.
  • Handling extracted to note_forget_outcome (also keeps clippy's cognitive-complexity lint quiet and makes the accounting unit-testable).
  • The metric's field/method docs, the registry row in adr/appendix-observability.md, and the alert comment + description now name both write paths.

In-memory resurrection (correctness)

release_live_repaid used entry(pool_id).or_default(): a repayment landing after forget_pool_floor removed the pool's entry re-inserted a default PoolFloorState for the closed pool — the in-memory face of the same race, which the drop guard already avoids via get_mut. Now get_mut here 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 property record_loss's in-transaction check relies on. One transaction instead of two at bring-up.
  • Two test docstrings reworded from changelog voice into present-tense counterfactuals (CLAUDE.md present-tense canon).

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 reaches decdn_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 warnings clean, cargo fmt -- --check clean, alerts YAML parses.

🤖 Generated with Claude Code

https://claude.ai/code/session_013d9kpLBeSy4kRmBazVEy7x


Generated by Claude Code

…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
Copilot AI lite review requested due to automatic review settings August 24, 2026 11:40

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.

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_outcome to ensure forget_loss failures increment floor_loss_persist_failures and surface corruption at error!, preventing the #1781 error-path leak from being silent.
  • Prevent in-memory PoolFloorState resurrection by switching release_live_repaid to get_mut (matching the drop guard’s semantics).
  • Simplify sweep_forgotten by 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_loss failures 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.

Comment thread monitoring/prometheus-alerts.yml Resolved
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
alpergundogdu merged commit a0758af into claude/issues-1781-1782-1783-iaxai2 Aug 24, 2026
@alpergundogdu
alpergundogdu deleted the claude/pr-1784-review-lmmst6 branch August 24, 2026 12:43
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]>
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.

3 participants