Skip to content

Commit

Permalink
[TieredStorage] Exclude NotFound in reporting storage leakage on drop…
Browse files Browse the repository at this point in the history
…() (solana-labs#446)

#### Problem
TieredStorage::drop() currently panic when it fails to delete the
underlying file to raise awareness of possible storage resource
leakage, including io::ErrorKind::NotFound.  But sometimes the
TieredStorage (or AccountsFile in general) instance is created
then dropped without any file being created.  This causes some
false-alarms including unit-tests.

#### Summary of Changes
This PR excludes NotFound in reporting storage leakage on
TieredStorage::drop().
  • Loading branch information
yhchiang-sol authored Mar 27, 2024
1 parent 9cd9075 commit 4b9e1e0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions accounts-db/src/tiered_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use {
solana_sdk::account::ReadableAccount,
std::{
borrow::Borrow,
fs,
fs, io,
path::{Path, PathBuf},
sync::{
atomic::{AtomicBool, Ordering},
Expand Down Expand Up @@ -65,10 +65,14 @@ pub struct TieredStorage {
impl Drop for TieredStorage {
fn drop(&mut self) {
if let Err(err) = fs::remove_file(&self.path) {
panic!(
"TieredStorage failed to remove backing storage file '{}': {err}",
self.path.display(),
);
// Here we bypass NotFound error as the focus of the panic is to
// detect any leakage of storage resource.
if err.kind() != io::ErrorKind::NotFound {
panic!(
"TieredStorage failed to remove backing storage file '{}': {err}",
self.path.display(),
);
}
}
}
}
Expand Down

0 comments on commit 4b9e1e0

Please sign in to comment.