File: rpl_xa_gtid_next.inc

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (84 lines) | stat: -rw-r--r-- 2,516 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#
# Create XA transaction to conclude it with COMMIT or ROLLBACK.
# For either logging phase preceed it with supplied value of GTID_NEXT.
#
# param  $conclude_as            Commit or Rollback
# param  $gtid_phase1            GTID_NEXT value for the prepared round
# param  $gtid_phase2	         GTID_NEXT value for the conclusion round
# param  $conn_external [master] connection to return control too
#                                and randomly run conclusive query
# param  $xa_table      [t1]     Table to operate on in transaction
# param  $xa_error_simul         Provoke a failure to set GTID_NEXT correctly.
#                                When the first phase is not AUTOMATIC the 2nd
#                                must be preceeded with a proper GTID_NEXT.
#                                When the value is true, $disconnect_prepare is
#                                to be false.
#

--let $xid = 'xid_1'
--let $disconnect_prepare = 0
if (`SELECT concat('a','$conn_external') = 'a'`)
{
  --let $conn_external = master
}
if (`SELECT concat('a','$gtid_phase1') = 'a'`)
{
  --let $gtid_phase1 = automatic
}
if (`SELECT concat('a','$gtid_phase2') = 'a'`)
{
  --let $gtid_phase2 = automatic
}
if (`SELECT concat('a','$xa_table') = 'a'`)
{
  --let $xa_table = t1
}
if (`SELECT concat('a','$xa_error_simul') = 'a'`)
{
  --let $xa_error_simul = 0
}
if (!$xa_error_simul)
{
  --let $disconnect_prepare = `SELECT floor(rand()*10)%2`
}

--connection $conn_external

--connect (xa_conn, 127.0.0.1,root,,test,$MASTER_MYPORT,)
--let $conn_id = `SELECT connection_id()`
--replace_result $master_uuid SOURCE_UUID
--eval SET @@SESSION.GTID_NEXT = '$gtid_phase1'
--eval XA START   $xid
--disable_warnings
--eval INSERT INTO $xa_table VALUES(1)
--enable_warnings
--eval XA END     $xid
--eval XA PREPARE $xid

if ($disconnect_prepare)
{
  --disconnect xa_conn
  --connection $conn_external
  --let $wait_condition= SELECT count(*) = 0 FROM performance_schema.threads WHERE PROCESSLIST_ID = $conn_id and type = 'FOREGROUND'
  --source include/wait_condition.inc
}

if (`SELECT NOT $disconnect_prepare AND $xa_error_simul AND '$gtid_phase1' <> 'automatic'`)
{
  --replace_result $master_uuid SOURCE_UUID
  --error ER_GTID_NEXT_TYPE_UNDEFINED_GTID
  --eval XA $conclude_as $xid
}

--replace_result $master_uuid SOURCE_UUID
--eval SET @@SESSION.GTID_NEXT = '$gtid_phase2'
--eval XA $conclude_as $xid

if (!$disconnect_prepare)
{
  --disconnect xa_conn
}

--connection $conn_external
SET @@SESSION.GTID_NEXT = 'automatic';