log metric in case of race condition (#27951)

This commit is contained in:
Jeff Washington (jwash) 2022-09-20 16:23:25 -07:00 committed by GitHub
parent ab8b3386a1
commit 6e24edb771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -277,6 +277,10 @@ impl AccountsCache {
}
}
pub fn contains_any_slots(&self, max_slot_inclusive: Slot) -> bool {
self.cache.iter().any(|e| e.key() <= &max_slot_inclusive)
}
// Removes slots less than or equal to `max_root`. Only safe to pass in a rooted slot,
// otherwise the slot removed could still be undergoing replay!
pub fn remove_slots_le(&self, max_root: Slot) -> Vec<(Slot, SlotCache)> {

View File

@ -7103,6 +7103,11 @@ impl AccountsDb {
config: &CalcAccountsHashConfig<'_>,
) -> Result<(Hash, u64), BankHashVerificationError> {
if !use_index {
if !config.use_write_cache && self.accounts_cache.contains_any_slots(slot) {
// this indicates a race condition
inc_new_counter_info!("accounts_hash_items_in_write_cache", 1);
}
let mut collect_time = Measure::start("collect");
let (combined_maps, slots) = self.get_snapshot_storages(slot, None, config.ancestors);
collect_time.stop();