Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
[WIP] immediately un-reserve CU of txs that failed to get lock
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Jan 24, 2024
1 parent 0a221c1 commit 7d7efcc
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ impl Consumer {
pre_results: impl Iterator<Item = Result<(), TransactionError>>,
) -> ProcessTransactionBatchOutput {
let (
(transaction_qos_cost_results, cost_model_throttled_transactions_count),
(mut transaction_qos_cost_results, cost_model_throttled_transactions_count),
cost_model_us,
) = measure_us!(self.qos_service.select_and_accumulate_transaction_costs(
bank,
Expand All @@ -479,6 +479,31 @@ impl Consumer {
})
));

// Remove reserved block space for transaction failed to acquire lock
let unlocked_cost_results: Vec<_> = batch
.lock_results()
.iter()
.zip(transaction_qos_cost_results.iter_mut())
.map(|(lock_result, cost)| {
if let Err(_lock_err) = lock_result {
if let Ok(tx_cost) = cost {
// reset cost to lock_err, so it won't be accidentally removed more than once
// TODO *cost = Err(lock_err.clone());
return Some(tx_cost);
}
}
None
})
.collect();
{
let mut cost_tracker = bank.write_cost_tracker().unwrap();
unlocked_cost_results.iter().for_each(|tx_cost| {
if let Some(tx_cost) = tx_cost {
cost_tracker.remove(tx_cost);
}
});
}

// retryable_txs includes AccountInUse, WouldExceedMaxBlockCostLimit
// WouldExceedMaxAccountCostLimit, WouldExceedMaxVoteCostLimit
// and WouldExceedMaxAccountDataCostLimit
Expand Down

0 comments on commit 7d7efcc

Please sign in to comment.