Calculate ref counts earlier to prevent bad clean (#9153)

This commit is contained in:
sakridge
2020-03-29 14:42:57 -07:00
committed by GitHub
parent 8b8e066bbe
commit da9e930788

View File

@ -727,14 +727,23 @@ impl AccountsDB {
}
}
for account_infos in purges.values() {
let mut no_delete = false;
for (_slot_id, account_info) in account_infos {
if *store_counts.get(&account_info.store_id).unwrap() != 0 {
no_delete = true;
break;
}
}
// Another pass to check if there are some filtered accounts which
// do not match the criteria of deleting all appendvecs which contain them
// then increment their storage count.
for (pubkey, account_infos) in &purges {
let no_delete =
if account_infos.len() as u64 != accounts_index.ref_count_from_storage(&pubkey) {
true
} else {
let mut no_delete = false;
for (_slot, account_info) in account_infos {
if *store_counts.get(&account_info.store_id).unwrap() != 0 {
no_delete = true;
break;
}
}
no_delete
};
if no_delete {
for (_slot_id, account_info) in account_infos {
*store_counts.get_mut(&account_info.store_id).unwrap() += 1;
@ -744,17 +753,13 @@ impl AccountsDB {
// Only keep purges where the entire history of the account in the root set
// can be purged. All AppendVecs for those updates are dead.
purges.retain(|pubkey, account_infos| {
let mut would_unref_count = 0;
for (_slot_id, account_info) in account_infos {
if *store_counts.get(&account_info.store_id).unwrap() == 0 {
would_unref_count += 1;
} else {
purges.retain(|_pubkey, account_infos| {
for (_slot, account_info) in account_infos.iter() {
if *store_counts.get(&account_info.store_id).unwrap() != 0 {
return false;
}
}
would_unref_count == accounts_index.ref_count_from_storage(&pubkey)
true
});
// Recalculate reclaims with new purge set