Skip to content

Commit 546dac0

Browse files
committed
Add method client_service::is_prepared_xa()
1 parent a5d95f0 commit 546dac0

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Diff for: include/wsrep/client_service.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,16 @@ namespace wsrep
194194
*/
195195
virtual bool is_explicit_xa() = 0;
196196

197+
/**
198+
* Returns true if the client has an ongoing XA transaction
199+
* in prepared state.
200+
* Notice: one could simply check if wsrep::transaction is
201+
* in s_prepared state. However, wsrep::transaction does not
202+
* transition to prepared state for read-only / empty
203+
* transactions.
204+
*/
205+
virtual bool is_prepared_xa() = 0;
206+
197207
/**
198208
* Returns true if the currently executing command is
199209
* a rollback for XA. This is used to avoid setting a

Diff for: src/client_state.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ void wsrep::client_state::close()
6868
keep_command_error_ = false;
6969
lock.unlock();
7070
if (transaction_.active() &&
71-
(mode_ != m_local ||
72-
transaction_.state() != wsrep::transaction::s_prepared))
71+
(mode_ != m_local || !client_service_.is_prepared_xa()))
7372
{
7473
client_service_.bf_rollback();
7574
transaction_.after_statement();

Diff for: test/mock_client_state.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ namespace wsrep
176176
return false;
177177
}
178178

179+
bool is_prepared_xa() WSREP_OVERRIDE
180+
{
181+
return false;
182+
}
183+
179184
bool is_xa_rollback() WSREP_OVERRIDE
180185
{
181186
return false;

0 commit comments

Comments
 (0)