MySQL 9.1.0
Source Code Documentation
xa.h File Reference
#include <string.h>
#include <sys/types.h>
#include <list>
#include <mutex>
#include "lex_string.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_sqlcommand.h"
#include "mysql/binlog/event/control_events.h"
#include "sql/malloc_allocator.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_cmd.h"
#include "sql/sql_list.h"
#include "sql/sql_plugin_ref.h"
#include "sql/xa_aux.h"

Go to the source code of this file.

Classes

struct  xid_t
 struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification, Distributed Transaction Processing: The XA Specification, X/Open Company Ltd., 1991. More...
 
struct  st_xarecover_txn
 Plain structure to store information about XA transaction id and a list of table names involved into XA transaction with specified id. More...
 
class  XID_STATE
 
class  Recovered_xa_transactions
 This class servers as a registry for prepared XA transactions existed before server was shutdown and being resurrected during the server restart. More...
 

Macros

#define MYSQL_XID_PREFIX   "MySQLXid"
 
#define XIDDATASIZE   128
 

Typedefs

typedef int64 query_id_t
 
typedef ulonglong my_xid
 
typedef struct xid_t XID
 struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification, Distributed Transaction Processing: The XA Specification, X/Open Company Ltd., 1991. More...
 
typedef struct st_xarecover_txn XA_recover_txn
 Plain structure to store information about XA transaction id and a list of table names involved into XA transaction with specified id. More...
 

Enumerations

enum  xa_option_words {
  XA_NONE , XA_JOIN , XA_RESUME , XA_ONE_PHASE ,
  XA_SUSPEND , XA_FOR_MIGRATE
}
 

Functions

bool applier_reset_xa_trans (THD *thd)
 This is a specific to "slave" applier collection of standard cleanup actions to reset XA transaction state at the end of XA prepare rather than to do it at the transaction commit, see ha_commit_one_phase. More...
 
struct st_plugin_intplugin_find_by_type (const LEX_CSTRING &plugin, int type)
 Searches for a correctly loaded plugin of a particular type by name. More...
 
bool detach_native_trx (THD *thd, plugin_ref plugin, void *)
 The function detaches existing storage engines transaction context from thd. More...
 
bool reattach_native_trx (THD *thd, plugin_ref plugin, void *)
 The function reattaches existing storage engines transaction context to thd. More...
 
void cleanup_trans_state (THD *thd)
 Reset some transaction state information and delete corresponding Transaction_ctx object from cache. More...
 
std::shared_ptr< Transaction_ctxfind_trn_for_recover_and_check_its_state (THD *thd, xid_t *xid_for_trn_in_recover, XID_STATE *xid_state)
 Find XA transaction in cache by its xid value. More...
 
bool acquire_mandatory_metadata_locks (THD *thd, xid_t *detached_xid)
 Acquire Commit metadata lock and all locks acquired by a prepared XA transaction before server was shutdown or terminated. More...
 
bool xa_trans_force_rollback (THD *thd)
 Rollback the active XA transaction. More...
 
bool disconnect_native_trx (THD *, plugin_ref, void *)
 Disconnect transaction in SE. More...
 
bool thd_holds_xa_transaction (THD *thd)
 Test if the THD session underlying transaction is an externally coordinated (XA) transaction. More...
 
bool is_xa_prepare (THD *thd)
 Checks whether or not the underlying statement is an XA PREPARE. More...
 
bool is_xa_rollback (THD *thd)
 Checks whether or not the underlying statement is an XA ROLLBACK. More...
 

Variables

static const int TC_HEURISTIC_NOT_USED = 0
 
static const int TC_HEURISTIC_RECOVER_COMMIT = 1
 
static const int TC_HEURISTIC_RECOVER_ROLLBACK = 2
 

Macro Definition Documentation

◆ MYSQL_XID_PREFIX

#define MYSQL_XID_PREFIX   "MySQLXid"

◆ XIDDATASIZE

#define XIDDATASIZE   128

Typedef Documentation

◆ my_xid

typedef ulonglong my_xid

◆ query_id_t

typedef int64 query_id_t

◆ XA_recover_txn

Plain structure to store information about XA transaction id and a list of table names involved into XA transaction with specified id.

◆ XID

typedef struct xid_t XID

struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification, Distributed Transaction Processing: The XA Specification, X/Open Company Ltd., 1991.

http://www.opengroup.org/bookstore/catalog/c193.htm

See also
MYSQL_XID in mysql/plugin.h

Enumeration Type Documentation

◆ xa_option_words

Enumerator
XA_NONE 
XA_JOIN 
XA_RESUME 
XA_ONE_PHASE 
XA_SUSPEND 
XA_FOR_MIGRATE 

Function Documentation

