Do not remove bank snapshots in new_from_dir() (#31556)
This commit is contained in:
parent
6adbb1254c
commit
7dbcf5a0fd
|
@ -191,14 +191,7 @@ impl BankSnapshotInfo {
|
||||||
|
|
||||||
// There is a time window from the slot directory being created, and the content being completely
|
// There is a time window from the slot directory being created, and the content being completely
|
||||||
// filled. Check the completion to avoid using a highest found slot directory with missing content.
|
// filled. Check the completion to avoid using a highest found slot directory with missing content.
|
||||||
let completion_flag_file = bank_snapshot_dir.join(SNAPSHOT_STATE_COMPLETE_FILENAME);
|
if !is_bank_snapshot_complete(&bank_snapshot_dir) {
|
||||||
if !completion_flag_file.is_file() {
|
|
||||||
// If the directory is incomplete, it should be removed.
|
|
||||||
// There are also possible hardlink files under <account_path>/snapshot/<slot>/, referred by this
|
|
||||||
// snapshot dir's symlinks. They are cleaned up in clean_orphaned_account_snapshot_dirs() at the
|
|
||||||
// boot time.
|
|
||||||
info!("Removing incomplete snapshot dir: {:?}", bank_snapshot_dir);
|
|
||||||
fs::remove_dir_all(&bank_snapshot_dir)?;
|
|
||||||
return Err(SnapshotNewFromDirError::IncompleteDir(bank_snapshot_dir));
|
return Err(SnapshotNewFromDirError::IncompleteDir(bank_snapshot_dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5224,8 +5217,6 @@ mod tests {
|
||||||
assert!(snapshot_dir_4.exists());
|
assert!(snapshot_dir_4.exists());
|
||||||
let snapshot = get_highest_bank_snapshot(&bank_snapshots_dir).unwrap();
|
let snapshot = get_highest_bank_snapshot(&bank_snapshots_dir).unwrap();
|
||||||
assert_eq!(snapshot.slot, 3);
|
assert_eq!(snapshot.slot, 3);
|
||||||
// The incomplete snapshot dir should have been deleted
|
|
||||||
assert!(!snapshot_dir_4.exists());
|
|
||||||
|
|
||||||
let snapshot_version_file = snapshot.snapshot_dir.join(SNAPSHOT_VERSION_FILENAME);
|
let snapshot_version_file = snapshot.snapshot_dir.join(SNAPSHOT_VERSION_FILENAME);
|
||||||
fs::remove_file(snapshot_version_file).unwrap();
|
fs::remove_file(snapshot_version_file).unwrap();
|
||||||
|
|
Loading…
Reference in New Issue