66#define MYSQL_XID_PREFIX "MySQLXid"
72#define XIDDATASIZE 128
113 DBUG_PRINT(
"debug", (
"SETTING XID_STATE formatID: %ld", v));
140 void set(
long f,
const char *g,
long gl,
const char *b,
long bl) {
142 DBUG_PRINT(
"debug", (
"SETTING XID_STATE formatID: %ld", f));
146 if (bl > 0) memcpy(
data + gl, b, bl);
268 friend std::ostream &
operator<<(std::ostream &out,
struct xid_t const &in);
528 std::list<XA_recover_txn *, Malloc_allocator<XA_recover_txn *>>
int64 query_id_t
Definition: binlog.h:71
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:480
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:245
MEM_ROOT * get_allocated_memroot()
Get initialized MEM_ROOT.
Definition: xa.cc:200
std::list< XA_recover_txn *, Malloc_allocator< XA_recover_txn * > > m_prepared_xa_trans
Definition: xa.h:529
MEM_ROOT m_mem_root
Definition: xa.h:531
static Recovered_xa_transactions * m_instance
Definition: xa.h:527
Recovered_xa_transactions()
Definition: xa.cc:163
static Recovered_xa_transactions & instance()
Get instance of the class Recovered_xa_transactions.
Definition: xa.cc:168
static bool init()
Initialize singleton.
Definition: xa.cc:172
static void destroy()
Cleanup and delete singleton object.
Definition: xa.cc:177
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:182
bool m_mem_root_inited
Definition: xa.h:530
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
Definition: transaction_info.h:52
void store_xid_info(Protocol *protocol, bool print_xid_as_hex) const
Definition: xa.cc:475
xa_states
Definition: xa.h:296
@ XA_ACTIVE
Definition: xa.h:298
@ XA_ROLLBACK_ONLY
Definition: xa.h:301
@ XA_IDLE
Definition: xa.h:299
@ XA_PREPARED
Definition: xa.h:300
@ XA_NOTR
Definition: xa.h:297
uint rm_error
Error reported by the Resource Manager (RM) to the Transaction Manager.
Definition: xa.h:324
bool m_is_detached
Definition: xa.h:322
void set_query_id(query_id_t query_id)
Definition: xa.h:356
void cleanup()
Definition: xa.h:364
void reset_error()
Definition: xa.h:362
bool is_binlogged() const
Definition: xa.h:399
bool has_state(xa_states state) const
Definition: xa.h:346
bool is_detached() const
Definition: xa.h:397
bool xa_trans_rolled_back()
Mark a XA transaction as rollback-only if the RM unilaterally rolled back the transaction branch.
Definition: xa.cc:421
void set_state(xa_states state)
Definition: xa.h:342
void unset_binlogged()
Definition: xa.h:403
bool check_xa_idle_or_prepared(bool report_error) const
Check that XA transaction is in state IDLE or PREPARED.
Definition: xa.cc:440
XID m_xid
Definition: xa.h:311
void start_detached_xa(const XID *xid, bool binlogged_arg=false)
Definition: xa.h:389
bool m_is_binlogged
Definition: xa.h:333
XID * get_xid()
Definition: xa.h:352
const XID * get_xid() const
Definition: xa.h:350
enum xa_states get_state()
Definition: xa.h:344
const char * state_name() const
Definition: xa.h:348
XID_STATE()
Definition: xa.h:336
xa_states xa_state
Used by external XA only.
Definition: xa.h:321
bool check_has_uncommitted_xa() const
Check that XA transaction has an uncommitted work.
Definition: xa.cc:451
bool has_same_xid(const XID *xid) const
Definition: xa.h:354
std::mutex m_xa_lock
This mutex used for eliminating a possibility to run two XA COMMIT/XA ROLLBACK statements concurrentl...
Definition: xa.h:318
void start_normal_xa(const XID *xid)
Definition: xa.h:381
void set_binlogged()
Definition: xa.h:401
void reset()
Definition: xa.h:374
static const char * xa_state_names[]
Transaction identifier.
Definition: xa.h:309
void set_error(THD *thd)
Definition: xa.cc:471
bool check_in_xa(bool report_error) const
Check if an XA transaction has been started.
Definition: xa.cc:461
std::mutex & get_xa_lock()
Definition: xa.h:340
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:290
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:180
#define DBUG_TRACE
Definition: my_dbug.h:145
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
Definition: buf0block_hint.cc:29
required string type
Definition: replication_group_member_actions.proto:33
ulonglong my_xid
Definition: handler.h:1226
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: control_events.h:587
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:289
List< st_handler_tablename > * mod_tables
Definition: xa.h:291
XID id
Definition: xa.h:290
struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification,...
Definition: xa.h:82
long get_gtrid_length() const
Definition: xa.h:118
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:121
void null()
Definition: xa.h:277
void set_gtrid_length(long v)
Definition: xa.h:120
long bqual_length
value from 1 through 64
Definition: xa.h:97
my_xid get_my_xid() const
Definition: xa.cc:98
bool eq(const xid_t *xid) const
Check if equal to another xid.
Definition: xa.h:204
uint key_length() const
Definition: xa.h:158
long formatID
-1 means that the XID is null
Definition: xa.h:87
char data[XIDDATASIZE]
distributed trx identifier.
Definition: xa.h:102
const char * get_data() const
Definition: xa.h:126
xid_t()
Definition: xa.h:105
long gtrid_length
value from 1 through 64
Definition: xa.h:92
void set(long f, const char *g, long gl, const char *b, long bl)
Definition: xa.h:140
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:181
bool operator<(struct xid_t const &rhs) const
Compares for lower-than-inequality two instances of xid_t.
Definition: xa.cc:135
void set_data(const void *v, long l)
Definition: xa.h:128
void reset()
Definition: xa.h:133
static const uint ser_buf_size
Definition: xa.h:171
void set(const xid_t *xid)
Definition: xa.h:271
const uchar * key() const
Definition: xa.h:154
uchar * key()
Definition: xa.h:152
long get_bqual_length() const
Definition: xa.h:122
void set_format_id(long v)
Definition: xa.h:111
bool is_null() const
Definition: xa.h:210
bool operator!=(struct xid_t const &rhs) const
Compares for inequality two instances of xid_t.
Definition: xa.cc:131
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:155
void set_bqual_length(long v)
Definition: xa.h:124
long get_format_id() const
Definition: xa.h:109
bool operator==(struct xid_t const &rhs) const
Compares for equality two instances of xid_t.
Definition: xa.cc:129
char * xid_to_str(char *buf) const
Get printable XID value.
Definition: xa.cc:503
unsigned int uint
Definition: uca9-dump.cc:74
bool xa_trans_force_rollback(THD *thd)
Rollback the active XA transaction.
Definition: xa.cc:343
int64 query_id_t
Definition: xa.h:48
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:3673
bool detach_native_trx(THD *thd, plugin_ref plugin, void *)
The function detaches existing storage engines transaction context from thd.
Definition: xa.cc:623
static const int TC_HEURISTIC_RECOVER_ROLLBACK
Definition: xa.h:63
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:638
void cleanup_trans_state(THD *thd)
Reset some transaction state information and delete corresponding Transaction_ctx object from cache.
Definition: xa.cc:357
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:556
bool disconnect_native_trx(THD *, plugin_ref, void *)
Disconnect transaction in SE.
Definition: xa.cc:658
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:688
bool is_xa_rollback(THD *thd)
Checks whether or not the underlying statement is an XA ROLLBACK.
Definition: xa.cc:697
static const int TC_HEURISTIC_NOT_USED
Definition: xa.h:61
static const int TC_HEURISTIC_RECOVER_COMMIT
Definition: xa.h:62
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:366
xa_option_words
Definition: xa.h:52
@ XA_JOIN
Definition: xa.h:54
@ XA_RESUME
Definition: xa.h:55
@ XA_NONE
Definition: xa.h:53
@ XA_FOR_MIGRATE
Definition: xa.h:58
@ XA_ONE_PHASE
Definition: xa.h:56
@ XA_SUSPEND
Definition: xa.h:57
bool is_xa_prepare(THD *thd)
Checks whether or not the underlying statement is an XA PREPARE.
Definition: xa.cc:693
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:393
ulonglong my_xid
Definition: xa.h:65
#define XIDDATASIZE
Definition: xa.h:72
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