From b2e1d736f9dc9e5f6541fd43a7629b8d3b85219e Mon Sep 17 00:00:00 2001 From: Xiang Zhu Date: Fri, 21 Apr 2023 05:57:49 -0700 Subject: [PATCH] Purge snapshot dirs before loading from an archive (#31283) * Purge snapshot dirs before loading from an archive * Refine comment * Should not remove the bank_snapshots_dir directory --- ledger/src/bank_forks_utils.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ledger/src/bank_forks_utils.rs b/ledger/src/bank_forks_utils.rs index aaf494134..f3a67f4d9 100644 --- a/ledger/src/bank_forks_utils.rs +++ b/ledger/src/bank_forks_utils.rs @@ -97,7 +97,6 @@ pub fn load_bank_forks( "Initializing bank snapshot path: {}", snapshot_config.bank_snapshots_dir.display() ); - let _ = fs::remove_dir_all(&snapshot_config.bank_snapshots_dir); fs::create_dir_all(&snapshot_config.bank_snapshots_dir) .expect("Couldn't create snapshot directory"); @@ -199,6 +198,12 @@ fn bank_forks_from_snapshot( process::exit(1); } + // Given that we are going to boot from an archive, the accountvecs held in the snapshot dirs for fast-boot should + // be released. They will be released by the account_background_service anyway. But in the case of the account_paths + // using memory-mounted file system, they are not released early enough to give space for the new append-vecs from + // the archives, causing the out-of-memory problem. So, purge the snapshot dirs upfront before loading from the archive. + snapshot_utils::purge_old_bank_snapshots(&snapshot_config.bank_snapshots_dir, 0, None); + let (deserialized_bank, full_snapshot_archive_info, incremental_snapshot_archive_info) = snapshot_utils::bank_from_latest_snapshot_archives( &snapshot_config.bank_snapshots_dir,