correctly clean filler accounts (#21139)

This commit is contained in:
Jeff Washington (jwash) 2021-11-03 11:27:15 -05:00 committed by GitHub
parent 140a5f633d
commit c0952831be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 10 deletions

View File

@ -5815,19 +5815,12 @@ impl AccountsDb {
.scan_account_storage(
slot,
|loaded_account: LoadedAccount| {
if self.is_filler_account(loaded_account.pubkey()) {
None
} else {
// Cache only has one version per key, don't need to worry about versioning
Some((*loaded_account.pubkey(), loaded_account.loaded_hash()))
}
},
|accum: &DashMap<Pubkey, (u64, Hash)>, loaded_account: LoadedAccount| {
let loaded_write_version = loaded_account.write_version();
let loaded_hash = loaded_account.loaded_hash();
if self.is_filler_account(loaded_account.pubkey()) {
return;
}
// keep the latest write version for each pubkey
match accum.entry(*loaded_account.pubkey()) {
Occupied(mut occupied_entry) => {
@ -5845,7 +5838,7 @@ impl AccountsDb {
scan.stop();
let mut accumulate = Measure::start("accumulate");
let hashes: Vec<_> = match scan_result {
let mut hashes: Vec<_> = match scan_result {
ScanStorageResult::Cached(cached_result) => cached_result,
ScanStorageResult::Stored(stored_result) => stored_result
.into_iter()
@ -5854,6 +5847,11 @@ impl AccountsDb {
};
let dirty_keys = hashes.iter().map(|(pubkey, _hash)| *pubkey).collect();
if self.filler_accounts_enabled() {
// filler accounts must be added to 'dirty_keys' above but cannot be used to calculate hash
hashes.retain(|(pubkey, _hash)| !self.is_filler_account(pubkey));
}
let ret = AccountsHash::accumulate_account_hashes(hashes);
accumulate.stop();
let mut uncleaned_time = Measure::start("uncleaned_index");
@ -6748,10 +6746,16 @@ impl AccountsDb {
.unwrap_or_default()
}
/// true if 'pubkey' is a filler account
pub fn is_filler_account(&self, pubkey: &Pubkey) -> bool {
Self::is_filler_account_helper(pubkey, self.filler_account_suffix.as_ref())
}
/// true if it is possible that there are filler accounts present
pub fn filler_accounts_enabled(&self) -> bool {
self.filler_account_suffix.is_some()
}
/// retain slots in 'roots' that are > (max(roots) - slots_per_epoch)
fn retain_roots_within_one_epoch_range(roots: &mut Vec<Slot>, slots_per_epoch: SlotCount) {
if let Some(max) = roots.iter().max() {