Skip to content

feat(node): meter floor-loss persist failures, surface redb corruption distinctly #1782

Closed

Description

@thiras

Found while reviewing #1780.

Gap

FloorReservation::drop persists the pool's dead charge best-effort and swallows every failure into one un-metriced line (crates/node/src/handlers/client/mod.rs:494-505):

if let Err(e) = store.record_loss(pool_id, micro) {
    tracing::warn!(%pool_id, error = %e, "floor dead-charge persist failed");
}

The sibling path is instrumented — lane_flush_failure() at crates/node/src/runtime/mod.rs:521,525 behind decdn_lane_flush_failures_total (crates/node/src/metrics.rs:470-471). The floor-loss path has nothing: grep floor crates/node/src/metrics.rs returns seven hits, all unrelated (pricing floor, cache-miss floor, refundable floor).

Why it matters now

redb 4.2 (landed in #1778) adds, per its changelog: "Harden against errors and panics raised part way through WriteTransaction::commit(): the database now refuses further write transactions until it is closed and reopened."

lanes.redb is shared by the lane flush and the floor-loss table. So a single failed lane-flush commit latches the whole file, and every subsequent record_loss then fails at begin_write. The node silently stops persisting dead charges for the rest of the process lifetime, emitting one un-metriced warn! per reservation drop.

On restart, load_losses hydrates a stale row set and every pool that accrued dead charge since the latch gets a fresh free-floor budget — the exact re-grant the table exists to prevent. Nothing alerts.

Proposal

  1. Add a floor_loss_persist_failures counter beside lane_flush_failures, incremented at both call sites (mod.rs:496 and mod.rs:502).
  2. Surface StorageError::Corrupted distinctly from a transient. It currently flattens into StoreError::Backend(String) alongside everything else, so "the payment database is corrupt" and "the disk was briefly busy" are indistinguishable at the call site. Either a dedicated StoreError variant or at minimum tracing::error! for the corrupt case.
  3. Log micro in both warns — the amount that failed to reach disk currently appears in no error string and neither warn.

Per the metrics convention, this is one unlabeled counter per reason rather than a reason label. monitoring/ and the observability appendix are name-gated by tests in metrics.rs, so the new name needs adding there too.

Activity

  1. added
    kind:feature
    prio:medium
    rust
    on Aug 24, 2026
  2. moved this from Backlog to In progress in deCDNon Aug 24, 2026
  3. moved this from In progress to Done in deCDNon Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:featureprio:mediumrust

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions