diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 9e60cabaacc..3f30b76604d 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -7053,6 +7053,15 @@ impl AccountsDb { } pub fn flush_accounts_cache_slot_for_tests(&self, slot: Slot) { + assert!( + self.accounts_index + .roots_tracker + .read() + .unwrap() + .alive_roots + .contains(&slot), + "slot: {slot}" + ); self.flush_slot_cache_with_clean(slot, None::<&mut fn(&_) -> bool>, None); } diff --git a/accounts-db/src/accounts_db/tests.rs b/accounts-db/src/accounts_db/tests.rs index 05c24acc084..ce62b2e2189 100644 --- a/accounts-db/src/accounts_db/tests.rs +++ b/accounts-db/src/accounts_db/tests.rs @@ -6478,10 +6478,13 @@ fn test_mark_obsolete_accounts_at_startup_purge_slot() { // Store the same pubkey in multiple slots // Store other pubkey in slot0 to ensure slot is not purged accounts_db.store_for_tests((0, [(&pubkey1, &account), (&pubkey2, &account)].as_slice())); + accounts_db.add_root(0); accounts_db.flush_accounts_cache_slot_for_tests(0); accounts_db.store_for_tests((1, [(&pubkey1, &account)].as_slice())); + accounts_db.add_root(1); accounts_db.flush_accounts_cache_slot_for_tests(1); accounts_db.store_for_tests((2, [(&pubkey1, &account)].as_slice())); + accounts_db.add_root(2); accounts_db.flush_accounts_cache_slot_for_tests(2); let pubkeys_with_duplicates_by_bin = vec![vec![pubkey1]]; @@ -6514,6 +6517,7 @@ fn test_mark_obsolete_accounts_at_startup_multiple_bins() { slot, [(&pubkey1, &account), (&pubkey2, &account)].as_slice(), )); + accounts_db.add_root(slot); accounts_db.flush_accounts_cache_slot_for_tests(slot); }