From d02a08b8848ffb44d77671fe27a8d94838523047 Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Thu, 3 Oct 2024 09:25:34 -0500 Subject: [PATCH] always unlock in schedule_batches_for_execution --- ledger/src/blockstore_processor.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 04d4e6f9fcb0a9..096fb2eb6b59b6 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -425,6 +425,10 @@ fn schedule_batches_for_execution( bank: &BankWithScheduler, locked_entries: impl Iterator>, ) -> Result<()> { + // Track the first error encountered in the loop below, if any. + // This error will be propagated to the replay stage, or Ok(()). + let mut first_err = Ok(()); + for LockedTransactionsWithIndexes { lock_results, transactions, @@ -433,15 +437,19 @@ fn schedule_batches_for_execution( { // unlock before sending to scheduler. bank.unlock_accounts(transactions.iter().zip(lock_results.iter())); - // give ownership to scheduler - bank.schedule_transaction_executions( - transactions - .into_iter() - .enumerate() - .map(|(index, tx)| (tx, index + starting_index)), - )?; + // give ownership to scheduler. capture the first error, but continue the loop + // to unlock. + // scheduling is skipped if we have already detected an error in this loop + first_err = first_err.and_then(|()| { + bank.schedule_transaction_executions( + transactions + .into_iter() + .enumerate() + .map(|(index, tx)| (tx, index + starting_index)), + ) + }); } - Ok(()) + first_err } fn rebatch_transactions<'a>(