File: rpl_xa_detach_on_prepare.test

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 (121 lines) | stat: -rw-r--r-- 3,045 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# ==== Purpose ====
#
# Validate that when option `xa_detach_on_prepare` is enabled an XA transaction
# prepared on a source by a client thread becomes detached from that thread and
# can be committed on another source.
#
# ==== Requirements ====
#
# R1. It must be possible to commit an XA transaction on a tology node that
#     is not the node where the transaction was originally prepared at.
#
# ==== Implementation ====
#
# 0. The test requires 2 servers in an asynchronous circular
#    replication topology 1->2->1
#      server1: source of server2
#      server2: source of server1
# 1. On server1 enable option `xa_detach_on_prepare` for current session.
# 2. On server1 create a table.
# 3. On server1 create and prepare an XA transaction which inserts a value on
#    the table.
# 4. On server2 commit the XA transaction.
# 5. Verify that insert was replicated to server1.
# 6. Cleanup
#
# ==== References ====
#
# BUG#31599926: XA COMMIT FAILED WHEN STOP GROUP_REPLICATION WILL LEAD NODE
#               ERROR
#

--source include/have_binlog_format_row.inc

--echo #
--echo # 0. Create asynchronous replication topology between server 1 and 2
--echo #.
--let $rpl_server_count= 2
--let $rpl_topology= 1->2->1
--source include/rpl_init.inc

--echo #
--echo # 1. On server1 enable option `xa_detach_on_prepare` for current session.
--echo #.


--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
SET @@session.xa_detach_on_prepare=1;

--let $assert_text= The value of xa_detach_on_prepare should be 1
--let $assert_cond= [SELECT @@session.xa_detach_on_prepare] = 1
--source include/assert.inc

--echo #
--echo # 2. On server1 create a table.
--echo #
--echo #

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
CREATE TABLE t1 (a INT) ENGINE = InnoDB;

--source include/rpl_sync.inc

--echo #
--echo # 3. On server1 create and prepare an XA transaction which inserts a value on
--echo #    the table.

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc

FLUSH LOGS;
XA START 'trx1';
INSERT INTO t1 VALUES (1);
XA END 'trx1';
XA PREPARE 'trx1';
--source include/rpl_sync.inc


--echo #
--echo # 4. On server2 commit the XA transaction.
--echo #
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc

XA COMMIT 'trx1';
XA RECOVER;

--let $wait_condition= SELECT COUNT(*) = 1 FROM t1
--source include/wait_condition.inc

--source include/rpl_sync.inc


--echo #
--echo # 5. Verify that insert was replicated to server1.
--echo #

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--let $wait_condition= SELECT COUNT(*) = 1 FROM t1
--source include/wait_condition.inc


--echo #
--echo # 6. Clean up
--echo #

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
SET @@session.xa_detach_on_prepare=0;

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
DROP TABLE t1;

--source include/rpl_sync.inc

--let $rpl_skip_sync= 1
--let $rpl_only_running_threads= 1
--source include/rpl_end.inc