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

[TieredStorage] Disable accounts-file type check before enabling tiered-storage #418

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Changes from all 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
17 changes: 2 additions & 15 deletions accounts-db/src/accounts_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,8 @@ impl AccountsFile {
/// The second element of the returned tuple is the number of accounts in the
/// accounts file.
pub fn new_from_file(path: impl AsRef<Path>, current_len: usize) -> Result<(Self, usize)> {
match TieredStorage::new_readonly(path.as_ref()) {
Ok(tiered_storage) => {
// unwrap() note: TieredStorage::new_readonly() is guaranteed to have a valid
// reader instance when opening with new_readonly.
let num_accounts = tiered_storage.reader().unwrap().num_accounts();
Ok((Self::TieredStorage(tiered_storage), num_accounts))
}
Err(TieredStorageError::MagicNumberMismatch(_, _)) => {
// In case of MagicNumberMismatch, we can assume that this is not
// a tiered-storage file.
let (av, num_accounts) = AppendVec::new_from_file(path, current_len)?;
Ok((Self::AppendVec(av), num_accounts))
}
Err(e) => Err(AccountsFileError::TieredStorageError(e)),
}
let (av, num_accounts) = AppendVec::new_from_file(path, current_len)?;
Ok((Self::AppendVec(av), num_accounts))
}

pub fn flush(&self) -> Result<()> {
Expand Down
Loading