MySQL 8.0.30
Source Code Documentation
xa.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2013, 2022, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef XA_H_INCLUDED
25#define XA_H_INCLUDED
26
27#include <string.h>
28#include <sys/types.h>
29#include <list>
30#include <mutex>
31
32#include "lex_string.h"
33#include "libbinlogevents/include/control_events.h" // XA_prepare_event
34#include "my_dbug.h"
35#include "my_inttypes.h"
36#include "my_sqlcommand.h"
37#include "sql/malloc_allocator.h" // Malloc_allocator
38#include "sql/psi_memory_key.h" // key_memory_xa_recovered_transactions
39#include "sql/sql_cmd.h" // Sql_cmd
40#include "sql/sql_list.h" // List
41#include "sql/sql_plugin_ref.h" // plugin_ref
42#include "sql/xa_aux.h" // serialize_xid
43
44class Protocol;
45class THD;
46struct xid_t;
47class XID_STATE;
48class Transaction_ctx;
49
51
59};
60
61static const int TC_HEURISTIC_NOT_USED = 0;
62static const int TC_HEURISTIC_RECOVER_COMMIT = 1;
63static const int TC_HEURISTIC_RECOVER_ROLLBACK = 2;
64
65typedef ulonglong my_xid; // this line is the same as in log_event.h
66#define MYSQL_XID_PREFIX "MySQLXid"
67
68/*
69 Same as MYSQL_XIDDATASIZE but we do not want to include plugin.h here
70 See static_assert in .cc file.
71*/
72#define XIDDATASIZE 128
73
74/**
75 struct xid_t is binary compatible with the XID structure as
76 in the X/Open CAE Specification, Distributed Transaction Processing:
77 The XA Specification, X/Open Company Ltd., 1991.
78 http://www.opengroup.org/bookstore/catalog/c193.htm
79
80 @see MYSQL_XID in mysql/plugin.h
81*/
82typedef struct xid_t {
83 private:
84 /**
85 -1 means that the XID is null
86 */
88
89 /**
90 value from 1 through 64
91 */
93
94 /**
95 value from 1 through 64
96 */
98
99 /**
100 distributed trx identifier. not \0-terminated.
101 */
103
104 public:
106 memset(data, 0, XIDDATASIZE);
107 }
108
109 long get_format_id() const { return formatID; }
110
111 void set_format_id(long v) {
113 DBUG_PRINT("debug", ("SETTING XID_STATE formatID: %ld", v));
114 formatID = v;
115 return;
116 }
117
118 long get_gtrid_length() const { return gtrid_length; }
119
120 void set_gtrid_length(long v) { gtrid_length = v; }
121
122 long get_bqual_length() const { return bqual_length; }
123
124 void set_bqual_length(long v) { bqual_length = v; }
125
126 const char *get_data() const { return data; }
127
128 void set_data(const void *v, long l) {
129 assert(l <= XIDDATASIZE);
130 memcpy(data, v, l);
131 }
132
133 void reset() {
134 formatID = -1;
135 gtrid_length = 0;
136 bqual_length = 0;
137 memset(data, 0, XIDDATASIZE);
138 }
139
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));
143 formatID = f;
144 memcpy(data, g, gtrid_length = gl);
145 bqual_length = bl;
146 if (bl > 0) memcpy(data + gl, b, bl);
147 return;
148 }
149
150 my_xid get_my_xid() const;
151
152 uchar *key() { return reinterpret_cast<uchar *>(&gtrid_length); }
153
154 const uchar *key() const {
155 return reinterpret_cast<const uchar *>(&gtrid_length);
156 }
157
158 uint key_length() const {
159 return sizeof(gtrid_length) + sizeof(bqual_length) + gtrid_length +
161 }
162
163 /*
164 The size of the string containing serialized Xid representation
165 is computed as a sum of
166 eight as the number of formatting symbols (X'',X'',)
167 plus 2 x XIDDATASIZE (2 due to hex format),
168 plus space for decimal digits of XID::formatID,
169 plus one for 0x0.
170 */
171 static const uint ser_buf_size = 8 + 2 * XIDDATASIZE + 4 * sizeof(long) + 1;
172
173 /**
174 The method fills XID in a buffer in format of GTRID,BQUAL,FORMATID
175 where GTRID, BQUAL are represented as hex strings.
176
177 @param buf a pointer to buffer
178 @return the value of the first argument
179 */
180
181 char *serialize(char *buf) const {
183 }
184
185#ifndef NDEBUG
186 /**
187 Get printable XID value.
188
189 @param buf pointer to the buffer where printable XID value has to be
190 stored
191
192 @return pointer to the buffer passed in the first argument
193 */
194 char *xid_to_str(char *buf) const;
195#endif
196 /**
197 Check if equal to another xid.
198
199 @param[in] xid the id of another X/Open XA transaction
200
201 @return true iff formats, gtrid_length, bqual_length and the content of
202 gtrid_length+bqual_length bytes is exactly the same
203 */
204 bool eq(const xid_t *xid) const {
205 return xid->formatID == formatID && xid->gtrid_length == gtrid_length &&
206 xid->bqual_length == bqual_length &&
207 !memcmp(xid->data, data, gtrid_length + bqual_length);
208 }
209
210 bool is_null() const { return formatID == -1; }
211
212 /**
213 Instantiates this object with the contents of the parameter of type
214 `XA_prepare_event::MY_XID`.
215
216 The `XA_prepare_event::MY_XID` is a mirror class of `xid_t` so the
217 instantiation is a direct instantiation relation of each class member
218 variables.
219
220 @param rhs The `XA_prepare_event::MY_XID` to instantiate from
221
222 @return This object reference.
223 */
225 /**
226 Compares for equality two instances of `xid_t`.
227
228 @param rhs The instance to compare this object with.
229
230 @return true if both instance are equal, false otherwise.
231 */
232 bool operator==(struct xid_t const &rhs) const;
233 /**
234 Compares for inequality two instances of `xid_t`.
235
236 @param rhs The instance to compare this object with.
237
238 @return true if both instance are different, false otherwise.
239 */
240 bool operator!=(struct xid_t const &rhs) const;
241 /**
242 Compares for lower-than-inequality two instances of `xid_t`.
243
244 The lesser-than relation between two given XIDs, x1 and x2, is as
245 follows:
246
247 x1 < x2 if any of the following is true:
248 - x1[FORMAT_ID] < x2[FORMAT_ID]
249 - x1[strlen(GTRID)] < x2[strlen(GTRID)]
250 - x1[strlen(BQUAL)] < x2[strlen(BQUAL)]
251 - std::strncmp(x1[DATA], x2[DATA]) < 0
252
253 @param rhs The instance to compare this object with.
254
255 @return true if this instance is lesser than the parameter, false
256 otherwise.
257 */
258 bool operator<(struct xid_t const &rhs) const;
259 /**
260 Writes the parameter's `in` string representation to the `out` stream
261 parameter object.
262
263 @param out The stream to write the XID representation to
264 @param in The XID for which the string representation should be written
265
266 @return The reference for the stream passed on as parameter.
267 */
268 friend std::ostream &operator<<(std::ostream &out, struct xid_t const &in);
269
270 private:
271 void set(const xid_t *xid) {
272 memcpy(this, xid, sizeof(xid->formatID) + xid->key_length());
273 }
274
275 void set(my_xid xid);
276
277 void null() { formatID = -1; }
278
279 friend class XID_STATE;
281
283
284/**
285 Plain structure to store information about XA transaction id
286 and a list of table names involved into XA transaction with
287 specified id.
288*/
289typedef struct st_xarecover_txn {
293
295 public:
302 };
303
304 /**
305 Transaction identifier.
306 For now, this is only used to catch duplicated external xids.
307 */
308 private:
309 static const char *xa_state_names[];
310
312 /**
313 This mutex used for eliminating a possibility to run two
314 XA COMMIT/XA ROLLBACK statements concurrently against the same xid value.
315 m_xa_lock is used on handling XA COMMIT/XA ROLLBACK and acquired only for
316 external XA branches.
317 */
318 std::mutex m_xa_lock;
319
320 /// Used by external XA only
322 bool m_is_detached = false;
323 /// Error reported by the Resource Manager (RM) to the Transaction Manager.
325 /*
326 XA-prepare binary logging status. The flag serves as a facility
327 to conduct XA transaction two round binary logging.
328 It is set to @c false at XA-start.
329 It is set to @c true by binlogging routine of XA-prepare handler as well
330 as recovered to @c true at the server recovery upon restart.
331 Checked and reset at XA-commit/rollback.
332 */
334
335 public:
337 m_xid.null();
338 }
339
340 std::mutex &get_xa_lock() { return m_xa_lock; }
341
342 void set_state(xa_states state) { xa_state = state; }
343
344 enum xa_states get_state() { return xa_state; }
345
346 bool has_state(xa_states state) const { return xa_state == state; }
347
348 const char *state_name() const { return xa_state_names[xa_state]; }
349
350 const XID *get_xid() const { return &m_xid; }
351
352 XID *get_xid() { return &m_xid; }
353
354 bool has_same_xid(const XID *xid) const { return m_xid.eq(xid); }
355
356 void set_query_id(query_id_t query_id) {
357 if (m_xid.is_null()) m_xid.set(query_id);
358 }
359
360 void set_error(THD *thd);
361
362 void reset_error() { rm_error = 0; }
363
364 void cleanup() {
365 /*
366 If rm_error is raised, it means that this piece of a distributed
367 transaction has failed and must be rolled back. But the user must
368 rollback it explicitly, so don't start a new distributed XA until
369 then.
370 */
371 if (!rm_error) m_xid.null();
372 }
373
374 void reset() {
376 m_xid.null();
377 m_is_detached = false;
378 m_is_binlogged = false;
379 }
380
381 void start_normal_xa(const XID *xid) {
382 assert(m_xid.is_null());
384 m_xid.set(xid);
385 m_is_detached = false;
386 rm_error = 0;
387 }
388
389 void start_detached_xa(const XID *xid, bool binlogged_arg = false) {
391 m_xid.set(xid);
392 m_is_detached = true;
393 rm_error = 0;
394 m_is_binlogged = binlogged_arg;
395 }
396
397 bool is_detached() const { return m_is_detached; }
398
399 bool is_binlogged() const { return m_is_binlogged; }
400
401 void set_binlogged() { m_is_binlogged = true; }
402
403 void unset_binlogged() { m_is_binlogged = false; }
404
405 void store_xid_info(Protocol *protocol, bool print_xid_as_hex) const;
406
407 /**
408 Mark a XA transaction as rollback-only if the RM unilaterally
409 rolled back the transaction branch.
410
411 @note If a rollback was requested by the RM, this function sets
412 the appropriate rollback error code and transits the state
413 to XA_ROLLBACK_ONLY.
414
415 @return true if transaction was rolled back or if the transaction
416 state is XA_ROLLBACK_ONLY. false otherwise.
417 */
418
420
421 /**
422 Check that XA transaction is in state IDLE or PREPARED.
423
424 @param report_error true if state IDLE or PREPARED has to be interpreted
425 as an error, else false
426
427 @return result of check
428 @retval false XA transaction is NOT in state IDLE or PREPARED
429 @retval true XA transaction is in state IDLE or PREPARED
430 */
431
433
434 /**
435 Check that XA transaction has an uncommitted work. Report an error
436 to a mysql user in case when there is an uncommitted work for XA
437 transaction.
438
439 @return result of check
440 @retval false XA transaction is NOT in state IDLE, PREPARED
441 or ROLLBACK_ONLY.
442 @retval true XA transaction is in state IDLE or PREPARED
443 or ROLLBACK_ONLY.
444 */
445
446 bool check_has_uncommitted_xa() const;
447
448 /**
449 Check if an XA transaction has been started.
450
451 @param report_error true if report an error in case when
452 XA transaction has been stared, else false.
453
454 @return result of check
455 @retval false XA transaction hasn't been started (XA_NOTR)
456 @retval true XA transaction has been started (!XA_NOTR)
457 */
458
459 bool check_in_xa(bool report_error) const;
460};
461
462/**
463 This class servers as a registry for prepared XA transactions existed before
464 server was shutdown and being resurrected during the server restart.
465 The class is singleton. To collect a list of XA transaction identifiers and
466 a list of tables for that MDL locks have be acquired the method
467 add_prepared_xa_transaction() must be called. This method is invoked by
468 the function trx_recover_for_mysql() called by innobase_xa_recover during
469 running of X/Open XA distributed transaction recovery procedure. After a list
470 of XA transaction identifiers and a list of table names to be locked in MDL
471 have been collected and the function ha_recover() has returned control flow
472 the method recover_prepared_xa_transactions() must be called to resurrect
473 prepared XA transactions. Separation of collecting information about prepared
474 XA transactions from restoring XA transactions is done in order to exclude
475 possible suspending on MDL locks inside the function
476 dd::reset_tables_and_tablespaces() that is called right after the function
477 ha_recover() returns control flow.
478 */
479
481 public:
482 /**
483 Initialize singleton.
484 */
485 static bool init();
486
487 /**
488 Cleanup and delete singleton object
489 */
490 static void destroy();
491
492 /**
493 Get instance of the class Recovered_xa_transactions
494 */
496
497 /**
498 Add information about prepared XA transaction into a list of
499 XA transactions to resurrect.
500
501 @param prepared_xa_trn information about prepared XA transaction
502
503 @return false on success, else true
504 */
505 bool add_prepared_xa_transaction(XA_recover_txn const *prepared_xa_trn);
506
507 /**
508 Iterate along a list of prepared XA transactions, register every XA
509 transaction in a cache and acquire MDL locks for every table taking part in
510 XA transaction being resurrected.
511
512 @return false on success, else true
513 */
515
516 /**
517 Get initialized MEM_ROOT.
518
519 @return Pointer to a initialized MEM_ROOT.
520 */
522
523 private:
524 // Disable direct instantiation. Use the method init() instead.
526
528 std::list<XA_recover_txn *, Malloc_allocator<XA_recover_txn *>>
532};
533
534/**
535 This is a specific to "slave" applier collection of standard cleanup
536 actions to reset XA transaction state at the end of XA prepare rather than
537 to do it at the transaction commit, see @c ha_commit_one_phase.
538 THD of the slave applier is dissociated from a transaction object in engine
539 that continues to exist there.
540
541 @param thd current thread
542 @return the value of is_error()
543*/
544
545bool applier_reset_xa_trans(THD *thd);
546
547/* interface to randomly access plugin data */
549
550/**
551 The function detaches existing storage engines transaction
552 context from thd. Backup area to save it is provided to low level
553 storage engine function.
554
555 is invoked by plugin_foreach() after
556 trans_xa_start() for each storage engine.
557
558 @param[in,out] thd Thread context
559 @param plugin Reference to handlerton
560
561 @return false on success, true otherwise.
562*/
563
564bool detach_native_trx(THD *thd, plugin_ref plugin, void *);
565
566/**
567 The function reattaches existing storage engines transaction
568 context to thd. Backup area to save it is provided to low level
569 storage engine function.
570
571 is invoked by plugin_foreach() after
572 trans_xa_prepare() for each storage engine.
573
574 @param[in,out] thd Thread context
575 @param plugin Reference to handlerton
576
577 @return false on success,
578 true otherwise.
579*/
580
581bool reattach_native_trx(THD *thd, plugin_ref plugin, void *);
582
583/**
584 Reset some transaction state information and delete corresponding
585 Transaction_ctx object from cache.
586
587 @param thd Current thread
588*/
589
590void cleanup_trans_state(THD *thd);
591
592/**
593 Find XA transaction in cache by its xid value.
594
595 @param thd Thread context
596 @param xid_for_trn_in_recover xid value to look for in transaction cache
597 @param xid_state State of XA transaction in current session
598
599 @return Pointer to an instance of Transaction_ctx corresponding to a
600 xid in argument. If XA transaction not found returns nullptr and
601 sets an error in DA to specify a reason of search failure.
602*/
603std::shared_ptr<Transaction_ctx> find_trn_for_recover_and_check_its_state(
604 THD *thd, xid_t *xid_for_trn_in_recover, XID_STATE *xid_state);
605
606/**
607 Acquire Commit metadata lock and all locks acquired by a prepared XA
608 transaction before server was shutdown or terminated.
609
610 @param thd Thread context
611 @param detached_xid XID value specified by XA COMMIT or XA ROLLBACK that
612 corresponds to a XA transaction generated outside
613 current session context.
614
615 @retval false Success
616 @retval true Failure
617*/
618bool acquire_mandatory_metadata_locks(THD *thd, xid_t *detached_xid);
619
620/**
621 Rollback the active XA transaction.
622
623 @note Resets rm_error before calling ha_rollback(), so
624 the thd->transaction.xid structure gets reset
625 by ha_rollback() / THD::transaction::cleanup().
626
627 @return true if the rollback failed, false otherwise.
628*/
629
631
632bool disconnect_native_trx(THD *, plugin_ref, void *);
633
634/**
635 Test if the THD session underlying transaction is an externally
636 coordinated (XA) transaction.
637
638 @param thd The session THD object holding the transaction to be tested.
639
640 @return true if the session underlying transaction is an XA transaction,
641 false otherwise.
642*/
644/**
645 Checks whether or not the underlying statement is an `XA PREPARE`.
646
647 @param thd THD session object.
648
649 @return true if the underlying statment is an `XA PREPARE`, false
650 if not
651 */
652bool is_xa_prepare(THD *thd);
653/**
654 Checks whether or not the underlying statement is an `XA ROLLBACK`.
655
656 @param thd THD session object.
657
658 @return true if the underlying statment is an `XA ROLLBACK`, false
659 if not
660 */
661bool is_xa_rollback(THD *thd);
662#endif
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: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_class.h:922
Definition: transaction_info.h:52
Definition: xa.h:294
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.
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
Definition: buf0block_hint.cc:29
required string type
Definition: replication_group_member_actions.proto:33
ulonglong my_xid
Definition: handler.h:1220
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: uca-dump.cc:29
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:3677
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