Repository navigation
Description
Found while reviewing #1780, which made PoolFloorLossStore monotonic. The race predates that PR; what the PR changes is that it is no longer self-healing.
The interleaving
forget_pool_floor (crates/node/src/handlers/client/mod.rs:1616-1637) drops the in-memory entry, then dispatches the durable delete:
{ guard.remove(&pool_id); } // in-memory
tokio::task::spawn_blocking(move || store.forget_loss(pool_id)).await;FloorReservation::drop (mod.rs:455-500) reads its cumulative total under the same lock and then dispatches its own write:
let snapshot = { /* under self.map.lock() */ entry.dead_charge };
// ...
handle.spawn_blocking(move || store.record_loss(pool_id, micro));The early return at mod.rs:465 (guard.get_mut(&self.pool_id) → None → skip) closes most of the window. It does not close the case where a guard already took its snapshot under the lock and has not yet run its spawn_blocking. That record_loss can land after forget_loss commits, re-inserting the row.
Why it is now permanent
Before #1780 the store overwrote, so any later record_loss could correct the row downward. Now forget_loss is the only downward transition and it has already fired for this pool — no second one is coming, because the pool is closed. The resurrected row survives every subsequent boot.
Runtime::new hydrates unconditionally from load_losses() (mod.rs:1109-1125) and deliberately fails closed on error, so each leaked row becomes a permanent PoolFloorState entry for a pool that no longer exists.
Impact
Not mis-accounting: the doc at mod.rs:1614-1615 is right that a reclaimed pool_id never recurs (monotonic open nonce), so the stale dead_charge is never consulted for a real pool. It is unbounded state growth — one row per closed pool that hits the race, accumulating in lanes.redb and in the boot-time HashMap for the life of the node, with nothing that reclaims it.
Options
- Have
record_lossskip a pool that is absent from the live floor map (needs the map reachable from the store call site, or the check hoisted into the caller before dispatch). - Have
forget_losswrite a tombstone that a laterecord_lossrespects, swept at boot. - Await in-flight persists for a pool before
forget_loss— cleanest semantically, but needs per-pool tracking of dispatchedspawn_blockingwork.
No test covers the interleaving today; whichever route is taken should add one.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
fix(node,payments): close the floor-loss error-path and in-memory res…