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

[REVERTED] Make startup aware of Incremental Snapshots #19550

Merged
merged 2 commits into from
Sep 3, 2021

Conversation

brooksprumo
Copy link
Contributor

@brooksprumo brooksprumo commented Sep 1, 2021

Now that the background services are aware of incremental snapshots,
they need (1) the corect 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

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 +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().

core/src/validator.rs Outdated Show resolved Hide resolved
timings: BankFromArchiveTimings,
mut 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.

High level overview for 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.

Comment on lines +1189 to +1211
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.

@codecov
Copy link

codecov bot commented Sep 1, 2021

Codecov Report

Merging #19550 (fede8d6) into master (f4f14c4) will increase coverage by 0.0%.
The diff coverage is 80.5%.

@@           Coverage Diff            @@
##           master   #19550    +/-   ##
========================================
  Coverage    82.5%    82.5%            
========================================
  Files         468      468            
  Lines      131542   131662   +120     
========================================
+ Hits       108540   108693   +153     
+ Misses      23002    22969    -33     

Now that the background services are aware of incremental snapshots,
they need (1) the corect 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 solana-labs#19297
@@ -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.

@brooksprumo brooksprumo marked this pull request as ready for review September 2, 2021 22:31
@brooksprumo brooksprumo merged commit d45ced0 into solana-labs:master Sep 3, 2021
brooksprumo added a commit to brooksprumo/solana that referenced this pull request Sep 3, 2021
@brooksprumo
Copy link
Contributor Author

brooksprumo commented Sep 3, 2021

Ugh, I was on the wrong PR and merged this one accidentally :( It has been reverted.

New PR is #19600

brooksprumo added a commit to brooksprumo/solana that referenced this pull request Sep 3, 2021
@brooksprumo brooksprumo mentioned this pull request Sep 3, 2021
brooksprumo added a commit that referenced this pull request Sep 3, 2021
brooksprumo added a commit that referenced this pull request Sep 3, 2021
@brooksprumo brooksprumo changed the title Make startup aware of Incremental Snapshots [REVERTED] Make startup aware of Incremental Snapshots Sep 3, 2021
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Sep 3, 2021
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Sep 3, 2021
frits-metalogix added a commit to identity-com/solana that referenced this pull request Nov 24, 2021
frits-metalogix added a commit to identity-com/solana that referenced this pull request Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make validator startup aware of Incremental Snapshots
1 participant