AcctIdx: check for range holds outside lock (#23706)
This commit is contained in:
parent
caddb851be
commit
be0aeea01a
|
@ -1045,7 +1045,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
|
|||
// return true if the removal was completed
|
||||
fn evict_from_cache(
|
||||
&self,
|
||||
evictions: Vec<Pubkey>,
|
||||
mut evictions: Vec<Pubkey>,
|
||||
current_age: Age,
|
||||
startup: bool,
|
||||
randomly_evicted: bool,
|
||||
|
@ -1060,7 +1060,20 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
|
|||
if self.get_stop_evictions() {
|
||||
return false; // did NOT complete, ranges were changed, so have to restart
|
||||
}
|
||||
|
||||
// skip any keys that are held in memory because of ranges being held
|
||||
let ranges = self.cache_ranges_held.read().unwrap().clone();
|
||||
if !ranges.is_empty() {
|
||||
evictions.retain(|k| {
|
||||
if ranges.iter().any(|range| range.contains(k)) {
|
||||
// this item is held in mem by range, so don't remove
|
||||
completed_scan = false;
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let mut removed = 0;
|
||||
// consider chunking these so we don't hold the write lock too long
|
||||
|
@ -1086,12 +1099,6 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ranges.iter().any(|range| range.contains(&k)) {
|
||||
// this item is held in mem by range, so don't remove
|
||||
completed_scan = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if stop_evictions_changes_at_start != self.get_stop_evictions_changes() {
|
||||
return false; // did NOT complete, ranges were changed, so have to restart
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue