diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 60e15a1394..07e9384aa1 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1376,9 +1376,11 @@ impl AccountsDB { let index = self.accounts_index.read().unwrap(); let storage = self.storage.read().unwrap(); for slot in dead_slots.iter() { - for store in storage.0.get(slot).unwrap().values() { - for account in store.accounts.accounts(0) { - index.unref_from_storage(&account.meta.pubkey); + if let Some(slot_storage) = storage.0.get(slot) { + for store in slot_storage.values() { + for account in store.accounts.accounts(0) { + index.unref_from_storage(&account.meta.pubkey); + } } } } @@ -3373,4 +3375,12 @@ pub mod tests { assert_load_account(&accounts, current_slot, pubkey2, old_lamport); assert_load_account(&accounts, current_slot, dummy_pubkey, dummy_lamport); } + + #[test] + fn clean_dead_slots_empty() { + let accounts = AccountsDB::new_single(); + let mut dead_slots = HashSet::new(); + dead_slots.insert(10); + accounts.clean_dead_slots(&mut dead_slots); + } }