Skip to content

Add method client_service::is_prepared_xa() #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dbsim/db_client_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ namespace db
return false;
}

bool is_prepared_xa() override
{
return false;
}

bool is_xa_rollback() override
{
return false;
Expand Down
10 changes: 10 additions & 0 deletions include/wsrep/client_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ namespace wsrep
*/
virtual bool is_explicit_xa() = 0;

/**
* Returns true if the client has an ongoing XA transaction
* in prepared state.
* Notice: one could simply check if wsrep::transaction is
* in s_prepared state. However, wsrep::transaction does not
* transition to prepared state for read-only / empty
* transactions.
*/
virtual bool is_prepared_xa() = 0;

/**
* Returns true if the currently executing command is
* a rollback for XA. This is used to avoid setting a
Expand Down
3 changes: 1 addition & 2 deletions src/client_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ void wsrep::client_state::close()
keep_command_error_ = false;
lock.unlock();
if (transaction_.active() &&
(mode_ != m_local ||
transaction_.state() != wsrep::transaction::s_prepared))
(mode_ != m_local || !client_service_.is_prepared_xa()))
{
client_service_.bf_rollback();
transaction_.after_statement();
Expand Down
5 changes: 5 additions & 0 deletions test/mock_client_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ namespace wsrep
return false;
}

bool is_prepared_xa() WSREP_OVERRIDE
{
return false;
}

bool is_xa_rollback() WSREP_OVERRIDE
{
return false;
Expand Down