Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Make startup aware of Incremental Snapshots #19600

Merged
merged 1 commit into from
Sep 7, 2021

Conversation

brooksprumo
Copy link
Contributor

@brooksprumo brooksprumo commented Sep 3, 2021

Now that the background services are aware of incremental snapshots,
they need (1) the correct last full snapshot slot in order to clean
accounts correctly, and (2) all expected full snapshots to be available
when created an incremental snapshot based on them.

This commit fixes startup so both requirements from above are met.

At startup, the blockstore processor loads frozen banks. Some of these
banks may be roots, and some of these roots may cross the full snapshot
interval. If/when that happens, take a bank snapshot and queue the full
snapshot in the AccountsPackageSender. And at the end of startup,
return the last full snapshot slot to pass into the background services.

Fixes #19297

Overview

High level overview for blockstore_processor::do_process_blockstore_from_root(). The new arg last_full_snapshot_slot is populated if we loaded from a full snapshot (vs starting from genesis). Then load_frozen_forks() processes the blocks, and updates the value (last_full_snapshot_slot) in case a new root is found that crosses the full snapshot interval. Finally, the value is returned and gets passed along to AccountsBackgroundService for its starting value of last_full_snapshot_slot.

Additionally, if a new root is found during load_frozen_forks() that crosses the full snapshot interval, now take a snapshot (with snapshot_utils::snapshot_bank()).

@codecov
Copy link

codecov bot commented Sep 3, 2021

Codecov Report

Merging #19600 (e9cde56) into master (9d9482b) will decrease coverage by 0.0%.
The diff coverage is 85.6%.

@@            Coverage Diff            @@
##           master   #19600     +/-   ##
=========================================
- Coverage    82.5%    82.5%   -0.1%     
=========================================
  Files         471      471             
  Lines      132112   132199     +87     
=========================================
+ Hits       109096   109163     +67     
- Misses      23016    23036     +20     

Copy link
Contributor Author

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

I'm calling out a few spots to highlight so they don't get lost in some of the plumbing noise.

Comment on lines 1189 to 1212
if let Some(snapshot_config) = snapshot_config {
let block_height = new_root_bank.block_height();
if block_height % snapshot_config.full_snapshot_archive_interval_slots == 0 {
snapshot_utils::snapshot_bank(
new_root_bank,
new_root_bank.src.slot_deltas(&new_root_bank.src.roots()),
&accounts_package_sender,
&snapshot_config.bank_snapshots_dir,
&snapshot_config.snapshot_archives_dir,
snapshot_config.snapshot_version,
snapshot_config.archive_format,
None,
Some(SnapshotType::FullSnapshot),
)
.expect("Failed to snapshot bank while loading frozen banks");
trace!(
"took bank snapshot for new root bank, block height: {}, slot: {}",
block_height,
*root
);
*last_full_snapshot_slot = Some(*root);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where snapshots are taken while processing blocks that are roots, and also sets the new value for last_full_snapshot_slot.

Copy link
Contributor Author

@brooksprumo brooksprumo Sep 7, 2021

Choose a reason for hiding this comment

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

TODO: call clean before snapshot_bank

Update: DONE

@@ -712,7 +712,7 @@ fn load_bank_forks(
let snapshot_archives_dir =
snapshot_archive_path.unwrap_or_else(|| blockstore.ledger_path().to_path_buf());
Some(SnapshotConfig {
full_snapshot_archive_interval_slots: 0, // Value doesn't matter
full_snapshot_archive_interval_slots: Slot::MAX,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cannot be zero because this value is used when processing the blockstore and is the modulo of the new roots. A value of 0 here is a divide-by-zero error.

Comment on lines +138 to +139
accounts_package_channel: (AccountsPackageSender, AccountsPackageReceiver),
last_full_snapshot_slot: Option<Slot>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The TVU now takes in an AccountsPackageSender/Receiver, and the last full snapshot slot. This comes from bank_forks::load() and blockstore_processor::do_process_blockstore_from_root().

@brooksprumo brooksprumo added the automerge Merge this Pull Request automatically once CI passes label Sep 7, 2021
@mergify mergify bot merged commit a0552e5 into solana-labs:master Sep 7, 2021
@brooksprumo brooksprumo deleted the snapshot-startup-2 branch September 20, 2021 21:57
frits-metalogix added a commit to identity-com/solana that referenced this pull request Nov 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make validator startup aware of Incremental Snapshots
2 participants