67#define MYSQL_XID_PREFIX "MySQLXid"
73#define XIDDATASIZE 128
114 DBUG_PRINT(
"debug", (
"SETTING XID_STATE formatID: %ld", v));
141 void set(
long f,
const char *g,
long gl,
const char *b,
long bl) {
143 DBUG_PRINT(
"debug", (
"SETTING XID_STATE formatID: %ld", f));
147 if (bl > 0) memcpy(
data + gl, b, bl);
269 friend std::ostream &
operator<<(std::ostream &out,
struct xid_t const &in);
529 std::list<XA_recover_txn *, Malloc_allocator<XA_recover_txn *>>
int64 query_id_t
Definition: binlog.h:72
Definition: sql_list.h:434
Definition: protocol.h:33
This class servers as a registry for prepared XA transactions existed before server was shutdown and ...
Definition: xa.h:481
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:246
MEM_ROOT * get_allocated_memroot()
Get initialized MEM_ROOT.
Definition: xa.cc:201
std::list< XA_recover_txn *, Malloc_allocator< XA_recover_txn * > > m_prepared_xa_trans
Definition: xa.h:530
MEM_ROOT m_mem_root
Definition: xa.h:532
static Recovered_xa_transactions * m_instance
Definition: xa.h:528
Recovered_xa_transactions()
Definition: xa.cc:164
static Recovered_xa_transactions & instance()
Get instance of the class Recovered_xa_transactions.
Definition: xa.cc:169
static bool init()
Initialize singleton.
Definition: xa.cc:173
static void destroy()
Cleanup and delete singleton object.
Definition: xa.cc:178
bool add_prepared_xa_transaction(XA_recover_txn const *prepared_xa_trn)
Add information about prepared XA transaction into a list of XA transactions to resurrect.
Definition: xa.cc:183
bool m_mem_root_inited
Definition: xa.h:531
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Definition: transaction_info.h:53
void store_xid_info(Protocol *protocol, bool print_xid_as_hex) const
Definition: xa.cc:476
xa_states
Definition: xa.h:297
@ XA_ACTIVE
Definition: xa.h:299
@ XA_ROLLBACK_ONLY
Definition: xa.h:302
@ XA_IDLE
Definition: xa.h:300
@ XA_PREPARED
Definition: xa.h:301
@ XA_NOTR
Definition: xa.h:298
uint rm_error
Error reported by the Resource Manager (RM) to the Transaction Manager.
Definition: xa.h:325
bool m_is_detached
Definition: xa.h:323
void set_query_id(query_id_t query_id)
Definition: xa.h:357
void cleanup()
Definition: xa.h:365
void reset_error()
Definition: xa.h:363
bool is_binlogged() const
Definition: xa.h:400
bool has_state(xa_states state) const
Definition: xa.h:347
bool is_detached() const
Definition: xa.h:398
bool xa_trans_rolled_back()
Mark a XA transaction as rollback-only if the RM unilaterally rolled back the transaction branch.
Definition: xa.cc:422
void set_state(xa_states state)
Definition: xa.h:343
void unset_binlogged()
Definition: xa.h:404
bool check_xa_idle_or_prepared(bool report_error) const
Check that XA transaction is in state IDLE or PREPARED.
Definition: xa.cc:441
XID m_xid
Definition: xa.h:312
void start_detached_xa(const XID *xid, bool binlogged_arg=false)
Definition: xa.h:390
bool m_is_binlogged
Definition: xa.h:334
XID * get_xid()
Definition: xa.h:353
const XID * get_xid() const
Definition: xa.h:351
enum xa_states get_state()
Definition: xa.h:345
const char * state_name() const
Definition: xa.h:349
XID_STATE()
Definition: xa.h:337
xa_states xa_state
Used by external XA only.
Definition: xa.h:322
bool check_has_uncommitted_xa() const
Check that XA transaction has an uncommitted work.
Definition: xa.cc:452
bool has_same_xid(const XID *xid) const
Definition: xa.h:355
std::mutex m_xa_lock
This mutex used for eliminating a possibility to run two XA COMMIT/XA ROLLBACK statements concurrentl...
Definition: xa.h:319
void start_normal_xa(const XID *xid)
Definition: xa.h:382
void set_binlogged()
Definition: xa.h:402
void reset()
Definition: xa.h:375
static const char * xa_state_names[]
Transaction identifier.
Definition: xa.h:310
void set_error(THD *thd)
Definition: xa.cc:472
bool check_in_xa(bool report_error) const
Check if an XA transaction has been started.
Definition: xa.cc:462
std::mutex & get_xa_lock()
Definition: xa.h:341
Contains the classes representing events operating in the replication stream properties.
static bool report_error(THD *thd, int error_code, Sql_condition::enum_severity_level level, Args... args)
Definition: error_handler.cc:291
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:181
#define DBUG_TRACE
Definition: my_dbug.h:146
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
unsigned char uchar
Definition: my_inttypes.h:52
int64_t int64
Definition: my_inttypes.h:68
Definition: buf0block_hint.cc:30
required string type
Definition: replication_group_member_actions.proto:34
ulonglong my_xid
Definition: handler.h:1228
Representation of an SQL command.
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: mysql_lex_string.h:40
Definition: control_events.h:588
Definition: handler.h:813
Definition: sql_plugin_ref.h:45
st_mysql_plugin * plugin
Definition: sql_plugin_ref.h:47
Plain structure to store information about XA transaction id and a list of table names involved into ...
Definition: xa.h:290
List< st_handler_tablename > * mod_tables
Definition: xa.h:292
XID id
Definition: xa.h:291
struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification,...
Definition: xa.h:83
long get_gtrid_length() const
Definition: xa.h:119
xid_t & operator=(binary_log::XA_prepare_event::MY_XID const &rhs)
Instantiates this object with the contents of the parameter of type XA_prepare_event::MY_XID.
Definition: xa.cc:122
void null()
Definition: xa.h:278
void set_gtrid_length(long v)
Definition: xa.h:121
long bqual_length
value from 1 through 64
Definition: xa.h:98
my_xid get_my_xid() const
Definition: xa.cc:99
bool eq(const xid_t *xid) const
Check if equal to another xid.
Definition: xa.h:205
uint key_length() const
Definition: xa.h:159
long formatID
-1 means that the XID is null
Definition: xa.h:88
char data[XIDDATASIZE]
distributed trx identifier.
Definition: xa.h:103
const char * get_data() const
Definition: xa.h:127
xid_t()
Definition: xa.h:106
long gtrid_length
value from 1 through 64
Definition: xa.h:93
void set(long f, const char *g, long gl, const char *b, long bl)
Definition: xa.h:141
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:182
bool operator<(struct xid_t const &rhs) const
Compares for lower-than-inequality two instances of xid_t.
Definition: xa.cc:136
void set_data(const void *v, long l)
Definition: xa.h:129
void reset()
Definition: xa.h:134
static const uint ser_buf_size
Definition: xa.h:172
void set(const xid_t *xid)
Definition: xa.h:272
const uchar * key() const
Definition: xa.h:155
uchar * key()
Definition: xa.h:153
long get_bqual_length() const
Definition: xa.h:123
void set_format_id(long v)
Definition: xa.h:112
bool is_null() const
Definition: xa.h:211
bool operator!=(struct xid_t const &rhs) const
Compares for inequality two instances of xid_t.
Definition: xa.cc:132
friend std::ostream & operator<<(std::ostream &out, struct xid_t const &in)
Writes the parameter's in string representation to the out stream parameter object.
Definition: xa.cc:156
void set_bqual_length(long v)
Definition: xa.h:125
long get_format_id() const
Definition: xa.h:110
bool operator==(struct xid_t const &rhs) const
Compares for equality two instances of xid_t.
Definition: xa.cc:130
char * xid_to_str(char *buf) const
Get printable XID value.
Definition: xa.cc:504
unsigned int uint
Definition: uca9-dump.cc:75
bool xa_trans_force_rollback(THD *thd)
Rollback the active XA transaction.
Definition: xa.cc:344
int64 query_id_t
Definition: xa.h:49
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:3680
bool detach_native_trx(THD *thd, plugin_ref plugin, void *)
The function detaches existing storage engines transaction context from thd.
Definition: xa.cc:624
static const int TC_HEURISTIC_RECOVER_ROLLBACK
Definition: xa.h:64
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:639
void cleanup_trans_state(THD *thd)
Reset some transaction state information and delete corresponding Transaction_ctx object from cache.
Definition: xa.cc:358
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:557
bool disconnect_native_trx(THD *, plugin_ref, void *)
Disconnect transaction in SE.
Definition: xa.cc:659
struct xid_t XID
struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification,...
bool thd_holds_xa_transaction(THD *thd)
Test if the THD session underlying transaction is an externally coordinated (XA) transaction.
Definition: xa.cc:689
bool is_xa_rollback(THD *thd)
Checks whether or not the underlying statement is an XA ROLLBACK.
Definition: xa.cc:698
static const int TC_HEURISTIC_NOT_USED
Definition: xa.h:62
static const int TC_HEURISTIC_RECOVER_COMMIT
Definition: xa.h:63
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.
Definition: xa.cc:367
xa_option_words
Definition: xa.h:53
@ XA_JOIN
Definition: xa.h:55
@ XA_RESUME
Definition: xa.h:56
@ XA_NONE
Definition: xa.h:54
@ XA_FOR_MIGRATE
Definition: xa.h:59
@ XA_ONE_PHASE
Definition: xa.h:57
@ XA_SUSPEND
Definition: xa.h:58
bool is_xa_prepare(THD *thd)
Checks whether or not the underlying statement is an XA PREPARE.
Definition: xa.cc:694
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 sh...
Definition: xa.cc:394
ulonglong my_xid
Definition: xa.h:66
#define XIDDATASIZE
Definition: xa.h:73
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:46