AcctIdx: delete from disk index (#20035)

This commit is contained in:
Jeff Washington (jwash) 2021-09-20 16:19:21 -05:00 committed by GitHub
parent e12e8bc431
commit 94330de843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -126,6 +126,14 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
if let Entry::Occupied(index_entry) = entry { if let Entry::Occupied(index_entry) = entry {
if index_entry.get().slot_list.read().unwrap().is_empty() { if index_entry.get().slot_list.read().unwrap().is_empty() {
index_entry.remove(); index_entry.remove();
// note there is a potential race here that has existed.
// if someone else holds the arc,
// then they think the item is still in the index and can make modifications.
// We have to have a write lock to the map here, which means nobody else can get
// the arc, but someone may already have retreived a clone of it.
if let Some(disk) = self.storage.disk.as_ref() {
disk.delete_key(&pubkey)
}
self.stats().insert_or_delete(false, self.bin); self.stats().insert_or_delete(false, self.bin);
return true; return true;
} }