Skip to content

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 a0b04ae
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 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,29 @@ 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);
}
}
return 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 a0b04ae

Please sign in to comment.