Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: run StaticFileProvider::check_consistency on start up #8143

Merged
merged 74 commits into from
Jun 1, 2024

Conversation

joshieDo
Copy link
Collaborator

@joshieDo joshieDo commented May 7, 2024

The bulk of changes are regarding ProviderFactoryinitialization, but the real change is introducing a function to check the overall consistency between static files and database:

pub fn check_consistency<TX: DbTx>(
&self,
provider: &DatabaseProvider<TX>,
has_receipt_pruning: bool,
) -> ProviderResult<Option<PipelineTarget>> {

For each segment the following invariants are checked:

/// Check invariants for each corresponding table and static file segment:
///
/// * the corresponding database table should overlap or have continuity in their keys
/// ([TxNumber] or [BlockNumber]).
/// * its highest block should match the stage checkpoint block number if it's equal or higher
/// than the corresponding database table last entry.
/// * If the checkpoint block is higher, then request a pipeline unwind to the static file
/// block.
/// * If the checkpoint block is lower, then heal by removing rows from the static file.
fn ensure_invariants<TX: DbTx, T: Table<Key = u64>>(
&self,

These will be called on starting up the node, before any data is queried from storage. If it fails any check it will try to self-heal, and if not possible, return a PipelineTarget::Unwind(N) that will be straight away handled by a standalone unwind-only pipeline.

The tests live in crates/stages/mod.rs because there are other necessary test functions there and can not be imported into providers crate. Follow-up will refactor the test-utils in stages crate and move them to providers crate.

Pending live testing - but open to review

fixes #7618

@joshieDo joshieDo requested a review from onbjerg May 7, 2024 17:37
@joshieDo joshieDo added A-db Related to the database A-static-files Related to static files labels May 7, 2024
@joshieDo joshieDo marked this pull request as draft May 7, 2024 17:38
@joshieDo joshieDo mentioned this pull request May 12, 2024
1 task
Copy link
Collaborator

@shekhirin shekhirin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a first pass, want to also look at unwrap_or_default() usage

crates/node/builder/src/launch/common.rs Show resolved Hide resolved
crates/node/builder/src/launch/common.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gg

Copy link
Collaborator

@shekhirin shekhirin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one comment

crates/storage/nippy-jar/src/writer.rs Outdated Show resolved Hide resolved
@joshieDo joshieDo added this pull request to the merge queue Jun 1, 2024
Merged via the queue into main with commit a4df6bb Jun 1, 2024
30 checks passed
@joshieDo joshieDo deleted the joshie/boot-up-check branch June 1, 2024 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-db Related to the database A-static-files Related to static files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

beta.5 rolling restart after sync
4 participants