diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index ad9157b817..da82cc4c86 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -2000,7 +2000,7 @@ impl AccountsDb { timings: &mut CleanKeyTimings, ) -> Vec { let mut dirty_store_processing_time = Measure::start("dirty_store_processing"); - let max_slot = max_clean_root.unwrap_or_else(|| self.accounts_index.max_root()); + let max_slot = max_clean_root.unwrap_or_else(|| self.accounts_index.max_root_inclusive()); let mut dirty_stores = Vec::with_capacity(self.dirty_stores.len()); self.dirty_stores.retain(|(slot, _store_id), store| { if *slot > max_slot { diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 74eb53436d..6832c32e9e 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -615,7 +615,7 @@ impl RollingBitField { #[derive(Debug)] pub struct RootsTracker { roots: RollingBitField, - max_root: Slot, + max_root_inclusive: Slot, uncleaned_roots: HashSet, previous_uncleaned_roots: HashSet, } @@ -633,7 +633,7 @@ impl RootsTracker { pub fn new(max_width: u64) -> Self { Self { roots: RollingBitField::new(max_width), - max_root: 0, + max_root_inclusive: 0, uncleaned_roots: HashSet::new(), previous_uncleaned_roots: HashSet::new(), } @@ -958,10 +958,10 @@ impl AccountsIndex { // the `ongoing_scan_roots` lock is held, // make sure inverse doesn't happen to avoid // deadlock - let max_root = self.max_root(); - *w_ongoing_scan_roots.entry(max_root).or_default() += 1; + let max_root_inclusive = self.max_root_inclusive(); + *w_ongoing_scan_roots.entry(max_root_inclusive).or_default() += 1; - max_root + max_root_inclusive }; // First we show that for any bank `B` that is a descendant of @@ -1793,7 +1793,7 @@ impl AccountsIndex { let roots_tracker = &self.roots_tracker.read().unwrap(); let newest_root_in_slot_list = Self::get_newest_root_in_slot_list(&roots_tracker.roots, slot_list, max_clean_root); - let max_clean_root = max_clean_root.unwrap_or(roots_tracker.max_root); + let max_clean_root = max_clean_root.unwrap_or(roots_tracker.max_root_inclusive); slot_list.retain(|(slot, value)| { let should_purge = @@ -1874,8 +1874,8 @@ impl AccountsIndex { w_roots_tracker.uncleaned_roots.insert(slot); } // `AccountsDb::flush_accounts_cache()` relies on roots being added in order - assert!(slot >= w_roots_tracker.max_root); - w_roots_tracker.max_root = slot; + assert!(slot >= w_roots_tracker.max_root_inclusive); + w_roots_tracker.max_root_inclusive = slot; } pub fn add_uncleaned_roots(&self, roots: I) @@ -1886,8 +1886,8 @@ impl AccountsIndex { w_roots_tracker.uncleaned_roots.extend(roots); } - pub fn max_root(&self) -> Slot { - self.roots_tracker.read().unwrap().max_root + pub fn max_root_inclusive(&self) -> Slot { + self.roots_tracker.read().unwrap().max_root_inclusive } /// Remove the slot when the storage for the slot is freed