1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-06-11 16:48:11 +03:00

Support for replaying prepared XA transactions

This patch implments replaying for prepared XA transactions.
Replay may happen in the following cases:

1) The transaction is BF aborted in prepared state and is idle. In
that case, the transaction is handed over to rollbacker for replay.

2) The transaction is BF aborted while executing the
commit (i.e. before or after successful certification). In
which case the transaction replays itself from fragment storage.

3) The transaction is BF aborted while certifying its commit
fragment. This case is handled like replay for streaming transactions,
where the provider is directly involved and re-delivers the last
fragment.
This commit is contained in:
Daniele Sciascia
2020-06-05 11:40:18 +02:00
parent 965642eded
commit b12bbd059c
7 changed files with 333 additions and 57 deletions

View File

@ -145,6 +145,11 @@ namespace wsrep
*/
virtual void will_replay() = 0;
/**
* Signal that replay is done.
*/
virtual void signal_replayed() = 0;
/**
* Replay the current transaction. The implementation must put
* the caller Client Context into applying mode and call
@ -155,6 +160,13 @@ namespace wsrep
*/
virtual enum wsrep::provider::status replay() = 0;
/**
* Replay the current transaction. This is used for replaying
* prepared XA transactions, which are BF aborted but not
* while orderding commit / rollback.
*/
virtual enum wsrep::provider::status replay_unordered() = 0;
/**
* Wait until all replaying transactions have been finished
* replaying.
@ -164,6 +176,32 @@ namespace wsrep
*/
virtual void wait_for_replayers(wsrep::unique_lock<wsrep::mutex>&) = 0;
//
// XA
//
/**
* Send a commit by xid
*/
virtual enum wsrep::provider::status commit_by_xid() = 0;
/*
Returns true if the client has an ongoing XA transaction.
This method is used to determine when to cleanup the
corresponding wsrep-lib transaction object.
This method should return false when the XA transaction
is over, and the wsrep-lib transaction object can be
cleaned up.
*/
virtual bool is_explicit_xa() = 0;
/**
* Returns true if the currently executing command is
* a rollback for XA. This is used to avoid setting a
* a deadlock error rollback as it may be unexpected
* by the DBMS.
*/
virtual bool is_xa_rollback() = 0;
//
// Debug interface
//

View File

@ -604,6 +604,23 @@ namespace wsrep
transaction_.xa_detach();
}
/**
* Replay a XA transaction
*
* Replay a XA transaction that is in s_idle state.
* This may happen if the transaction is BF aborted
* between prepare and commit.
* Since the victim is idle, this method can be called
* by the BF aborter or the backround rollbacker.
*/
void xa_replay()
{
assert(mode_ == m_local);
assert(state_ == s_idle);
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
transaction_.xa_replay(lock);
}
//
// BF aborting
//

View File

@ -146,6 +146,8 @@ namespace wsrep
void xa_detach();
int xa_replay(wsrep::unique_lock<wsrep::mutex>&);
bool pa_unsafe() const { return pa_unsafe_; }
void pa_unsafe(bool pa_unsafe) { pa_unsafe_ = pa_unsafe; }