Fix race condition in store.
Multiple threads can enter the read lock and all store the new empty set to account_maps. Check again after taking write lock to make sure only one thread actually inserts the new entry.
This commit is contained in:
parent
0be59cad4e
commit
22855def27
|
@ -513,7 +513,9 @@ impl AccountsDB {
|
|||
.contains_key(&pubkey)
|
||||
{
|
||||
let mut waccount_maps = self.account_index.account_maps.write().unwrap();
|
||||
waccount_maps.insert(*pubkey, RwLock::new(HashMap::new()));
|
||||
if !waccount_maps.contains_key(&pubkey) {
|
||||
waccount_maps.insert(*pubkey, RwLock::new(HashMap::new()));
|
||||
}
|
||||
}
|
||||
}
|
||||
self.store_account(fork, pubkey, account);
|
||||
|
|
Loading…
Reference in New Issue