200#define MYSQL_XID_PREFIX "MySQLXid"
206#define XIDDATASIZE 128
247 DBUG_PRINT(
"debug", (
"SETTING XID_STATE formatID: %ld", v));
274 void set(
long f,
const char *g,
long gl,
const char *b,
long bl) {
276 DBUG_PRINT(
"debug", (
"SETTING XID_STATE formatID: %ld", f));
280 if (bl > 0) memcpy(
data + gl, b, bl);
604 std::list<XA_recover_txn *, Malloc_allocator<XA_recover_txn *>>
int64 query_id_t
Definition: binlog.h:70
Definition: sql_list.h:433
Definition: protocol.h:32
This class servers as a registry for prepared XA transactions existed before server was shutdown and ...
Definition: xa.h:556
bool recover_prepared_xa_transactions()
Iterate along a list of prepared XA transactions, register every XA transaction in a cache and acquir...
Definition: xa.cc:310
MEM_ROOT * get_allocated_memroot()
Get initialized MEM_ROOT.
Definition: xa.cc:258
std::list< XA_recover_txn *, Malloc_allocator< XA_recover_txn * > > m_prepared_xa_trans
Definition: xa.h:605
MEM_ROOT m_mem_root
Definition: xa.h:607
static Recovered_xa_transactions * m_instance
Definition: xa.h:603
Recovered_xa_transactions()
Definition: xa.cc:221
bool add_prepared_xa_transaction(XA_recover_txn *prepared_xa_trn)
Add information about prepared XA transaction into a list of XA transactions to resurrect.
Definition: xa.cc:240
static Recovered_xa_transactions & instance()
Get instance of the class Recovered_xa_transactions.
Definition: xa.cc:226
static bool init()
Initialize singleton.
Definition: xa.cc:230
static void destroy()
Cleanup and delete singleton object.
Definition: xa.cc:235
bool m_mem_root_inited
Definition: xa.h:606
This class represents SQL statement which commits and terminates an XA transaction with the given xid...
Definition: xa.h:153
bool trans_xa_commit(THD *thd)
Commit and terminate a XA transaction.
Definition: xa.cc:564
Sql_cmd_xa_commit(xid_t *xid_arg, enum xa_option_words xa_option)
Definition: xa.h:155
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: xa.h:158
bool process_external_xa_commit(THD *thd, xid_t *xid, XID_STATE *thd_xid_state)
Handle the statement XA COMMIT for the case when xid corresponds to an external XA transaction,...
Definition: xa.cc:643
enum xa_option_words get_xa_opt() const
Definition: xa.h:164
enum xa_option_words m_xa_opt
Definition: xa.h:173
bool process_internal_xa_commit(THD *thd, XID_STATE *xid_state)
Handle the statement XA COMMIT for the case when xid corresponds to an internal XA transaction,...
Definition: xa.cc:790
bool execute(THD *thd) override
Execute this SQL statement.
Definition: xa.cc:885
xid_t * m_xid
Definition: xa.h:172
This class represents SQL statement which puts in the IDLE state an XA transaction with the given xid...
Definition: xa.h:87
Sql_cmd_xa_end(xid_t *xid_arg, enum xa_option_words xa_option)
Definition: xa.h:89
xid_t * m_xid
Definition: xa.h:99
bool execute(THD *thd) override
Execute this SQL statement.
Definition: xa.cc:1224
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: xa.h:92
bool trans_xa_end(THD *thd)
Put a XA transaction in the IDLE state.
Definition: xa.cc:1200
enum xa_option_words m_xa_opt
Definition: xa.h:100
This class represents SQL statement which puts in the PREPARED state an XA transaction with the given...
Definition: xa.h:108
bool execute(THD *thd) override
Execute this SQL statement.
Definition: xa.cc:1376
Sql_cmd_xa_prepare(xid_t *xid_arg)
Definition: xa.h:110
xid_t * m_xid
Definition: xa.h:121
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: xa.h:112
bool trans_xa_prepare(THD *thd)
Put a XA transaction in the PREPARED state.
Definition: xa.cc:1241
This class represents SQL statement which returns to a client a list of XID's prepared to a XA commit...
Definition: xa.h:129
bool m_print_xid_as_hex
Definition: xa.h:144
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: xa.h:134
bool check_xa_recover_privilege(THD *thd) const
Check if the current user has a privilege to perform XA RECOVER.
Definition: xa.cc:1449
bool trans_xa_recover(THD *thd)
Return the list of XID's to a client, the same way SHOW commands do.
Definition: xa.cc:1401
Sql_cmd_xa_recover(bool print_xid_as_hex)
Definition: xa.h:131
bool execute(THD *thd) override
Execute this SQL statement.
Definition: xa.cc:1467
This class represents SQL statement which rollbacks and terminates an XA transaction with the given x...
Definition: xa.h:181
xid_t * m_xid
Definition: xa.h:196
Sql_cmd_xa_rollback(xid_t *xid_arg)
Definition: xa.h:183
bool process_internal_xa_rollback(THD *thd, XID_STATE *xid_state)
Handle the statement XA ROLLBACK for the case when xid corresponds to an internal XA transaction,...
Definition: xa.cc:1063
bool process_external_xa_rollback(THD *thd, xid_t *xid, XID_STATE *xid_state)
Handle the statement XA ROLLBACK for the case when xid corresponds to an external XA transaction,...
Definition: xa.cc:942
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: xa.h:185
bool trans_xa_rollback(THD *thd)
Roll back and terminate a XA transaction.
Definition: xa.cc:910
bool execute(THD *thd) override
Execute this SQL statement.
Definition: xa.cc:1115
This class represents SQL statement which starts an XA transaction with the given xid value.
Definition: xa.h:67
enum xa_option_words m_xa_opt
Definition: xa.h:79
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: xa.h:72
Sql_cmd_xa_start(xid_t *xid_arg, enum xa_option_words xa_option)
Definition: xa.h:69
bool trans_xa_start(THD *thd)
Start a XA transaction with the given xid value.
Definition: xa.cc:1142
bool execute(THD *thd) override
Execute this SQL statement.
Definition: xa.cc:1180
xid_t * m_xid
Definition: xa.h:78
Representation of an SQL command.
Definition: sql_cmd.h:64
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:945
Definition: transaction_info.h:51
void store_xid_info(Protocol *protocol, bool print_xid_as_hex) const
Definition: xa.cc:1529
xa_states
Definition: xa.h:372
@ XA_ACTIVE
Definition: xa.h:374
@ XA_ROLLBACK_ONLY
Definition: xa.h:377
@ XA_IDLE
Definition: xa.h:375
@ XA_PREPARED
Definition: xa.h:376
@ XA_NOTR
Definition: xa.h:373
uint rm_error
Error reported by the Resource Manager (RM) to the Transaction Manager.
Definition: xa.h:400
bool m_is_detached
Definition: xa.h:398
void set_query_id(query_id_t query_id)
Definition: xa.h:432
void cleanup()
Definition: xa.h:440
void reset_error()
Definition: xa.h:438
bool is_binlogged() const
Definition: xa.h:475
bool has_state(xa_states state) const
Definition: xa.h:422
bool is_detached() const
Definition: xa.h:473
bool xa_trans_rolled_back()
Mark a XA transaction as rollback-only if the RM unilaterally rolled back the transaction branch.
Definition: xa.cc:1475
void set_state(xa_states state)
Definition: xa.h:418
void unset_binlogged()
Definition: xa.h:479
bool check_xa_idle_or_prepared(bool report_error) const
Check that XA transaction is in state IDLE or PREPARED.
Definition: xa.cc:1494
XID m_xid
Definition: xa.h:387
void start_detached_xa(const XID *xid, bool binlogged_arg=false)
Definition: xa.h:465
bool m_is_binlogged
Definition: xa.h:409
XID * get_xid()
Definition: xa.h:428
const XID * get_xid() const
Definition: xa.h:426
enum xa_states get_state()
Definition: xa.h:420
const char * state_name() const
Definition: xa.h:424
XID_STATE()
Definition: xa.h:412
xa_states xa_state
Used by external XA only.
Definition: xa.h:397
bool check_has_uncommitted_xa() const
Check that XA transaction has an uncommitted work.
Definition: xa.cc:1505
bool has_same_xid(const XID *xid) const
Definition: xa.h:430
std::mutex m_xa_lock
This mutex used for eliminating a possibility to run two XA COMMIT/XA ROLLBACK statements concurrentl...
Definition: xa.h:394
void start_normal_xa(const XID *xid)
Definition: xa.h:457
void set_binlogged()
Definition: xa.h:477
void reset()
Definition: xa.h:450
static const char * xa_state_names[]
Transaction identifier.
Definition: xa.h:385
void set_error(THD *thd)
Definition: xa.cc:1525
bool check_in_xa(bool report_error) const
Check if an XA transaction has been started.
Definition: xa.cc:1515
std::mutex & get_xa_lock()
Definition: xa.h:416
DBUG_TRACE
Definition: do_ctype.cc:46
static bool report_error(THD *thd, int error_code, Sql_condition::enum_severity_level level, Args... args)
Definition: error_handler.cc:290
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:180
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
unsigned char uchar
Definition: my_inttypes.h:51
int64_t int64
Definition: my_inttypes.h:67
enum_sql_command
Definition: my_sqlcommand.h:45
@ SQLCOM_XA_PREPARE
Definition: my_sqlcommand.h:154
@ SQLCOM_XA_COMMIT
Definition: my_sqlcommand.h:155
@ SQLCOM_XA_ROLLBACK
Definition: my_sqlcommand.h:156
@ SQLCOM_XA_RECOVER
Definition: my_sqlcommand.h:157
@ SQLCOM_XA_END
Definition: my_sqlcommand.h:153
@ SQLCOM_XA_START
Definition: my_sqlcommand.h:152
Definition: buf0block_hint.cc:29
required string type
Definition: replication_group_member_actions.proto:33
ulonglong my_xid
recover() step of xa.
Definition: handler.h:6995
Representation of an SQL command.
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
Definition: mysql_lex_string.h:39
Definition: handler.h:811
Definition: sql_plugin_ref.h:44
st_mysql_plugin * plugin
Definition: sql_plugin_ref.h:46
Plain structure to store information about XA transaction id and a list of table names involved into ...
Definition: xa.h:365
List< st_handler_tablename > * mod_tables
Definition: xa.h:367
XID id
Definition: xa.h:366
struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification,...
Definition: xa.h:216
long get_gtrid_length() const
Definition: xa.h:252
void null()
Definition: xa.h:353
void set_gtrid_length(long v)
Definition: xa.h:254
long bqual_length
value from 1 through 64
Definition: xa.h:231
my_xid get_my_xid() const
Definition: xa.cc:109
bool eq(const xid_t *xid) const
Check if equal to another xid.
Definition: xa.h:338
uint key_length() const
Definition: xa.h:292
long formatID
-1 means that the XID is null
Definition: xa.h:221
char data[XIDDATASIZE]
distributed trx identifier.
Definition: xa.h:236
const char * get_data() const
Definition: xa.h:260
xid_t()
Definition: xa.h:239
long gtrid_length
value from 1 through 64
Definition: xa.h:226
void set(long f, const char *g, long gl, const char *b, long bl)
Definition: xa.h:274
char * serialize(char *buf) const
The method fills XID in a buffer in format of GTRID,BQUAL,FORMATID where GTRID, BQUAL are represented...
Definition: xa.h:315
void set_data(const void *v, long l)
Definition: xa.h:262
void reset()
Definition: xa.h:267
static const uint ser_buf_size
Definition: xa.h:305
void set(const xid_t *xid)
Definition: xa.h:347
const uchar * key() const
Definition: xa.h:288
uchar * key()
Definition: xa.h:286
long get_bqual_length() const
Definition: xa.h:256
void set_format_id(long v)
Definition: xa.h:245
bool is_null() const
Definition: xa.h:344
void set_bqual_length(long v)
Definition: xa.h:258
long get_format_id() const
Definition: xa.h:243
char * xid_to_str(char *buf) const
Get printable XID value.
Definition: xa.cc:1557
unsigned int uint
Definition: uca-dump.cc:29
void transaction_cache_delete(Transaction_ctx *transaction)
Remove information about transaction from a cache.
Definition: xa.cc:1748
bool xa_trans_force_rollback(THD *thd)
Rollback the active XA transaction.
Definition: xa.cc:454
int64 query_id_t
Definition: xa.h:45
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.
Definition: sql_plugin.cc:3658
bool detach_native_trx(THD *thd, plugin_ref plugin, void *)
The function detaches existing storage engines transaction context from thd.
Definition: xa.cc:1844
bool transaction_cache_init()
Initialize a cache to store Transaction_ctx and a mutex to protect access to the cache.
Definition: xa.cc:1624
static const int TC_HEURISTIC_RECOVER_ROLLBACK
Definition: xa.h:60
bool transaction_cache_detach(Transaction_ctx *transaction)
Transaction is marked in the cache as if it's recovered.
Definition: xa.cc:1694
struct st_xarecover_txn XA_recover_txn
Plain structure to store information about XA transaction id and a list of table names involved into ...
bool reattach_native_trx(THD *thd, plugin_ref plugin, void *)
The function reattaches existing storage engines transaction context to thd.
Definition: xa.cc:1859
void cleanup_trans_state(THD *thd)
Reset some transaction state information and delete corresponding Transaction_ctx object from cache.
Definition: xa.cc:468
bool applier_reset_xa_trans(THD *thd)
This is a specific to "slave" applier collection of standard cleanup actions to reset XA transaction ...
Definition: xa.cc:1776
bool disconnect_native_trx(THD *, plugin_ref, void *)
Disconnect transaction in SE.
Definition: xa.cc:1879
struct xid_t XID
struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification,...
static const int TC_HEURISTIC_NOT_USED
Definition: xa.h:58
static const int TC_HEURISTIC_RECOVER_COMMIT
Definition: xa.h:59
xa_option_words
Definition: xa.h:49
@ XA_JOIN
Definition: xa.h:51
@ XA_RESUME
Definition: xa.h:52
@ XA_NONE
Definition: xa.h:50
@ XA_FOR_MIGRATE
Definition: xa.h:55
@ XA_ONE_PHASE
Definition: xa.h:53
@ XA_SUSPEND
Definition: xa.h:54
ulonglong my_xid
Definition: xa.h:199
void transaction_cache_free()
Release resources occupied by transaction cache.
Definition: xa.cc:1635
#define XIDDATASIZE
Definition: xa.h:206
char * serialize_xid(char *buf, long fmt, long gln, long bln, const char *dat)
Function serializes XID which is characterized by by four last arguments of the function.
Definition: xa_aux.h:45