From fa16029b84f567808e5b3320c0e5dfed2cd7eec5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:05:32 -0500 Subject: [PATCH] v2.1: Fixes clean_old_storages_with_reclaims tests (backport of #4147) (#4165) * Fixes clean_old_storages_with_reclaims tests (#4147) (cherry picked from commit 4eabeedaa2f26822b9eb61d8e081c5edb03544da) # Conflicts: # accounts-db/src/accounts_db/tests.rs * fix merge conflicts --------- Co-authored-by: Brooks --- accounts-db/src/accounts_db.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 8e5b91900c626f..7d97fc2f7a6fc4 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -17373,14 +17373,19 @@ pub mod tests { slot, &[(&pubkey, &account), (&Pubkey::new_unique(), &account)], ); - accounts_db.calculate_accounts_delta_hash(slot); accounts_db.add_root_and_flush_write_cache(slot); + // ensure this slot is *not* in the dirty_stores or uncleaned_pubkeys, because we want to + // test cleaning *old* storages, i.e. when they aren't explicitly marked for cleaning + assert!(!accounts_db.dirty_stores.contains_key(&slot)); + assert!(!accounts_db.uncleaned_pubkeys.contains_key(&slot)); } - // for this test, `new_slot` must not be in the uncleaned_roots list - accounts_db.accounts_index.remove_uncleaned_root(new_slot); - assert!(accounts_db.accounts_index.is_uncleaned_root(old_slot)); - assert!(!accounts_db.accounts_index.is_uncleaned_root(new_slot)); + // add `old_slot` to the dirty stores list to mimic it being picked up as old + let old_storage = accounts_db + .storage + .get_slot_storage_entry_shrinking_in_progress_ok(old_slot) + .unwrap(); + accounts_db.dirty_stores.insert(old_slot, old_storage); // ensure the slot list for `pubkey` has both the old and new slots let slot_list = accounts_db @@ -17428,13 +17433,14 @@ pub mod tests { &[(&pubkey, &account), (&Pubkey::new_unique(), &account)], ); accounts_db.calculate_accounts_delta_hash(slot); + // ensure this slot is in uncleaned_pubkeys (but not dirty_stores) so it'll be cleaned + assert!(!accounts_db.dirty_stores.contains_key(&slot)); + assert!(accounts_db.uncleaned_pubkeys.contains_key(&slot)); } - // do not root `new_slot`! - accounts_db.add_root_and_flush_write_cache(old_slot); - // for this test, `new_slot` must not be a root - assert!(accounts_db.accounts_index.is_uncleaned_root(old_slot)); - assert!(!accounts_db.accounts_index.is_uncleaned_root(new_slot)); + // only `old_slot` should be rooted, not `new_slot` + accounts_db.add_root_and_flush_write_cache(old_slot); + assert!(accounts_db.accounts_index.is_alive_root(old_slot)); assert!(!accounts_db.accounts_index.is_alive_root(new_slot)); // ensure the slot list for `pubkey` has both the old and new slots