mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
Minimize client_service interface for XA
Remove methods `is_xa()`, `is_xa_prepare()`, and `xid()` from client_service interface. Instead, transactions are explicitly assigned their xid, through at start of XA.
This commit is contained in:
@ -73,24 +73,6 @@ namespace wsrep
|
||||
*/
|
||||
virtual void cleanup_transaction() = 0;
|
||||
|
||||
//
|
||||
// XA
|
||||
//
|
||||
/**
|
||||
* Return true if the current transactions is XA
|
||||
*/
|
||||
virtual bool is_xa() const = 0;
|
||||
|
||||
/**
|
||||
* Return true if the current statement is XA PREPARE
|
||||
*/
|
||||
virtual bool is_xa_prepare() const = 0;
|
||||
|
||||
/**
|
||||
* Return a string representing the xid of the transaction
|
||||
*/
|
||||
virtual std::string xid() const = 0;
|
||||
|
||||
//
|
||||
// Streaming
|
||||
//
|
||||
|
@ -305,36 +305,6 @@ namespace wsrep
|
||||
return transaction_.assign_read_view(gtid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the client's transaction to prepared state
|
||||
*
|
||||
* The purpose of this method is to restore transaction state
|
||||
* during recovery of a prepared XA transaction.
|
||||
*/
|
||||
int restore_prepared_transaction()
|
||||
{
|
||||
return transaction_.restore_to_prepared_state();
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminate transaction with the given xid
|
||||
*
|
||||
* Sends a commit or rollback fragment to terminate the a
|
||||
* transaction with the given xid. For the fragment to be
|
||||
* sent, a streaming applier for the transaction must exist
|
||||
* and the transaction must be in prepared state.
|
||||
*
|
||||
* @param xid the xid of the the transaction to terminate
|
||||
* @param commit whether to send a commmit or rollback fragment
|
||||
*
|
||||
* @return Zero on success, non-zero on error. In case of error
|
||||
* the client_state's current_error is set
|
||||
*/
|
||||
int commit_or_rollback_by_xid(const std::string& xid, bool commit)
|
||||
{
|
||||
return transaction_.commit_or_rollback_by_xid(xid, commit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a key into transaction write set.
|
||||
*
|
||||
@ -552,6 +522,52 @@ namespace wsrep
|
||||
void wait_rollback_complete_and_acquire_ownership();
|
||||
/** @} */
|
||||
|
||||
//
|
||||
// XA
|
||||
//
|
||||
/**
|
||||
* Assign transaction external id.
|
||||
*
|
||||
* Other than storing the xid, the transaction is marked as XA.
|
||||
* This should be called when XA transaction is started.
|
||||
*
|
||||
* @param xid transaction id
|
||||
*/
|
||||
void assign_xid(const std::string& xid)
|
||||
{
|
||||
transaction_.assign_xid(xid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the client's transaction to prepared state
|
||||
*
|
||||
* The purpose of this method is to restore transaction state
|
||||
* during recovery of a prepared XA transaction.
|
||||
*/
|
||||
int restore_xid(std::string& xid)
|
||||
{
|
||||
return transaction_.restore_to_prepared_state(xid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminate transaction with the given xid
|
||||
*
|
||||
* Sends a commit or rollback fragment to terminate a
|
||||
* transaction with the given xid. For the fragment to be
|
||||
* sent, a streaming applier for the transaction must exist
|
||||
* and the transaction must be in prepared state.
|
||||
*
|
||||
* @param xid the xid of the the transaction to terminate
|
||||
* @param commit whether to send a commmit or rollback fragment
|
||||
*
|
||||
* @return Zero on success, non-zero on error. In case of error
|
||||
* the client_state's current_error is set
|
||||
*/
|
||||
int commit_or_rollback_by_xid(const std::string& xid, bool commit)
|
||||
{
|
||||
return transaction_.commit_or_rollback_by_xid(xid, commit);
|
||||
}
|
||||
|
||||
//
|
||||
// BF aborting
|
||||
//
|
||||
|
@ -124,23 +124,25 @@ namespace wsrep
|
||||
|
||||
bool is_xa() const
|
||||
{
|
||||
return client_service_.is_xa();
|
||||
return !xid_.empty();
|
||||
}
|
||||
|
||||
bool is_xa_prepare() const
|
||||
void assign_xid(const std::string& xid)
|
||||
{
|
||||
return client_service_.is_xa_prepare();
|
||||
assert(active());
|
||||
assert(xid_.empty());
|
||||
xid_ = xid;
|
||||
}
|
||||
|
||||
int restore_to_prepared_state();
|
||||
|
||||
int commit_or_rollback_by_xid(const std::string& xid, bool commit);
|
||||
|
||||
const std::string xid() const
|
||||
{
|
||||
return client_service_.xid();
|
||||
return xid_;
|
||||
}
|
||||
|
||||
int restore_to_prepared_state(const std::string& xid);
|
||||
|
||||
int commit_or_rollback_by_xid(const std::string& xid, bool commit);
|
||||
|
||||
bool pa_unsafe() const { return pa_unsafe_; }
|
||||
void pa_unsafe(bool pa_unsafe) { pa_unsafe_ = pa_unsafe; }
|
||||
|
||||
@ -239,7 +241,7 @@ namespace wsrep
|
||||
// The call will adjust transaction state and set client_state
|
||||
// error status accordingly.
|
||||
bool abort_or_interrupt(wsrep::unique_lock<wsrep::mutex>&);
|
||||
int streaming_step(wsrep::unique_lock<wsrep::mutex>&);
|
||||
int streaming_step(wsrep::unique_lock<wsrep::mutex>&, bool force = false);
|
||||
int certify_fragment(wsrep::unique_lock<wsrep::mutex>&);
|
||||
int certify_commit(wsrep::unique_lock<wsrep::mutex>&);
|
||||
int append_sr_keys_for_commit();
|
||||
@ -271,7 +273,7 @@ namespace wsrep
|
||||
wsrep::streaming_context streaming_context_;
|
||||
wsrep::sr_key_set sr_keys_;
|
||||
wsrep::mutable_buffer apply_error_buf_;
|
||||
bool is_recovered_xa_;
|
||||
std::string xid_;
|
||||
};
|
||||
|
||||
static inline const char* to_c_string(enum wsrep::transaction::state state)
|
||||
|
Reference in New Issue
Block a user