correctly clean filler accounts (#21139)
This commit is contained in:
parent
140a5f633d
commit
c0952831be
|
@ -5815,19 +5815,12 @@ impl AccountsDb {
|
||||||
.scan_account_storage(
|
.scan_account_storage(
|
||||||
slot,
|
slot,
|
||||||
|loaded_account: LoadedAccount| {
|
|loaded_account: LoadedAccount| {
|
||||||
if self.is_filler_account(loaded_account.pubkey()) {
|
// Cache only has one version per key, don't need to worry about versioning
|
||||||
None
|
Some((*loaded_account.pubkey(), loaded_account.loaded_hash()))
|
||||||
} 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| {
|
|accum: &DashMap<Pubkey, (u64, Hash)>, loaded_account: LoadedAccount| {
|
||||||
let loaded_write_version = loaded_account.write_version();
|
let loaded_write_version = loaded_account.write_version();
|
||||||
let loaded_hash = loaded_account.loaded_hash();
|
let loaded_hash = loaded_account.loaded_hash();
|
||||||
if self.is_filler_account(loaded_account.pubkey()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// keep the latest write version for each pubkey
|
// keep the latest write version for each pubkey
|
||||||
match accum.entry(*loaded_account.pubkey()) {
|
match accum.entry(*loaded_account.pubkey()) {
|
||||||
Occupied(mut occupied_entry) => {
|
Occupied(mut occupied_entry) => {
|
||||||
|
@ -5845,7 +5838,7 @@ impl AccountsDb {
|
||||||
scan.stop();
|
scan.stop();
|
||||||
|
|
||||||
let mut accumulate = Measure::start("accumulate");
|
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::Cached(cached_result) => cached_result,
|
||||||
ScanStorageResult::Stored(stored_result) => stored_result
|
ScanStorageResult::Stored(stored_result) => stored_result
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -5854,6 +5847,11 @@ impl AccountsDb {
|
||||||
};
|
};
|
||||||
let dirty_keys = hashes.iter().map(|(pubkey, _hash)| *pubkey).collect();
|
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);
|
let ret = AccountsHash::accumulate_account_hashes(hashes);
|
||||||
accumulate.stop();
|
accumulate.stop();
|
||||||
let mut uncleaned_time = Measure::start("uncleaned_index");
|
let mut uncleaned_time = Measure::start("uncleaned_index");
|
||||||
|
@ -6748,10 +6746,16 @@ impl AccountsDb {
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// true if 'pubkey' is a filler account
|
||||||
pub fn is_filler_account(&self, pubkey: &Pubkey) -> bool {
|
pub fn is_filler_account(&self, pubkey: &Pubkey) -> bool {
|
||||||
Self::is_filler_account_helper(pubkey, self.filler_account_suffix.as_ref())
|
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)
|
/// 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) {
|
fn retain_roots_within_one_epoch_range(roots: &mut Vec<Slot>, slots_per_epoch: SlotCount) {
|
||||||
if let Some(max) = roots.iter().max() {
|
if let Some(max) = roots.iter().max() {
|
||||||
|
|
Loading…
Reference in New Issue