From dfc4bdb8a5dcbd6fbea007ad3beff899a6b5b7bd Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 6 Mar 2024 17:42:28 +0100 Subject: [PATCH] Do not abort prepared transaction when statement is interrupted In `transaction::abort_or_interrupt()` handle the case were a statement is interrupted while transaction is in prepared state. In which case, the transaction must remain in prepared state, until it is committed (or rolled back). Also in this patch: remove check for reduntant `s_must_abort` state. --- src/transaction.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/transaction.cpp b/src/transaction.cpp index 451e94d..7d9e31e 100644 --- a/src/transaction.cpp +++ b/src/transaction.cpp @@ -1400,10 +1400,19 @@ bool wsrep::transaction::abort_or_interrupt( } return true; } - else if (client_service_.interrupted(lock)) + + if (client_service_.interrupted(lock)) { + assert(state() != s_must_abort && + state() != s_aborting && + state() != s_aborted); + + // Client was interrupted. Set the appropriate error and abort. + // For transactions in prepared state, it is OK to interrupt the + // statement, but transaction must remain in prepared state until + // commit or rollback. client_state_.override_error(wsrep::e_interrupted_error); - if (state() != s_must_abort) + if (state() != s_prepared) { state(lock, s_must_abort); }