diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index c1c7164e7f..3c59a27941 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -525,25 +525,24 @@ impl Accounts { /// Commit remaining credit-only changes, regardless of reference count pub fn commit_credits(&self, ancestors: &HashMap, fork: Fork) { - let credit_only_account_locks = self.credit_only_account_locks.read().unwrap(); - for (pubkey, credit_only_lock) in credit_only_account_locks.iter() { - let credit = credit_only_lock.credits.load(Ordering::Relaxed); + for (pubkey, lock) in self.credit_only_account_locks.write().unwrap().drain() { + let lock_count = *lock.lock_count.lock().unwrap(); + if lock_count != 0 { + warn!( + "dropping credit-only lock on {}, still has {} locks", + pubkey, lock_count + ); + } + let credit = lock.credits.load(Ordering::Relaxed); if credit > 0 { let mut account = self - .load_slow(ancestors, pubkey) + .load_slow(ancestors, &pubkey) .map(|(account, _)| account) .unwrap_or_default(); account.lamports += credit; - self.store_slow(fork, pubkey, &account); + self.store_slow(fork, &pubkey, &account); } } - drop(credit_only_account_locks); - self.clear_credit_only_account_locks(); - } - - pub fn clear_credit_only_account_locks(&self) { - let mut credit_only_account_locks = self.credit_only_account_locks.write().unwrap(); - credit_only_account_locks.clear(); } fn collect_accounts<'a>( diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 18b152c6ea..36380c5f08 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -344,7 +344,6 @@ impl Bank { self.collector_id = *collector_id; self.rc.accounts = Arc::new(Accounts::new_from_parent(&parent.rc.accounts)); - self.clear_credit_only_account_locks(); self.epoch_stakes = { let mut epoch_stakes = parent.epoch_stakes.clone(); @@ -1417,9 +1416,6 @@ impl Bank { .accounts .commit_credits(&self.ancestors, self.slot()); } - fn clear_credit_only_account_locks(&self) { - self.rc.accounts.clear_credit_only_account_locks(); - } } impl Drop for Bank {