Debian Codegraph @

mysql-test/suite/rpl_nogtid/t/rpl_assign_gtids_to_anonymous_transactions.test

raw
1 # ==== Purpose ====
2 #
3 # This test evaluates that replication works with expected errors and warnings
4 # while replicating from a gtid disabled source to a gtid enabled replica
5
6 # ==== Implementation ====
7 #
8 # TC1. Test with assign_gtids_to_anonymous_transactions = OFF.
9 #
10 # 1) Start replica with GTID_MODE = ON and check for errors.
11 # 2) Set gtid_mode = Off and check that replication works fine
12 #
13 # TC2. Test with assign_gtids_to_anonymous_transactions = LOCAL
14 #
15 # 1) Execute change master with gtid_mode = Off and check for error.
16 # 2) Set the GTID_MODE = ON and execute CHANGE MASTER, verify that we have the
17 # warning about the limitation os the option ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
18 # emitted on the client side.
19 # 3) When server starts with gtid_mode=OFF and any replication channel has
20 # ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS != OFF, the server shall generate a warning
21 # message in the error log, but not change the gtid_mode or the option.
22 # 4) Start replica with GTID_MODE = ON and verify the gtid_generated for
23 # the anonymous_gtid_events. Verify that the UUID in gtid generated
24 # is same as that of replica server's UUID.
25 # 5) Try setting gtid_mode = Off along with assign_gtids_to_anonymous_transactions = LOCAL
26 # and check for errors.
27 # 6) Try setting auto_pos = 1 and check for errors.
28 # 7) Test that Both receiver and applier needs to be stopped to set the
29 # assign_gtids_to_anonymous_transactions
30 # 8) Test assign_gtids_to_anonymous_transactions with sql_replica_skip_counter and verify that
31 # it works and the correct warning is emitted.
32 # 9) Try starting slave with SQL_BEFORE_GTIDS/SQL_AFTER_GTIDS and check for error
33 # 10) Execute the function WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS and check for error
34 #
35 # TC3. Test with assign_gtids_to_anonymous_transactions = <UUID>
36 #
37 # 1) Verify that there is an error in the error log for wrong
38 # UUID string passed through ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
39 # 2) Verify that the UUID in gtid generated is same as that of
40 # specified via assign_gtids_to_anonymous_transactions.
41 #
42 # TC4. Test with assign_gtids_to_anonymous_transactions = ON & @@global.server_uuid
43 #
44 # 1) Test with the value ON and expect an error
45 # 2) Test with the value @@global.server_uuid and the values in P_S table
46 #
47 # ==== References ====
48 # WL#12819:GTIDs: Replicate from GTID disabled source to GTID enabled replica directly
49 #
50
51 --let $rpl_gtid_utils= 1
52 --let $rpl_skip_start_slave = 1
53 --source include/master-slave.inc
54 --source include/have_binlog_format_row.inc
55 CALL mtr.add_suppression("Using ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS implies limitations on the replication topology");
56 CALL mtr.add_suppression("Replica I/O for channel '': The replication receiver thread cannot start");
57 CALL mtr.add_suppression("If you intend to use GTID_MODE = ON everywhere, change to ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = OFF");
58
59 --echo TC1. Test with assign_gtids_to_anonymous_transactions = OFF.
60
61 # 1) Start replica with GTID_MODE = ON and check for errors.
62 --source include/rpl_connection_slave.inc
63
64 --let $rpl_set_enforce_gtid_consistency= 1
65 --let $rpl_gtid_mode= ON
66 --let $rpl_server_numbers= 2
67 --let $rpl_skip_sync= 1
68 --source include/rpl_set_gtid_mode.inc
69
70 CHANGE REPLICATION SOURCE TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = OFF;
71 START SLAVE IO_THREAD;
72
73 # Replica will complain about having different gtid value on source.
74 --let $slave_io_errno= convert_error(ER_REPLICA_FATAL_ERROR)
75 --let $show_slave_io_error = 1
76 --source include/wait_for_slave_io_error.inc
77 RESET SLAVE;
78
79 # 2) Set gtid_mode = Off and check that replication works fine
80 --let $rpl_gtid_mode= OFF
81 --let $rpl_server_numbers= 2
82 --let $rpl_skip_sync= 1
83 --source include/rpl_set_gtid_mode.inc
84
85 --source include/start_slave.inc
86
87 --source include/rpl_connection_master.inc
88 CREATE TABLE t(s INT);
89 INSERT INTO t VALUES(10);
90
91 #Used by CHM for assign_gtids_to_anonymous_transactions= LOCAL
92 --source include/save_binlog_position.inc
93
94 --source include/sync_slave_sql_with_master.inc
95 # Verify that no GTID was generated when assign_gtids_to_anonymous_transactions = OFF
96 --let $gtid_step_count = 0
97 --source include/gtid_step_assert.inc
98
99 --source include/stop_slave.inc
100
101 --echo
102 --echo TC2. Test with assign_gtids_to_anonymous_transactions = LOCAL
103 --echo
104 # 1) Execute change master with GTID_MODE = OFF and check for error.
105
106 --error ER_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS_REQUIRES_GTID_MODE_ON
107 CHANGE REPLICATION SOURCE TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = LOCAL;
108
109 # 2) Set the GTID_MODE = ON and execute CHANGE MASTER, verify that we have the
110 # warning about the limitation os the option ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
111 # emitted on the client side.
112
113 # Set the gtid_mode to ON in order to set assign_gtids_to_anonymous_transactions = LOCAL
114 --let $rpl_gtid_mode= ON
115 --let $rpl_server_numbers= 2
116 --let $rpl_skip_sync= 1
117 --source include/rpl_set_gtid_mode.inc
118
119 # We don't want to replicate the events which are already on replica.
120 --replace_result $binlog_file BINLOG_FILE $binlog_position BINLOG_POS
121 eval CHANGE REPLICATION SOURCE TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = LOCAL, SOURCE_LOG_FILE = "$binlog_file", SOURCE_LOG_POS = $binlog_position;
122
123 --let $assert_text= A warning will be generated stating the limitation of ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS option
124 --let $warning_code= query_get_value(SHOW WARNINGS, Code, 1)
125 --let $expected_code= convert_error(ER_USING_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS_AS_LOCAL_OR_UUID)
126 --let $assert_cond= $warning_code = $expected_code
127 --source include/assert.inc
128
129 # 3) When server starts with gtid_mode=OFF and any replication channel has
130 # ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS != OFF, the server shall throw an error
131
132 # Set the gtid_mode = OFF and restart.
133 --let $rpl_server_number=2
134 --let $rpl_start_with_gtids= 0
135 --source include/rpl_restart_server.inc
136
137 --let $assert_text = When assign_gtids_to_anonymous_transactions is set to LOCAL|UUID attempt to restart the slave with gtid-mode= off to get ER_REPLICA_RENAME_TXN_IS_LOCAL_OR_UUID_AND_GTID_MODE_OFF
138 --let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err
139 --let $assert_select = If you intend to use GTID_MODE = ON everywhere, change to ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = OFF
140 --let $assert_count = 1
141 --source include/assert_grep.inc
142
143 --error ER_CANT_USE_ANONYMOUS_TO_GTID_WITH_GTID_MODE_NOT_ON
144 START SLAVE;
145
146 # Set the gtid_mode=ON
147 --let $rpl_gtid_mode= ON
148 --let $rpl_server_numbers= 2
149 --let $rpl_skip_sync= 1
150 --source include/rpl_set_gtid_mode.inc
151 --source include/start_slave.inc
152
153 --source include/stop_slave.inc
154 --error ER_CANT_COMBINE_ANONYMOUS_TO_GTID_AND_AUTOPOSITION
155 CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION = 1;
156 --source include/start_slave.inc
157
158 --source include/rpl_connection_master.inc
159 INSERT INTO t VALUES(10);
160 INSERT INTO t VALUES(10);
161 --source include/save_binlog_position.inc
162
163 --source include/sync_slave_sql_with_master.inc
164 # 4) Start replica with GTID_MODE = ON and verify the gtid_generated for
165 # the anonymous_gtid_events. Verify that the UUID in gtid generated
166 # is same as that of replica server's UUID.
167
168 --let $server_local_uuid = `SELECT @@GLOBAL.SERVER_UUID`
169 --let $gtid_step_count= 2
170 --let $gtid_step_uuid = $server_local_uuid
171 --source include/gtid_step_assert.inc
172 --source include/stop_slave.inc
173
174 # 5) Try setting gtid_mode <> ON along with assign_gtids_to_anonymous_transactions = LOCAL
175 # and check for errors.
176 --error ER_CANT_SET_GTID_MODE
177 SET GLOBAL GTID_MODE=ON_PERMISSIVE;
178
179 # 6) Try setting auto_pos = 1 and check for errors.
180
181 --error ER_CANT_COMBINE_ANONYMOUS_TO_GTID_AND_AUTOPOSITION
182 CHANGE REPLICATION SOURCE TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = LOCAL, SOURCE_AUTO_POSITION = 1;
183
184 # 7) Test that Both receiver and applier needs to be stopped to set the assign_gtids_to_anonymous_transactions
185
186 --source include/start_slave_io.inc
187 --error ER_REPLICA_CHANNEL_MUST_STOP
188 CHANGE REPLICATION SOURCE TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = LOCAL;
189
190 --source include/start_slave_sql.inc
191 --error ER_REPLICA_CHANNEL_MUST_STOP
192 CHANGE REPLICATION SOURCE TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = LOCAL;
193
194 # 8) Test assign_gtids_to_anonymous_transactions with sql_replica_skip_counter and verify that
195 # it works and the correct warning is emitted.
196
197 --source include/stop_slave.inc
198 # This will generate a warning in the result file.
199 SET GLOBAL sql_replica_skip_counter = 1;
200
201 --let $assert_text= A warning will be generated stating "The value of sql_replica_skip_counter will only take effect for channels running with"
202 --let $warning_code= query_get_value(SHOW WARNINGS, Code, 1)
203 --let $expected_code= convert_error(ER_SQL_REPLICA_SKIP_COUNTER_USED_WITH_GTID_MODE_ON)
204 --let $assert_cond= $warning_code = $expected_code
205 --source include/assert.inc
206
207 --source include/rpl_connection_master.inc
208 INSERT INTO t VALUES(12);
209 --source include/save_binlog_position.inc
210
211 --source include/rpl_connection_slave.inc
212 --source include/start_slave.inc
213
214 --source include/rpl_connection_master.inc
215 --source include/sync_slave_sql_with_master.inc
216
217 # Check that no gtid was generated since the last call to gtid_step_assert.inc
218 --let $gtid_step_count= 0
219 --let $gtid_step_uuid = $server_local_uuid
220 --source include/gtid_step_assert.inc
221
222 # 9) Try starting slave with SQL_BEFORE_GTIDS/SQL_AFTER_GTIDS and check for error
223 #
224 --source include/stop_slave.inc
225
226 --error ER_CANT_SET_SQL_AFTER_OR_BEFORE_GTIDS_WITH_ANONYMOUS_TO_GTID
227 START SLAVE UNTIL SQL_BEFORE_GTIDS='332ceb83-f759-11ea-9e3a-5076afc0021b:1-5';
228
229 # 10) Execute the function WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS and check for error
230
231 --let $server_uuid= `SELECT @@GLOBAL.SERVER_UUID`
232 --replace_result $server_uuid server_uuid
233
234 --error ER_CANT_SET_ANONYMOUS_TO_GTID_AND_WAIT_UNTIL_SQL_THD_AFTER_GTIDS
235 --eval SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS('$server_uuid:1-2')
236
237 --echo TC3. Test with assign_gtids_to_anonymous_transactions = <UUID>
238
239 # 1) Verify that there is an error in the error log for wrong
240 # UUID string passed through ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
241
242 --replace_result $binlog_file BINLOG_FILE $binlog_position BINLOG_POS
243 --error ER_WRONG_VALUE
244 eval CHANGE REPLICATION SOURCE TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = "aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", SOURCE_LOG_FILE = "$binlog_file", SOURCE_LOG_POS = $binlog_position;
245
246 --replace_result $binlog_file BINLOG_FILE $binlog_position BINLOG_POS
247 eval CHANGE REPLICATION SOURCE TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", SOURCE_LOG_FILE = "$binlog_file", SOURCE_LOG_POS = $binlog_position;
248 --source include/start_slave.inc
249
250 --source include/rpl_connection_master.inc
251 DROP TABLE t;
252 --source include/sync_slave_sql_with_master.inc
253
254 # 2) Verify that the UUID in gtid generated is same as that of
255 # specified via assign_gtids_to_anonymous_transactions
256
257 --let $gtid_step_count= 1
258 --let $gtid_step_uuid = aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
259 --source include/gtid_step_assert.inc
260
261 --echo TC4. Test with assign_gtids_to_anonymous_transactions = ON & @@global.server_uuid
262
263 # 1) Test with the value ON and expect an error in the parse phase
264
265 --error ER_PARSE_ERROR
266 CHANGE REPLICATION SOURCE TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = ON;
267
268 # 2) Test with the value @@global.server_uuid and the values in P_S table
269
270 --source include/stop_slave.inc
271 --let $server_uuid= `SELECT @@GLOBAL.SERVER_UUID`
272 --replace_result $server_uuid server_uuid
273
274 --eval CHANGE REPLICATION SOURCE TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = "$server_uuid"
275 --source include/start_slave.inc
276
277 --let $count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS_TYPE = 'UUID'`
278 --let $assert_text = Check entry for default channel "" in performance_schema.replication_applier_configuration
279 --let $assert_cond = $count = 1
280 --source include/assert.inc
281 --echo # Cleanup
282
283 --source include/stop_slave.inc
284 CHANGE REPLICATION SOURCE TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = OFF;
285 --let $rpl_gtid_mode = OFF
286 --let $rpl_set_enforce_gtid_consistency = 0
287 --source include/rpl_set_gtid_mode.inc
288
289 --source include/rpl_end.inc