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

Commit

Permalink
Replaces snapshot_utils::remove_bank_snapshot() (#31498)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored May 5, 2023
1 parent e4d1fcb commit 4196dbc
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions runtime/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ pub fn add_bank_snapshot(
// the system may not be booted from the latest snapshot directory, but an older and complete
// directory. Then, when adding new snapshots, the newer incomplete snapshot directory could
// be found. If so, it should be removed.
remove_bank_snapshot(slot, &bank_snapshots_dir)?;
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.
Expand Down Expand Up @@ -1327,12 +1327,6 @@ fn serialize_status_cache(slot_deltas: &[BankSlotDelta], status_cache_path: &Pat
})
}

/// Remove the snapshot directory for this slot
pub fn remove_bank_snapshot(slot: Slot, bank_snapshots_dir: impl AsRef<Path>) -> Result<()> {
let bank_snapshot_dir = get_bank_snapshot_dir(&bank_snapshots_dir, slot);
purge_bank_snapshot(bank_snapshot_dir)
}

#[derive(Debug, Default)]
pub struct BankFromArchiveTimings {
pub rebuild_bank_from_snapshots_us: u64,
Expand Down Expand Up @@ -2953,10 +2947,10 @@ pub fn purge_old_bank_snapshots(
.rev()
.skip(num_bank_snapshots_to_retain)
.for_each(|bank_snapshot| {
let r = remove_bank_snapshot(bank_snapshot.slot, &bank_snapshots_dir);
let r = purge_bank_snapshot(&bank_snapshot.snapshot_dir);
if r.is_err() {
warn!(
"Couldn't remove bank snapshot at: {}",
"Couldn't purge bank snapshot at: {}",
bank_snapshot.snapshot_dir.display()
);
}
Expand Down Expand Up @@ -5138,7 +5132,8 @@ mod tests {
hardlink_dirs.push(dst_path);
}

assert!(remove_bank_snapshot(bank.slot(), bank_snapshots_dir).is_ok());
let bank_snapshot_dir = get_bank_snapshot_dir(&bank_snapshots_dir, bank.slot());
assert!(purge_bank_snapshot(bank_snapshot_dir).is_ok());

// When the bank snapshot is removed, all the snapshot hardlink directories should be removed.
assert!(hardlink_dirs.iter().all(|dir| fs::metadata(dir).is_err()));
Expand Down

0 comments on commit 4196dbc

Please sign in to comment.