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

Clean up old account snapshot directories to avoid the file existing hardlink error #30426

Merged
merged 5 commits into from
Feb 23, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions runtime/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,21 @@ pub fn add_bank_snapshot(
// 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)?;
} 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;
for account_path in account_paths {
let account_snapshot_path = account_path
.parent()
.unwrap()
.join("snapshot")
.join(bank.slot().to_string());
if account_snapshot_path.is_dir() {
// remove the account snapshot directory
fs::remove_dir_all(&account_snapshot_path)?;
}
}
}
fs::create_dir_all(&bank_snapshot_dir)?;

Expand Down