1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-24 10:42:31 +03:00

Fix cleanup for non-prepared XA transactions

Cleanup XA transaction which is marked as prepared in DBMS, but not in
wsrep-lib side. This may happen if the DBMS runs with wsrep disabled.
This commit is contained in:
Daniele Sciascia
2022-04-08 14:44:22 +02:00
parent 23fb862462
commit 8bfce04189
2 changed files with 10 additions and 6 deletions

View File

@ -633,7 +633,7 @@ namespace wsrep
void xa_detach()
{
assert(mode_ == m_local);
assert(state_ == s_none || state_ == s_exec);
assert(state_ == s_none || state_ == s_exec || state_ == s_quitting);
transaction_.xa_detach();
}

View File

@ -1193,11 +1193,15 @@ int wsrep::transaction::commit_or_rollback_by_xid(const wsrep::xid& xid,
void wsrep::transaction::xa_detach()
{
debug_log_state("xa_detach enter");
assert(state() == s_prepared);
wsrep::server_state& server_state(client_state_.server_state());
server_state.convert_streaming_client_to_applier(&client_state_);
client_service_.store_globals();
client_service_.cleanup_transaction();
assert(state() == s_prepared ||
client_state_.state() == wsrep::client_state::s_quitting);
if (state() == s_prepared)
{
wsrep::server_state& server_state(client_state_.server_state());
server_state.convert_streaming_client_to_applier(&client_state_);
client_service_.store_globals();
client_service_.cleanup_transaction();
}
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex_);
streaming_context_.cleanup();
state(lock, s_aborting);