Removes init-time cleanup in add_bank_snapshot() (#31997)
This commit is contained in:
parent
228e92a024
commit
afbb0fa92f
|
@ -1279,32 +1279,12 @@ pub fn add_bank_snapshot(
|
||||||
) -> Result<BankSnapshotInfo> {
|
) -> Result<BankSnapshotInfo> {
|
||||||
let mut add_snapshot_time = Measure::start("add-snapshot-ms");
|
let mut add_snapshot_time = Measure::start("add-snapshot-ms");
|
||||||
let slot = bank.slot();
|
let slot = bank.slot();
|
||||||
// bank_snapshots_dir/slot
|
|
||||||
let bank_snapshot_dir = get_bank_snapshot_dir(&bank_snapshots_dir, slot);
|
let bank_snapshot_dir = get_bank_snapshot_dir(&bank_snapshots_dir, slot);
|
||||||
if bank_snapshot_dir.is_dir() {
|
assert!(
|
||||||
// There is a time window from when a snapshot directory is created to when its content
|
!bank_snapshot_dir.exists(),
|
||||||
// is fully filled to become a full state good to construct a bank from. At the init time,
|
"A bank snapshot already exists for slot {slot}!? Path: {}",
|
||||||
// the system may not be booted from the latest snapshot directory, but an older and complete
|
bank_snapshot_dir.display()
|
||||||
// directory. Then, when adding new snapshots, the newer incomplete snapshot directory could
|
);
|
||||||
// be found. If so, it should be removed.
|
|
||||||
purge_bank_snapshot(&bank_snapshot_dir)?;
|
|
||||||
} else {
|
|
||||||
// Even the snapshot directory is not found, still ensure the account snapshot directory
|
|
||||||
// is also clean. hardlink failure will happen if an old file exists.
|
|
||||||
let account_paths = &bank.accounts().accounts_db.paths;
|
|
||||||
let slot_str = slot.to_string();
|
|
||||||
for account_path in account_paths {
|
|
||||||
let account_snapshot_path = account_path
|
|
||||||
.parent()
|
|
||||||
.ok_or(SnapshotError::InvalidAccountPath(account_path.clone()))?
|
|
||||||
.join("snapshot")
|
|
||||||
.join(&slot_str);
|
|
||||||
if account_snapshot_path.is_dir() {
|
|
||||||
// remove the account snapshot directory
|
|
||||||
move_and_async_delete_path(&account_snapshot_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fs::create_dir_all(&bank_snapshot_dir)?;
|
fs::create_dir_all(&bank_snapshot_dir)?;
|
||||||
|
|
||||||
// the bank snapshot is stored as bank_snapshots_dir/slot/slot.BANK_SNAPSHOT_PRE_FILENAME_EXTENSION
|
// the bank snapshot is stored as bank_snapshots_dir/slot/slot.BANK_SNAPSHOT_PRE_FILENAME_EXTENSION
|
||||||
|
@ -1320,7 +1300,7 @@ pub fn add_bank_snapshot(
|
||||||
|
|
||||||
// We are constructing the snapshot directory to contain the full snapshot state information to allow
|
// We are constructing the snapshot directory to contain the full snapshot state information to allow
|
||||||
// constructing a bank from this directory. It acts like an archive to include the full state.
|
// constructing a bank from this directory. It acts like an archive to include the full state.
|
||||||
// The set of the account appendvec files is the necessary part of this snapshot state. Hard-link them
|
// The set of the account storages files is the necessary part of this snapshot state. Hard-link them
|
||||||
// from the operational accounts/ directory to here.
|
// from the operational accounts/ directory to here.
|
||||||
hard_link_storages_to_snapshot(&bank_snapshot_dir, slot, snapshot_storages)?;
|
hard_link_storages_to_snapshot(&bank_snapshot_dir, slot, snapshot_storages)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue