Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 3 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
16 changes: 16 additions & 0 deletions runtime/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,22 @@ 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;
let slot_str = slot.to_string();
for account_path in account_paths {
let account_snapshot_path = account_path
.parent()
.ok_or(SnapshotError::InvalidAppendVecPath(account_path.clone()))?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about SnapshotError::IoWithSourceAndFile instead? If we can't get parent() here, it doesn't feel like an AppendVec path issue. It'd be because the account_path here isn't within run/, right (basically)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that it is probably better to use SnapshotError::IoWithSourceAndFile here. I doubt we'll actually see this though - parent() would only return None if the account path was root or an empty string here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IoWithSourceAndFile need an IO error.

  #[error("source({1}) - I/O error: {0}, file: {2}")]
    IoWithSourceAndFile(#[source] std::io::Error, &'static str, PathBuf),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not an IO error. There is no std::io::Error supplied.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, added a new error InvalidAccountPath

.join("snapshot")
.join(slot_str.clone());
apfitzge marked this conversation as resolved.
Show resolved Hide resolved
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