Skip to content

Commit

Permalink
In ledger-tool delete the account files in the async way (solana-labs…
Browse files Browse the repository at this point in the history
…#27622)

* In ledger-tool delete the account files in the async way

* format changes by ./cargo nightly fmt --all
  • Loading branch information
xiangzhu70 authored Sep 7, 2022
1 parent 6a322de commit 4308c30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,7 @@ fn get_stake_percent_in_gossip(bank: &Bank, cluster_info: &ClusterInfo, log: boo
/// If the process is killed and the deleting process is not done,
/// the leftover path will be deleted in the next process life, so
/// there is no file space leaking.
fn move_and_async_delete_path(path: impl AsRef<Path> + Copy) {
pub fn move_and_async_delete_path(path: impl AsRef<Path> + Copy) {
let mut path_delete = PathBuf::new();
path_delete.push(path);
path_delete.set_file_name(format!(
Expand Down
15 changes: 7 additions & 8 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ use {
is_parsable, is_pow2, is_pubkey, is_pubkey_or_keypair, is_slot, is_valid_percentage,
},
},
solana_core::system_monitor_service::SystemMonitorService,
solana_core::{
system_monitor_service::SystemMonitorService, validator::move_and_async_delete_path,
},
solana_entry::entry::Entry,
solana_geyser_plugin_manager::geyser_plugin_service::GeyserPluginService,
solana_ledger::{
Expand Down Expand Up @@ -1053,13 +1055,10 @@ fn load_bank_forks(

if non_primary_accounts_path.exists() {
info!("Clearing {:?}", non_primary_accounts_path);
if let Err(err) = std::fs::remove_dir_all(&non_primary_accounts_path) {
eprintln!(
"error deleting accounts path {:?}: {}",
non_primary_accounts_path, err
);
exit(1);
}
let mut measure_time = Measure::start("clean_non_primary_accounts_paths");
move_and_async_delete_path(&non_primary_accounts_path);
measure_time.stop();
info!("done. {}", measure_time);
}

vec![non_primary_accounts_path]
Expand Down

0 comments on commit 4308c30

Please sign in to comment.