Create-snapshot check if slot is available on startup (#25329)
* Add a check during ledger-tool create-snapshot startup to see if the snapshot slot is available * check all slots from the start to snapshot_slot during load_bank_forks * unwrap_or_default incremental snapshot slot before comparison * Improve error messages on missing or not full slots
This commit is contained in:
parent
de03a3d3aa
commit
1e7d877494
|
@ -766,6 +766,8 @@ fn load_bank_forks(
|
||||||
} else {
|
} else {
|
||||||
"snapshot.ledger-tool"
|
"snapshot.ledger-tool"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let mut starting_slot = 0; // default start check with genesis
|
||||||
let snapshot_config = if arg_matches.is_present("no_snapshot") {
|
let snapshot_config = if arg_matches.is_present("no_snapshot") {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -773,6 +775,19 @@ fn load_bank_forks(
|
||||||
snapshot_archive_path.unwrap_or_else(|| blockstore.ledger_path().to_path_buf());
|
snapshot_archive_path.unwrap_or_else(|| blockstore.ledger_path().to_path_buf());
|
||||||
let incremental_snapshot_archives_dir =
|
let incremental_snapshot_archives_dir =
|
||||||
incremental_snapshot_archive_path.unwrap_or_else(|| full_snapshot_archives_dir.clone());
|
incremental_snapshot_archive_path.unwrap_or_else(|| full_snapshot_archives_dir.clone());
|
||||||
|
|
||||||
|
if let Some(full_snapshot_slot) =
|
||||||
|
snapshot_utils::get_highest_full_snapshot_archive_slot(&full_snapshot_archives_dir)
|
||||||
|
{
|
||||||
|
let incremental_snapshot_slot =
|
||||||
|
snapshot_utils::get_highest_incremental_snapshot_archive_slot(
|
||||||
|
&incremental_snapshot_archives_dir,
|
||||||
|
full_snapshot_slot,
|
||||||
|
)
|
||||||
|
.unwrap_or_default();
|
||||||
|
starting_slot = std::cmp::max(full_snapshot_slot, incremental_snapshot_slot);
|
||||||
|
}
|
||||||
|
|
||||||
Some(SnapshotConfig {
|
Some(SnapshotConfig {
|
||||||
full_snapshot_archive_interval_slots: Slot::MAX,
|
full_snapshot_archive_interval_slots: Slot::MAX,
|
||||||
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
incremental_snapshot_archive_interval_slots: Slot::MAX,
|
||||||
|
@ -782,6 +797,25 @@ fn load_bank_forks(
|
||||||
..SnapshotConfig::default()
|
..SnapshotConfig::default()
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(halt_slot) = process_options.halt_at_slot {
|
||||||
|
for slot in starting_slot..=halt_slot {
|
||||||
|
if let Ok(Some(slot_meta)) = blockstore.meta(slot) {
|
||||||
|
if !slot_meta.is_full() {
|
||||||
|
eprintln!("Unable to process from slot {} to {} due to blockstore slot {} not being full",
|
||||||
|
starting_slot, halt_slot, slot);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
eprintln!(
|
||||||
|
"Unable to process from slot {} to {} due to blockstore missing slot {}",
|
||||||
|
starting_slot, halt_slot, slot
|
||||||
|
);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let account_paths = if let Some(account_paths) = arg_matches.value_of("account_paths") {
|
let account_paths = if let Some(account_paths) = arg_matches.value_of("account_paths") {
|
||||||
if !blockstore.is_primary_access() {
|
if !blockstore.is_primary_access() {
|
||||||
// Be defensive, when default account dir is explicitly specified, it's still possible
|
// Be defensive, when default account dir is explicitly specified, it's still possible
|
||||||
|
|
Loading…
Reference in New Issue