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