feat: added flush of parity-db logs after block import#1219
Open
feat: added flush of parity-db logs after block import#1219
Conversation
8042521 to
5e0c28a
Compare
36db0bc to
1bbfd08
Compare
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.
Summary
Adds a background pipeline that flushes the ledger ParityDB log after each block import, exposes a small
midnight-node-ledgerAPI to perform that flush safely, and temporarily patches severalmidnight-*crates to amidnight-ledgerbranch that providesflush_log_pipelineon the storage backend.Motivation
ParityDB keeps work in a log pipeline; flushing it regularly after imports reduces reliance on shutdown-only behavior and aligns with durability expectations for ledger state on disk.
What changed
node/src/ledger_log_pipeline.rs(new)every_import_notification_stream().AtomicBoolplustokio::sync::Notifyso wakeups coalesce with a drain loop: each wake runsflush_requested.swap(false)until quiescent, with the actual flush inspawn_blocking.catch_unwindso a panic is logged and the next import can retry.ledger-parity-db-wal(trace for queue, debug for timing, error on panic/join failure).ledger/src/lib.rsflush_log_pipeline_on_default_storage()(ledger v7 and v8 paths).ledger/src/versions/common/storage.rsflush_log_pipeline_on_default_storage_if_exists()usingif let Some(storage) = try_get_default_storage::<ParityDb>()andstorage.with_backend(...)so the flush holds anArcfor the whole call and avoids a TOCTOU withdefault_storage()if default storage is dropped concurrently.node/src/service.rsspawn_tasks, with the rest of full client setup unchanged.Workspace dependencies
[patch.crates-io]in rootCargo.tomlpointsmidnight-base-crypto,midnight-base-crypto-derive,midnight-serialize,midnight-serialize-macros, andmidnight-storage-coreatmidnight-ledgerbranchfeat/parity_db_pipeline_flush.derive-wherebumped to1.6.1;Cargo.lockupdated (including duplicateconsole/indicatifversions from the dependency graph).🗹 TODO before merging
📌 Submission Checklist
🧪 Testing Evidence
Please describe any additional testing aside from CI:
🔱 Fork Strategy
Links