race condition when running solana-program-test (#31637)

* hold bank freeze lock in banks-server to prevent RC on slot change

* clean up comments and loop

---------

Co-authored-by: Maximilian Schneider <max@mango.markets>
This commit is contained in:
Maximilian Schneider 2023-05-15 21:25:06 +02:00 committed by GitHub
parent 950892e503
commit 31aafc8ae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -85,8 +85,18 @@ impl BanksServer {
.into_iter()
.map(|info| deserialize(&info.wire_transaction).unwrap())
.collect();
let bank = bank_forks.read().unwrap().working_bank();
let _ = bank.try_process_transactions(transactions.iter());
loop {
let bank = bank_forks.read().unwrap().working_bank();
// bank forks lock released, now verify bank hasn't been frozen yet
// in the mean-time the bank can not be frozen until this tx batch
// has been processed
let lock = bank.freeze_lock();
if *lock == Hash::default() {
let _ = bank.try_process_transactions(transactions.iter());
// break out of inner loop and release bank freeze lock
break;
}
}
}
}

View File

@ -3187,8 +3187,8 @@ impl Bank {
pub fn freeze(&self) {
// This lock prevents any new commits from BankingStage
// `process_and_record_transactions_locked()` from coming
// in after the last tick is observed. This is because in
// `Consumer::execute_and_commit_transactions_locked()` from
// coming in after the last tick is observed. This is because in
// BankingStage, any transaction successfully recorded in
// `record_transactions()` is recorded after this `hash` lock
// is grabbed. At the time of the successful record,