Repository navigation
perf(node): split the lane store into per-family redb files (#1795 item 3) - #1880
Merged
Merged
Conversation
…em 3) One `lanes.redb` held every durable write family behind a single redb write-transaction slot, so unrelated commits serialized: the periodic lane flush, a settlement checkpoint, a floor-loss write on abnormal stream end, and a buyer top-up all queued on one writer. Give each family its own redb file under `data_dir`, each with its own writer slot: - lanes.redb — lane frontier + capability rows (shared flush txn) - settle.redb — seller + buyer pending-settle sets - floor-loss.redb — dead-charge totals + forget tombstones (shared txn) - checkpoint.redb — settlement-watcher scan checkpoints - buyer.redb — buyer pool state + owner index The families were already committed in independent transactions, so there is no cross-family atomicity to preserve — splitting changes crash semantics for none of them, it only removes the writer-slot serialization between them. The only intra-file multi-table transactions are lane+capability and floor-loss+tombstone; both stay co-located. Factor the per-file open into `open_hardened_db` (the #527 empty-file guard, TOCTOU-safe create, and 0o600 tightening), called once per family with lanes.redb first so the #527 fault-injection tests still name it. `open_with` takes `Fn` (called five times) instead of `FnOnce`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Splits the node’s previously single lanes.redb durable state into multiple per-“write family” redb files under data_dir, so unrelated durable commits no longer serialize behind one redb writer slot. This targets background-task contention identified in #1795 item 3 (hot-path audit), while keeping the existing per-family crash/atomicity semantics.
Changes:
- Refactors
PersistentPoolStateStoreto open/manage 5 separate redb files (lanes,settle,floor-loss,checkpoint,buyer) and routes each table family to its dedicatedDatabase. - Adds shared hardened-open helper (
open_hardened_db) and updates chmod hardening/tests to cover all family files. - Updates docstrings and operator-facing observability text to reflect the new per-family file layout and failure modes.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/node/src/channel_store.rs | Core refactor: split store into per-family redb Databases; add hardened open helper; update durability/docs and tests for new file set. |
| crates/node/src/runtime/mod.rs | Update runtime wiring comment to match per-family file commits under a single concrete store handle. |
| crates/node/tests/channel_state_store.rs | Rename/update concurrency test doc to reflect the lane-flush vs floor-loss split across files. |
| crates/node/src/metrics.rs | Update metric documentation to point to floor-loss.redb as the likely latching/corruption locus for floor-loss persist failures. |
| crates/node/src/handlers/client/mod.rs | Update test comment to reference floor-loss.redb instead of the formerly shared file. |
| crates/incentive/src/buyer_pool_table.rs | Update documentation about where the node’s buyer table is persisted (buyer.redb). |
| crates/incentive/src/buyer_pool_redb.rs | Update module docs to reflect node buyer persistence in its own file and independent writer slot. |
| adr/appendix-observability.md | Update observability appendix to reference floor-loss.redb (not shared lanes.redb) for sustained floor-loss persist failures. |
Suppressed comments (1)
crates/node/src/channel_store.rs:630
- This backend-open error also hard-codes "lane state store file" but can now refer to any of the per-family DB files. Using a generic name (or including the family filename) will make failure reports clearer.
"failed to open lane state store file at {}: {err}. \
Removing the file forfeits its durability guard \
— restore from backup or investigate the corruption.",
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…em 3 review) `open_hardened_db` opens every per-family file, but the empty-file and open-failure messages said "lane state store file", which reads as misleading when settle/floor-loss/checkpoint/buyer is the one truncated. Say "redb store file" and lean on the path (which already names the file); the #527 note stays scoped to lanes.redb explicitly. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 82.28% (was 82.27%, ▲ +0.01%) — 69275/84194 lines
History
|
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.
Closes #1795 item 3 (Group H hot-path audit).
Problem
One
lanes.redbheld every durable write family behind a single redb write-transaction slot, so unrelated commits serialized on one writer: the periodic lane flush, a settlement checkpoint, a floor-loss write on abnormal stream end, and a buyer top-up all queued behind each other. A durability burst anywhere back-pressured every other subsystem's durable writes.Fix
Give each write family its own redb file under
data_dir, each with its own writer slot:lanes.redblane_state_v1+capability_v1settle.redbpending_settle_v1+buyer_pending_settle_v1floor-loss.redbpool_floor_loss_v1+..._forgotten_v1checkpoint.redbwatcher_checkpoint_v1buyer.redbbuyer_pool_state_v3+..._owner_index_v3The families were already committed in independent transactions, so there is no cross-family atomicity to preserve — splitting changes crash semantics for none of them; it only removes the writer-slot serialization between them. The only intra-file multi-table transactions are lane+capability and floor-loss+tombstone, and both stay co-located.
Notes on the issue text
Two of item 3's bullets were stale by the time this landed:
Implementation
open_hardened_db(the incentive: no replay-protection window enforced on incoming voucher nonces, allowing a client to resubmit a previously accepted voucher after a node restart and receive a second byte-delivery for the same payment #527 empty-file guard, TOCTOU-safecreate_new, and0o600tightening with the fresh-vs-preexisting cleanup asymmetry), called once per family.lanes.redbopens first so the incentive: no replay-protection window enforced on incoming voucher nonces, allowing a client to resubmit a previously accepted voucher after a node restart and receive a second byte-delivery for the same payment #527 fault-injection tests still name it.open_with'schmod_fnis nowFn(called five times) instead ofFnOnce.channel_store,runtime,metrics, the floor-loss handler doc,incentive/buyer_pool_{redb,table}, andadr/appendix-observability.md.record_loss_races_the_lane_flush(was..._on_the_shared_file) and reworked its doc; extendedfile_mode_is_owner_onlyto assert all five files exist at0o600.Verification
cargo build,cargo clippy,cargo fmt --checkcleancargo nextest run -p decdn-node -p decdn-incentivegreen (incl. all 14channel_state_storeintegration guards)🤖 Generated with Claude Code