◆ acquire_mandatory_metadata_locks()

bool acquire_mandatory_metadata_locks ( THD thd,
xid_t detached_xid 
)

Acquire Commit metadata lock and all locks acquired by a prepared XA transaction before server was shutdown or terminated.

Parameters
thdThread context
detached_xidXID value specified by XA COMMIT or XA ROLLBACK that corresponds to a XA transaction generated outside current session context.
Return values
falseSuccess
trueFailure

◆ applier_reset_xa_trans()

bool applier_reset_xa_trans ( THD thd)

This is a specific to "slave" applier collection of standard cleanup actions to reset XA transaction state at the end of XA prepare rather than to do it at the transaction commit, see ha_commit_one_phase.

THD of the slave applier is dissociated from a transaction object in engine that continues to exist there.

Parameters
thdcurrent thread
Returns
the value of is_error()

◆ cleanup_trans_state()

void cleanup_trans_state ( THD thd)

Reset some transaction state information and delete corresponding Transaction_ctx object from cache.

Parameters
thdCurrent thread

◆ detach_native_trx()

bool detach_native_trx ( THD thd,
plugin_ref  plugin,
void *   
)

The function detaches existing storage engines transaction context from thd.

Backup area to save it is provided to low level storage engine function.

is invoked by plugin_foreach() after trans_xa_start() for each storage engine.

Parameters
[in,out]thdThread context
pluginReference to handlerton
Returns
false on success, true otherwise.

◆ disconnect_native_trx()

bool disconnect_native_trx ( THD thd,
plugin_ref  plugin,
void *   
)

Disconnect transaction in SE.

This the same action which is performed by SE when disconnecting a connection which has a prepared XA transaction, when xa_detach_on_prepare is OFF. Signature matches that required by plugin_foreach.

◆ find_trn_for_recover_and_check_its_state()

std::shared_ptr< Transaction_ctx > find_trn_for_recover_and_check_its_state ( THD thd,
xid_t xid_for_trn_in_recover,
XID_STATE xid_state 
)

Find XA transaction in cache by its xid value.

Parameters
thdThread context
xid_for_trn_in_recoverxid value to look for in transaction cache
xid_stateState of XA transaction in current session
Returns
Pointer to an instance of Transaction_ctx corresponding to a xid in argument. If XA transaction not found returns nullptr and sets an error in DA to specify a reason of search failure.

◆ is_xa_prepare()

bool is_xa_prepare ( THD thd)

Checks whether or not the underlying statement is an XA PREPARE.

Parameters
thdTHD session object.
Returns
true if the underlying statement is an XA PREPARE, false if not

◆ is_xa_rollback()

bool is_xa_rollback ( THD thd)

Checks whether or not the underlying statement is an XA ROLLBACK.

Parameters
thdTHD session object.
Returns
true if the underlying statement is an XA ROLLBACK, false if not

◆ plugin_find_by_type()

struct st_plugin_int * plugin_find_by_type ( const LEX_CSTRING plugin,
int  type 
)

Searches for a correctly loaded plugin of a particular type by name.

Parameters
pluginthe name of the plugin we're looking for
typetype of the plugin (0-MYSQL_MAX_PLUGIN_TYPE_NUM)
Returns
plugin, or NULL if not found

◆ reattach_native_trx()

bool reattach_native_trx ( THD thd,
plugin_ref  plugin,
void *   
)

The function reattaches existing storage engines transaction context to thd.

Backup area to save it is provided to low level storage engine function.

is invoked by plugin_foreach() after trans_xa_prepare() for each storage engine.

Parameters
[in,out]thdThread context
pluginReference to handlerton
Returns
false on success, true otherwise.

◆ thd_holds_xa_transaction()

bool thd_holds_xa_transaction ( THD thd)

Test if the THD session underlying transaction is an externally coordinated (XA) transaction.

Parameters
thdThe session THD object holding the transaction to be tested.
Returns
true if the session underlying transaction is an XA transaction, false otherwise.

◆ xa_trans_force_rollback()

bool xa_trans_force_rollback ( THD thd)

Rollback the active XA transaction.

Note
Resets rm_error before calling ha_rollback(), so the thd->transaction.xid structure gets reset by ha_rollback() / THD::transaction::cleanup().
Returns
true if the rollback failed, false otherwise.

Variable Documentation

◆ TC_HEURISTIC_NOT_USED

const int TC_HEURISTIC_NOT_USED = 0
static

◆ TC_HEURISTIC_RECOVER_COMMIT

const int TC_HEURISTIC_RECOVER_COMMIT = 1
static

◆ TC_HEURISTIC_RECOVER_ROLLBACK

const int TC_HEURISTIC_RECOVER_ROLLBACK = 2
static