Debian Codegraph @

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

raw
1 ##############################################################################
2 # WL#4677 Unique Server Ids for Replication Topology (UUIDs) #
3 #
4 # Master and slave exchange their UUID each other when connecting. Master's
5 # UUID is set into the result of 'SHOW SLAVE STATUS' and stored into
6 # master.info file. Slave's UUID appears in the result of 'SHOW SLAVE HOSTS'.
7 # Slave and master cannot have the same UUID, except
8 # --replicate-same-server-id is set.
9 #
10 ##############################################################################
11 # Does not work with GTIDs because it uses replicate-same-server-id to
12 # replicate from one server to itself.
13 --source include/no_valgrind_without_big.inc
14 # This test case is binlog_format agnostic
15 --source include/have_binlog_format_mixed.inc
16 --source include/have_debug.inc
17 --source include/have_debug_sync.inc
18
19 --let $rpl_server_count= 3
20 --source include/master-slave.inc
21
22 call mtr.add_suppression("Replica I/O thread .* register on source");
23 call mtr.add_suppression("Replica I/O: Source command COM_REGISTER_REPLICA failed: .*");
24 CALL mtr.add_suppression(".*source and replica have equal MySQL server UUIDs.*");
25 CALL mtr.add_suppression("Source's UUID has changed, although this should not happen unless you have changed it manually");
26 CALL mtr.add_suppression("Replica I/O: SET @master_heartbeat_period to source failed with error: Lost connection to MySQL server during query");
27 CALL mtr.add_suppression("Notifying source by SET @master_binlog_checksum= @@global.binlog_checksum failed with error");
28 CALL mtr.add_suppression("A replica with the same server_uuid/server_id as this replica has connected to the source");
29
30 --let $old_log_error_verbosity= `SELECT @@GLOBAL.LOG_ERROR_VERBOSITY`
31 SET @@GLOBAL.LOG_ERROR_VERBOSITY= 3;
32
33 --let $uuid_file= auto.cnf
34
35 --let $master_datadir=`SELECT @@DATADIR`
36 # Sync suppressions
37 --source include/sync_slave_sql_with_master.inc
38 --let $slave_datadir=`SELECT @@DATADIR`
39
40 connection server_3;
41 --let $server_3_datadir=`SELECT @@DATADIR`
42
43 connection master;
44 --let $original_master_uuid=query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
45 --copy_file $master_datadir/$uuid_file $master_datadir/original_$uuid_file
46
47 --echo
48 --echo # Case 1:
49 --echo # Master's UUID appears in the result of 'SHOW SLAVE STATUS'.
50 --echo # Slave's UUID appears in the result of 'SHOW SLAVE HOSTS'.
51 --echo -----------------------------------------------------------------------------
52
53 --let $assert_cond= "[master:SELECT @@SERVER_UUID AS a, a, 1]" = "[slave:SHOW SLAVE STATUS, Master_UUID, 1]"
54 --let $assert_text= "Slave's SHOW SLAVE HOST should contain the correct value for master's server_uuid
55 --source include/assert.inc
56
57 --let $assert_cond= "[master:SHOW SLAVE HOSTS, Slave_UUID, 1]" = "[slave:SHOW VARIABLES LIKE "SERVER_UUID", Value, 1]"
58 --let $assert_text= Master's SHOW SLAVE HOSTS should contain the correct value for slave's server_uuid
59 --source include/assert.inc
60
61 connection slave;
62
63 --echo
64 --echo # Case 2:
65 --echo # After executing 'STOP SLAVE [IO_THREAD|SQL_THREAD]' successfully, Master's UUID
66 --echo # is still kept into Slave status.
67 --echo -----------------------------------------------------------------------------
68 --source include/stop_slave_io.inc
69 source include/check_slave_param.inc;
70
71 --source include/stop_slave_sql.inc
72 --source include/check_slave_param.inc
73
74 --source include/start_slave.inc
75 --source include/stop_slave.inc
76 source include/check_slave_param.inc;
77
78 --echo
79 --echo # Case 3:
80 --echo # Slave generates an error and aborts, if master's UUID is
81 --echo # equal to slave's UUID unless --replicate-same-server-id
82 --echo # option is set.
83 --echo -----------------------------------------------------------------------------
84 connection master;
85 # copy slave's server_properties file to master, so master will have a same
86 # UUID as slave.
87 --remove_file $master_datadir/$uuid_file
88 --copy_file $slave_datadir/$uuid_file $master_datadir/$uuid_file
89 --let $rpl_server_number= 1
90 --source include/rpl_restart_server.inc
91
92 connection slave;
93 START SLAVE IO_THREAD;
94
95 let $show_statement= SHOW SLAVE STATUS;
96 --let $slave_io_errno= 13117
97 --source include/wait_for_slave_io_error.inc
98
99 connection master;
100 --remove_file $master_datadir/$uuid_file
101 --copy_file $server_3_datadir/$uuid_file $master_datadir/$uuid_file
102 --let $rpl_server_number= 1
103 --source include/rpl_restart_server.inc
104 --let $master_log_file= query_get_value(SHOW MASTER STATUS, 'File', 1)
105 --let $master_log_pos= query_get_value(SHOW MASTER STATUS, 'Position', 1)
106
107 --echo
108 --echo # server_3 is running with --replicate-same-server-id option
109 connection server_3;
110 --replace_result $MASTER_MYPORT MASTER_PORT
111 --replace_column 2 ####
112 eval CHANGE REPLICATION SOURCE TO SOURCE_HOST= '127.0.0.1',
113 SOURCE_PORT= $MASTER_MYPORT,
114 SOURCE_USER= 'root',
115 SOURCE_LOG_FILE='master-bin.000001';
116 --source include/start_slave.inc
117 --source include/check_slave_no_error.inc
118
119 connection master;
120 --let $sync_slave_connection= server_3
121 --source include/sync_slave_sql_with_master.inc
122 --source include/stop_slave.inc
123
124 connection master;
125 --remove_file $master_datadir/$uuid_file
126 --move_file $master_datadir/original_$uuid_file $master_datadir/$uuid_file
127 --let $rpl_server_number= 1
128 --source include/rpl_restart_server.inc
129
130 --echo
131 --echo # Case 4:
132 --echo # When executing 'CHANGE MASTER ...', master's UUID and server_id will be
133 --echo # cleared if master_host or/and master_port are changed.
134 --echo # Master's UUID and server_id will not be cleared if both master_port
135 --echo # and master_host are not changed.
136 --echo -----------------------------------------------------------------------------
137 connection slave;
138 --source include/start_slave_io.inc
139 --let $slave_param= Master_UUID
140 --let $slave_param_value= $original_master_uuid
141 --source include/wait_for_slave_param.inc
142
143 --source include/stop_slave.inc
144
145 --echo
146 --echo # Only change MASTER_PORT
147 let $old_master_log_file= query_get_value(SHOW SLAVE STATUS, Master_Log_File, 1);
148 let $old_master_log_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
149
150 CHANGE REPLICATION SOURCE TO SOURCE_PORT= 1111;
151 --let $slave_param= Master_UUID
152 --let $slave_param_value=
153 --source include/check_slave_param.inc
154 --let $slave_param= Master_Server_Id
155 --let $slave_param_value= 0
156 --source include/check_slave_param.inc
157
158 --replace_result $old_master_log_file MASTER_LOG_FILE $MASTER_MYPORT MASTER_PORT $old_master_log_pos MASTER_POS
159 eval CHANGE REPLICATION SOURCE TO SOURCE_PORT= $MASTER_MYPORT,
160 SOURCE_LOG_FILE= '$old_master_log_file', SOURCE_LOG_POS= $old_master_log_pos;
161 --source include/start_slave_io.inc
162 --let $slave_param= Master_UUID
163 --let $slave_param_value= $original_master_uuid
164 --source include/wait_for_slave_param.inc
165
166 --echo
167 --echo # Only change MASTER_HOST
168 STOP SLAVE IO_THREAD;
169 --source include/wait_for_slave_io_to_stop.inc
170 let $old_master_log_file= query_get_value(SHOW SLAVE STATUS, Master_Log_File, 1);
171 let $old_master_log_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
172
173 CHANGE REPLICATION SOURCE TO SOURCE_HOST= 'localhost';
174 --let $slave_param= Master_UUID
175 --let $slave_param_value=
176 --source include/check_slave_param.inc
177 --let $slave_param= Master_Server_Id
178 --let $slave_param_value= 0
179 --source include/check_slave_param.inc
180
181 --replace_result $old_master_log_file MASTER_LOG_FILE $MASTER_MYPORT MASTER_PORT $old_master_log_pos MASTER_POS
182 eval CHANGE REPLICATION SOURCE TO SOURCE_HOST= '127.0.0.1',
183 SOURCE_LOG_FILE= '$old_master_log_file', SOURCE_LOG_POS= $old_master_log_pos;
184 --source include/start_slave_io.inc
185 --let $slave_param= Master_UUID
186 --let $slave_param_value= $original_master_uuid
187 --source include/wait_for_slave_param.inc
188
189 --echo
190 --echo # Both MASTER_HOST and MASTER_PORT are changed
191 STOP SLAVE IO_THREAD;
192
193 --source include/wait_for_slave_io_to_stop.inc
194 CHANGE REPLICATION SOURCE TO SOURCE_HOST= '127.0.0.1', SOURCE_PORT= 1111;
195 --let $slave_param= Master_UUID
196 --let $slave_param_value=
197 --source include/check_slave_param.inc
198 --let $slave_param= Master_Server_Id
199 --let $slave_param_value= 0
200 --source include/check_slave_param.inc
201
202 --replace_result $old_master_log_file MASTER_LOG_FILE $MASTER_MYPORT MASTER_PORT $old_master_log_pos MASTER_POS
203 eval CHANGE REPLICATION SOURCE TO SOURCE_HOST= '127.0.0.1', SOURCE_PORT= $MASTER_MYPORT,
204 SOURCE_LOG_FILE= '$old_master_log_file', SOURCE_LOG_POS= $old_master_log_pos;
205 --source include/start_slave_io.inc
206 --let $slave_param= Master_UUID
207 --let $slave_param_value= $original_master_uuid
208 --source include/wait_for_slave_param.inc
209
210 --echo
211 --echo # Both MASTER_HOST and MASTER_PORT are NOT changed
212 STOP SLAVE IO_THREAD;
213 --source include/wait_for_slave_io_to_stop.inc
214
215 --replace_result $MASTER_MYPORT MASTER_PORT
216 eval CHANGE REPLICATION SOURCE TO SOURCE_HOST= '127.0.0.1', SOURCE_PORT= $MASTER_MYPORT;
217 --source include/check_slave_param.inc
218
219 --replace_result $old_master_log_file MASTER_LOG_FILE $MASTER_MYPORT MASTER_PORT $old_master_log_pos MASTER_POS
220 eval CHANGE REPLICATION SOURCE TO
221 SOURCE_LOG_FILE= '$old_master_log_file', SOURCE_LOG_POS= $old_master_log_pos;
222 --source include/check_slave_param.inc
223
224 --echo
225 --echo # Case 5:
226 --echo # After executing 'RESET SLAVE' successfully, Master's UUID is still kept
227 --echo # into Slave status.
228 --echo -----------------------------------------------------------------------------
229 connection slave;
230 RESET SLAVE;
231 --source include/check_slave_param.inc
232
233 --replace_result $old_master_log_file MASTER_LOG_FILE $MASTER_MYPORT MASTER_PORT $old_master_log_pos MASTER_POS
234 eval CHANGE REPLICATION SOURCE TO
235 SOURCE_LOG_FILE= '$old_master_log_file', SOURCE_LOG_POS= $old_master_log_pos;
236 --source include/start_slave.inc
237
238 --echo
239 --echo # Case 6:
240 --echo # In an existing master-slave replication forum (M->S1), if another
241 --echo # slave (S2) with the same UUID as S1 joins the forum and connects
242 --echo # to Master(M), the master will throw an error to the first slave
243 --echo # connection that will not try to reconnect.
244 --echo -----------------------------------------------------------------------------
245
246 # Get current server_2 thread_id at master
247 --connection server_1
248 --let $replica_thread_id= query_get_value(SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND='Binlog Dump', ID, 1)
249
250 # Step-1: Copy server 2(S1)'s auto.cnf into server 3 (S2)'s data directory.
251 --connection server_2
252 --let $datadir2=`select @@datadir`
253 -- connection server_3
254 --let $datadir3=`select @@datadir`
255 --copy_file $datadir3/auto.cnf $datadir3/auto_backup.cnf
256 --remove_file $datadir3/auto.cnf
257 --copy_file $datadir2/auto.cnf $datadir3/auto.cnf
258
259 # Step-2: Restart the server 3 (two servers with the same UUID)
260 --let $rpl_server_number= 3
261 --source include/rpl_restart_server.inc
262 # Notice that the other slave has stopped with an error
263 --let $rpl_connection_name= server_2
264 --source include/rpl_connection.inc
265 --let $slave_io_errno= convert_error(ER_SERVER_SOURCE_FATAL_ERROR_READING_BINLOG)
266 --source include/wait_for_slave_io_error.inc
267
268 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.1.err
269 # Grep only after the message that the server_2 has connected to the master
270 --let $assert_only_after=Start binlog_dump to source_thread_id\($replica_thread_id\)
271 --let $assert_count= 1
272 --let $assert_select=Upon reconnection with the replica, while initializing the dump thread for.*, an existing dump thread with the same.* was detected.*
273 --let $assert_text= Found the expected line in master's error log for server 2 disconnection
274 --source include/assert_grep.inc
275
276 # Get current server_3 thread_id at master
277 --connection server_1
278 --let $replica_thread_id= query_get_value(SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND='Binlog Dump', ID, 1)
279
280 # Step-3: Connect server 2 and notice that the slave server 3 will error
281 --connection server_2
282 --source include/start_slave_io.inc
283 # Notice that the other slave has stopped with an error
284 --let $rpl_connection_name= server_3
285 --source include/rpl_connection.inc
286 --let $slave_io_errno= convert_error(ER_SERVER_SOURCE_FATAL_ERROR_READING_BINLOG)
287 --source include/wait_for_slave_io_error.inc
288
289 # Grep only after the message that the server_3 has connected to the master
290 --let $assert_only_after=Start binlog_dump to source_thread_id\($replica_thread_id\)
291 --let $assert_text= Found the expected line in master's error log for server 3 disconnection
292 --source include/assert_grep.inc
293
294 # Step-4: Check for error messages on slaves
295 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
296 # Assert only the occurrences after the last CHANGE MASTER
297 --let $assert_only_after=CHANGE REPLICATION SOURCE .* executed
298 --let $assert_select= Replica .* Got fatal error .* from source .* replica with the same server_uuid/server_id as this replica
299 --let $assert_text= Found the expected line in server 2 error log
300 --source include/assert_grep.inc
301
302 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.3.err
303 --let $assert_text= Found the expected line in server 3 error log
304 --source include/assert_grep.inc
305
306 # Cleanup (restore the server 3's auto.cnf back to proper one and restart)
307 --remove_file $datadir3/auto.cnf
308 --copy_file $datadir3/auto_backup.cnf $datadir3/auto.cnf
309 --remove_file $datadir3/auto_backup.cnf
310 --let $rpl_server_number= 3
311 --source include/rpl_restart_server.inc
312 --source include/stop_slave.inc
313
314 --source include/rpl_connection_master.inc
315 --replace_result $old_log_error_verbosity OLD_LOG_ERROR_VERBOSITY
316 eval SET @@GLOBAL.log_error_verbosity= $old_log_error_verbosity;
317
318 --source include/rpl_end.inc