Only add keys with multiple index entries to the clean set (#17473)
This commit is contained in:
@ -5205,7 +5205,7 @@ impl AccountsDb {
|
|||||||
let len = accounts_map.len();
|
let len = accounts_map.len();
|
||||||
|
|
||||||
let mut items = Vec::with_capacity(len);
|
let mut items = Vec::with_capacity(len);
|
||||||
let dirty_keys = accounts_map
|
let mut dirty_pubkeys = accounts_map
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(pubkey, (_, store_id, stored_account))| {
|
.map(|(pubkey, (_, store_id, stored_account))| {
|
||||||
items.push((
|
items.push((
|
||||||
@ -5220,10 +5220,25 @@ impl AccountsDb {
|
|||||||
*pubkey
|
*pubkey
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
self.uncleaned_pubkeys.insert(*slot, dirty_keys);
|
|
||||||
|
|
||||||
self.accounts_index
|
let items_len = items.len();
|
||||||
|
let dirty_pubkey_mask = self
|
||||||
|
.accounts_index
|
||||||
.insert_new_if_missing_into_primary_index(*slot, items);
|
.insert_new_if_missing_into_primary_index(*slot, items);
|
||||||
|
|
||||||
|
assert_eq!(dirty_pubkey_mask.len(), items_len);
|
||||||
|
|
||||||
|
let mut dirty_pubkey_mask_iter = dirty_pubkey_mask.iter();
|
||||||
|
|
||||||
|
// dirty_pubkey_mask will return true if an item has multiple rooted entries for
|
||||||
|
// a given pubkey. If there is just a single item, there is no cleaning to
|
||||||
|
// be done on that pubkey. Prune the touched pubkey set here for only those
|
||||||
|
// pubkeys with multiple updates.
|
||||||
|
dirty_pubkeys.retain(|_k| *dirty_pubkey_mask_iter.next().unwrap());
|
||||||
|
if !dirty_pubkeys.is_empty() {
|
||||||
|
self.uncleaned_pubkeys.insert(*slot, dirty_pubkeys);
|
||||||
|
}
|
||||||
|
|
||||||
if !self.account_indexes.is_empty() {
|
if !self.account_indexes.is_empty() {
|
||||||
for (pubkey, (_, _store_id, stored_account)) in accounts_map.iter() {
|
for (pubkey, (_, _store_id, stored_account)) in accounts_map.iter() {
|
||||||
self.accounts_index.update_secondary_indexes(
|
self.accounts_index.update_secondary_indexes(
|
||||||
|
@ -1205,7 +1205,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
|
|||||||
&self,
|
&self,
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
items: Vec<(&Pubkey, T)>,
|
items: Vec<(&Pubkey, T)>,
|
||||||
) {
|
) -> Vec<bool> {
|
||||||
let potentially_new_items = items
|
let potentially_new_items = items
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_pubkey, account_info)| {
|
.map(|(_pubkey, account_info)| {
|
||||||
@ -1220,7 +1220,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
|
|||||||
items
|
items
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.zip(potentially_new_items.into_iter())
|
.zip(potentially_new_items.into_iter())
|
||||||
.for_each(|((pubkey, account_info), new_item)| {
|
.map(|((pubkey, account_info), new_item)| {
|
||||||
let account_entry = self.insert_new_entry_if_missing_with_lock(
|
let account_entry = self.insert_new_entry_if_missing_with_lock(
|
||||||
pubkey,
|
pubkey,
|
||||||
&mut w_account_maps,
|
&mut w_account_maps,
|
||||||
@ -1231,8 +1231,12 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
|
|||||||
}
|
}
|
||||||
if let Some(mut w_account_entry) = account_entry {
|
if let Some(mut w_account_entry) = account_entry {
|
||||||
w_account_entry.update(slot, account_info, &mut _reclaims);
|
w_account_entry.update(slot, account_info, &mut _reclaims);
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates the given pubkey at the given slot with the new account information.
|
// Updates the given pubkey at the given slot with the new account information.
|
||||||
|
@ -4624,22 +4624,26 @@ impl Bank {
|
|||||||
/// A snapshot bank should be purged of 0 lamport accounts which are not part of the hash
|
/// A snapshot bank should be purged of 0 lamport accounts which are not part of the hash
|
||||||
/// calculation and could shield other real accounts.
|
/// calculation and could shield other real accounts.
|
||||||
pub fn verify_snapshot_bank(&self) -> bool {
|
pub fn verify_snapshot_bank(&self) -> bool {
|
||||||
|
info!("cleaning..");
|
||||||
let mut clean_time = Measure::start("clean");
|
let mut clean_time = Measure::start("clean");
|
||||||
if self.slot() > 0 {
|
if self.slot() > 0 {
|
||||||
self.clean_accounts(true, true);
|
self.clean_accounts(true, true);
|
||||||
}
|
}
|
||||||
clean_time.stop();
|
clean_time.stop();
|
||||||
|
|
||||||
|
info!("shrinking..");
|
||||||
let mut shrink_all_slots_time = Measure::start("shrink_all_slots");
|
let mut shrink_all_slots_time = Measure::start("shrink_all_slots");
|
||||||
if self.slot() > 0 {
|
if self.slot() > 0 {
|
||||||
self.shrink_all_slots(true);
|
self.shrink_all_slots(true);
|
||||||
}
|
}
|
||||||
shrink_all_slots_time.stop();
|
shrink_all_slots_time.stop();
|
||||||
|
|
||||||
|
info!("verify_bank_hash..");
|
||||||
let mut verify_time = Measure::start("verify_bank_hash");
|
let mut verify_time = Measure::start("verify_bank_hash");
|
||||||
let mut verify = self.verify_bank_hash();
|
let mut verify = self.verify_bank_hash();
|
||||||
verify_time.stop();
|
verify_time.stop();
|
||||||
|
|
||||||
|
info!("verify_hash..");
|
||||||
let mut verify2_time = Measure::start("verify_hash");
|
let mut verify2_time = Measure::start("verify_hash");
|
||||||
// Order and short-circuiting is significant; verify_hash requires a valid bank hash
|
// Order and short-circuiting is significant; verify_hash requires a valid bank hash
|
||||||
verify = verify && self.verify_hash();
|
verify = verify && self.verify_hash();
|
||||||
|
Reference in New Issue
Block a user