Skip to content

Commit

Permalink
TestKit: allow new transaction after tx failure
Browse files Browse the repository at this point in the history
  • Loading branch information
robsdedude committed Jan 20, 2024
1 parent a35f401 commit e0f52a9
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions testkit_backend/src/testkit_backend/session_holder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,19 @@ impl SessionHolderRunner {
}

command @ (Command::BeginTransaction(_)
| Command::TransactionFunction(_)|Command::AutoCommit(_)) => command.reply_error(
tx_res, session_already_executing_tx_error()
),
| Command::TransactionFunction(_)|Command::AutoCommit(_)) => {
if known_transactions
.get(&id)
.map(|tx| matches!(tx, TxFailState::Failed))
.unwrap_or(false) {
// transaction failed, therefore, we allow to start a new one
_ = buffered_command.insert(command);
return Ok(());
}
command.reply_error(
tx_res, session_already_executing_tx_error(),
)
}
command @ (Command::RetryablePositive(_)
| Command::RetryableNegative(_)) => {
command.reply_error(
Expand Down Expand Up @@ -691,6 +701,11 @@ impl SessionHolderRunner {
.unwrap();
return;
}
command @ (Command::BeginTransaction(_)
| Command::TransactionFunction(_)|Command::AutoCommit(_)) => {
res.expect("expected failed transaction to not error");
_ = buffered_command.insert(command);
}
_ => panic!(
"left transaction function with unexpected buffered command {command:?}"
),
Expand Down

0 comments on commit e0f52a9

Please sign in to comment.