Debian Codegraph @

mysql-test/suite/rpl/t/rpl_xa_detach_on_prepare.test

raw
1 # ==== Purpose ====
2 #
3 # Validate that when option `xa_detach_on_prepare` is enabled an XA transaction
4 # prepared on a source by a client thread becomes detached from that thread and
5 # can be committed on another source.
6 #
7 # ==== Requirements ====
8 #
9 # R1. It must be possible to commit an XA transaction on a tology node that
10 # is not the node where the transaction was originally prepared at.
11 #
12 # ==== Implementation ====
13 #
14 # 0. The test requires 2 servers in an asynchronous circular
15 # replication topology 1->2->1
16 # server1: source of server2
17 # server2: source of server1
18 # 1. On server1 enable option `xa_detach_on_prepare` for current session.
19 # 2. On server1 create a table.
20 # 3. On server1 create and prepare an XA transaction which inserts a value on
21 # the table.
22 # 4. On server2 commit the XA transaction.
23 # 5. Verify that insert was replicated to server1.
24 # 6. Cleanup
25 #
26 # ==== References ====
27 #
28 # BUG#31599926: XA COMMIT FAILED WHEN STOP GROUP_REPLICATION WILL LEAD NODE
29 # ERROR
30 #
31
32 --source include/have_binlog_format_row.inc
33
34 --echo #
35 --echo # 0. Create asynchronous replication topology between server 1 and 2
36 --echo #.
37 --let $rpl_server_count= 2
38 --let $rpl_topology= 1->2->1
39 --source include/rpl_init.inc
40
41 --echo #
42 --echo # 1. On server1 enable option `xa_detach_on_prepare` for current session.
43 --echo #.
44
45
46 --let $rpl_connection_name= server_1
47 --source include/rpl_connection.inc
48 SET @@session.xa_detach_on_prepare=1;
49
50 --let $assert_text= The value of xa_detach_on_prepare should be 1
51 --let $assert_cond= [SELECT @@session.xa_detach_on_prepare] = 1
52 --source include/assert.inc
53
54 --echo #
55 --echo # 2. On server1 create a table.
56 --echo #
57 --echo #
58
59 --let $rpl_connection_name= server_1
60 --source include/rpl_connection.inc
61 CREATE TABLE t1 (a INT) ENGINE = InnoDB;
62
63 --source include/rpl_sync.inc
64
65 --echo #
66 --echo # 3. On server1 create and prepare an XA transaction which inserts a value on
67 --echo # the table.
68
69 --let $rpl_connection_name= server_1
70 --source include/rpl_connection.inc
71
72 FLUSH LOGS;
73 XA START 'trx1';
74 INSERT INTO t1 VALUES (1);
75 XA END 'trx1';
76 XA PREPARE 'trx1';
77 --source include/rpl_sync.inc
78
79
80 --echo #
81 --echo # 4. On server2 commit the XA transaction.
82 --echo #
83 --let $rpl_connection_name= server_2
84 --source include/rpl_connection.inc
85
86 XA COMMIT 'trx1';
87 XA RECOVER;
88
89 --let $wait_condition= SELECT COUNT(*) = 1 FROM t1
90 --source include/wait_condition.inc
91
92 --source include/rpl_sync.inc
93
94
95 --echo #
96 --echo # 5. Verify that insert was replicated to server1.
97 --echo #
98
99 --let $rpl_connection_name= server_1
100 --source include/rpl_connection.inc
101 --let $wait_condition= SELECT COUNT(*) = 1 FROM t1
102 --source include/wait_condition.inc
103
104
105 --echo #
106 --echo # 6. Clean up
107 --echo #
108
109 --let $rpl_connection_name= server_1
110 --source include/rpl_connection.inc
111 SET @@session.xa_detach_on_prepare=0;
112
113 --let $rpl_connection_name= server_1
114 --source include/rpl_connection.inc
115 DROP TABLE t1;
116
117 --source include/rpl_sync.inc
118
119 --let $rpl_skip_sync= 1
120 --let $rpl_only_running_threads= 1
121 --source include/rpl_end.inc