Debian Codegraph @

mysql-test/suite/group_replication/include/gr_replicate_anonymous_server_to_group.inc

raw
1 # ==== Purpose ====
2 #
3 # This test checks that the replica parameter ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS works when
4 # replicating into a Group replication group.
5 #
6 # ==== Requirements ====
7 #
8 # + TC1: **ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS** works when replicating into a group
9 #
10 # ==== Implementation ====
11 #
12 # 0. This test works with 2 servers in multi primary mode and a third server
13 # replicating into to the group trough async replication
14 #
15 # 1. Create the group by starting GR on server 1 and 2
16 # 2. Disable GTIDs on server 3
17 # 3. Setup a asynchronous replication connection from server 3 into the group (server 1)
18 # Calculate the source_uuid
19 # 4. Execute some transactions on server 3 and sync with server 1
20 # 5. Execute a transaction on the group and sync
21 # 6. GTID_EXECUTED on server 1 must contain the transactions from server 3.
22 # Validate data on server 1.
23 # 7. GTID_EXECUTED on server 2 must contain the transactions from server 3.
24 # Validate data on server 2.
25 # 8. Cleanup
26 #
27 # ==== References ====
28 #
29 # WL#12819:GTIDs: Replicate from GTID disabled source to GTID enabled replica directly
30 #
31 # ==== Usage ====
32 #
33 # --let $_rename_parameter = LOCAL | UUID
34 # --source ../include/gr_replicate_anonymous_server_to_group.inc
35 #
36 # Parameters:
37 # $_rename_parameter
38 # The ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS parameter for the server that receives the transactions
39 #
40
41 --source include/have_group_replication_plugin.inc
42 --let $rpl_skip_group_replication_start= 1
43 --let $rpl_server_count= 3
44 --source include/group_replication.inc
45
46 --echo
47 --echo ############################################################
48 --echo # 1. Setup Group Replication on server 1 and 2.
49
50 --let $rpl_connection_name= server1
51 --source include/rpl_connection.inc
52 --source include/start_and_bootstrap_group_replication.inc
53
54 --let $rpl_connection_name= server2
55 --source include/rpl_connection.inc
56 --source include/start_group_replication.inc
57
58 --echo
59 --echo ############################################################
60 --echo # 2. Disable GTIDs on server 3
61
62 --let $rpl_connection_name= server3
63 --source include/rpl_connection.inc
64
65 --let $rpl_gtid_mode= OFF
66 --let $rpl_server_numbers= 3
67 --source include/rpl_set_gtid_mode.inc
68
69 --echo
70 --echo ############################################################
71 --echo # 3. Setup a asynchronous replication connection from server 3
72 --echo # into the group (server 1)
73 --echo # Calculate the source_uuid
74
75 --let $rpl_connection_name= server1
76 --source include/rpl_connection.inc
77
78 --let $_source_uuid = $_rename_parameter
79 --let $__rename_parameter = "$_rename_parameter"
80 if ($_rename_parameter == 'LOCAL')
81 {
82 --let $_source_uuid = `SELECT @@SERVER_UUID`
83 --let $__rename_parameter = $_rename_parameter
84 }
85
86 --replace_result $SERVER_MYPORT_3 SERVER_3_PORT
87 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1", SOURCE_USER="root", SOURCE_PASSWORD="", SOURCE_PORT=$SERVER_MYPORT_3, ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS=$__rename_parameter
88 --source include/start_slave.inc
89
90
91 --echo
92 --echo ###################################################################
93 --echo # 4. Execute some transactions on server 3 and sync with server 1
94
95 --let $rpl_connection_name= server3
96 --source include/rpl_connection.inc
97
98 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
99 INSERT INTO t1 VALUES (0);
100 INSERT INTO t1 VALUES (1);
101 UPDATE t1 SET c1=2 WHERE c1=0;
102
103 --let $sync_slave_connection= server1
104 --let $use_gtids= 0
105 --source include/sync_slave_sql_with_master.inc
106 --let $use_gtids= 1
107
108 --echo
109 --echo ############################################################
110 --echo # 5. Execute a transaction on the group and sync
111 --let $rpl_connection_name= server1
112 --source include/rpl_connection.inc
113
114 INSERT INTO t1 VALUES (6);
115 --source include/rpl_sync.inc
116
117 --echo
118 --echo ############################################################
119 --echo # 6. GTID_EXECUTED on server 1 must contain the transactions
120 --echo # from server 3.
121 --echo # Validate data on server 1.
122 --let $rpl_connection_name= server1
123 --source include/rpl_connection.inc
124
125 --let $assert_text= GTID_EXECUTED must contain server 4 GTID_EXECUTED from server 3 with server 1 UUID
126 --let $assert_cond= [SELECT GTID_SUBSET("$_source_uuid:1-4", @@GLOBAL.GTID_EXECUTED)] = 1
127 --source include/assert.inc
128
129 --let $assert_text= 'There is a value 1 in table t1'
130 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
131 --source include/assert.inc
132 --let $assert_text= 'There is a value 2 in table t1'
133 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1
134 --source include/assert.inc
135 --let $assert_text= 'There is a value 6 in table t1'
136 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 6, count, 1] = 1
137 --source include/assert.inc
138
139 --echo
140 --echo ############################################################
141 --echo # 7. GTID_EXECUTED on server 2 must contain the transactions
142 --echo # from server 3.
143 --echo # Validate data on server 2.
144
145 --let $rpl_connection_name= server2
146 --source include/rpl_connection.inc
147 --let $assert_text= GTID_EXECUTED must contain server 4 GTID_EXECUTED from server 3 with server 1 UUID
148 --let $assert_cond= [SELECT GTID_SUBSET("$_source_uuid:1-4", @@GLOBAL.GTID_EXECUTED)] = 1
149 --source include/assert.inc
150
151 --let $assert_text= 'There is a value 1 in table t1'
152 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
153 --source include/assert.inc
154 --let $assert_text= 'There is a value 2 in table t1'
155 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1
156 --source include/assert.inc
157 --let $assert_text= 'There is a value 6 in table t1'
158 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 6, count, 1] = 1
159 --source include/assert.inc
160
161 --echo
162 --echo ############################################################
163 --echo # 8. Cleanup
164
165 --let $rpl_connection_name= server3
166 --source include/rpl_connection.inc
167
168 DROP TABLE t1;
169
170 --let $sync_slave_connection= server1
171 --let $use_gtids= 0
172 --source include/sync_slave_sql_with_master.inc
173 --let $use_gtids= 1
174 # Stop asynchronous replication connection from server 3
175
176 --let $rpl_connection_name= server1
177 --source include/rpl_connection.inc
178
179 --source include/stop_slave.inc
180
181 # Restore the GTID_MODE on server 3
182
183 --let $rpl_connection_name= server3
184 --source include/rpl_connection.inc
185
186 --let $rpl_gtid_mode= ON
187 --let $rpl_skip_sync= 1
188 --let $rpl_server_numbers= 3
189 --source include/rpl_set_gtid_mode.inc
190
191 --let $rpl_connection_name= server1
192 --source include/rpl_connection.inc
193
194 # Stop Group Replication on server 1 and 2 to avoid sync problems
195
196 --source include/stop_group_replication.inc
197
198 SET session sql_log_bin=0;
199 CALL mtr.add_suppression("Using ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS implies limitations on the replication topology");
200 SET session sql_log_bin=1;
201
202 --let $allow_rpl_inited=1
203 --let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
204 --let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
205 --let $restart_parameters=restart:--group_replication_group_name=$group_replication_group_name --group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group_replication_bootstrap_group=1 --group_replication_start_on_boot=OFF
206 --replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS
207 --source include/restart_mysqld.inc
208 --let $rpl_server_number= 1
209 --source include/rpl_reconnect.inc
210
211 --let $rpl_connection_name= server2
212 --source include/rpl_connection.inc
213 --source include/stop_group_replication.inc
214
215 --source include/group_replication_end.inc