Calculate ref counts earlier to prevent bad clean (#9147)
This commit is contained in:
parent
5f31444300
commit
b1771b92ec
|
@ -775,14 +775,23 @@ impl AccountsDB {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for account_infos in purges.values() {
|
// Another pass to check if there are some filtered accounts which
|
||||||
let mut no_delete = false;
|
// do not match the criteria of deleting all appendvecs which contain them
|
||||||
for (_slot, account_info) in account_infos {
|
// then increment their storage count.
|
||||||
if *store_counts.get(&account_info.store_id).unwrap() != 0 {
|
for (pubkey, account_infos) in &purges {
|
||||||
no_delete = true;
|
let no_delete =
|
||||||
break;
|
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 {
|
if no_delete {
|
||||||
for (_slot, account_info) in account_infos {
|
for (_slot, account_info) in account_infos {
|
||||||
*store_counts.get_mut(&account_info.store_id).unwrap() += 1;
|
*store_counts.get_mut(&account_info.store_id).unwrap() += 1;
|
||||||
|
@ -794,17 +803,13 @@ impl AccountsDB {
|
||||||
// Only keep purges where the entire history of the account in the root set
|
// Only keep purges where the entire history of the account in the root set
|
||||||
// can be purged. All AppendVecs for those updates are dead.
|
// can be purged. All AppendVecs for those updates are dead.
|
||||||
let mut purge_filter = Measure::start("purge_filter");
|
let mut purge_filter = Measure::start("purge_filter");
|
||||||
purges.retain(|pubkey, account_infos| {
|
purges.retain(|_pubkey, account_infos| {
|
||||||
let mut would_unref_count = 0;
|
for (_slot, account_info) in account_infos.iter() {
|
||||||
for (_slot, account_info) in account_infos {
|
if *store_counts.get(&account_info.store_id).unwrap() != 0 {
|
||||||
if *store_counts.get(&account_info.store_id).unwrap() == 0 {
|
|
||||||
would_unref_count += 1;
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
true
|
||||||
would_unref_count == accounts_index.ref_count_from_storage(&pubkey)
|
|
||||||
});
|
});
|
||||||
purge_filter.stop();
|
purge_filter.stop();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue