1# Verify that after CHANGE MASTER, replication (I/O thread and SQL
2# thread) restart from where SQL thread left, not from where
3# I/O thread left (some old bug fixed in 4.0.17)
4
5source include/master-slave.inc;
6call mtr.add_suppression("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum");
7
8connection master;
9# Make SQL slave thread advance a bit
10create table t1(n int);
11sync_slave_with_master;
12select * from t1;
13# Now stop it and make I/O slave thread be ahead
14stop slave sql_thread;
15connection master;
16insert into t1 values(1);
17insert into t1 values(2);
18save_master_pos;
19let $slave_param= Read_Master_Log_Pos;
20let $slave_param_value= query_get_value(SHOW MASTER STATUS, Position, 1);
21connection slave;
22source include/wait_for_slave_param.inc;
23source include/stop_slave.inc;
24
25let $read_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
26let $exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
27if ($read_pos == $exec_pos)
28{
29  source include/show_rpl_debug_info.inc;
30  echo 'Read_Master_Log_Pos: $read_pos' == 'Exec_Master_Log_Pos: $exec_pos';
31  die Failed because Read_Master_Log_Pos is equal to Exec_Master_Log_Pos;
32}
33change master to master_user='root';
34let $read_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
35let $exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
36if ($read_pos != $exec_pos)
37{
38  source include/show_rpl_debug_info.inc;
39  echo 'Read_Master_Log_Pos: $read_pos' <> 'Exec_Master_Log_Pos: $exec_pos';
40  die Failed because Read_Master_Log_Pos is not equal to Exec_Master_Log_Pos;
41}
42
43start slave;
44sync_with_master;
45select * from t1;
46connection master;
47drop table t1;
48sync_slave_with_master;
49
50# End of 4.1 tests
51
52#
53# BUG#12190 CHANGE MASTER has differ path requiremts on MASTER_LOG_FILE and RELAY_LOG_FILE
54#
55
56if ($bug_59037_is_fixed == 'true') {
57--source include/rpl_reset.inc
58
59connection master;
60create table t1 (a int);
61insert into t1 values (1);
62flush logs;
63insert into t1 values (2);
64
65# Note: the master positon saved by this will also be used by the
66# 'sync_with_master' below.
67sync_slave_with_master;
68
69# Check if the table t1 and t2 are identical on master and slave;
70let $diff_tables= master:t1,slave:t1
71source include/diff_tables.inc;
72
73connection slave;
74source include/stop_slave.inc;
75delete from t1 where a=2;
76
77# start replication from the second insert, after fix of BUG#12190,
78# relay_log_file does not use absolute path, only the filename is
79# required
80#
81# Note: the follow change master will automatically reset
82# relay_log_purge to false, save the old value to restore
83let $relay_log_purge= `select @@global.relay_log_purge`;
84CHANGE MASTER TO relay_log_file='slave-relay-bin.000005', relay_log_pos=4;
85start slave sql_thread;
86source include/wait_for_slave_sql_to_start.inc;
87
88# Sync to the same position saved by the 'sync_slave_with_master' above.
89sync_with_master;
90
91# Check if the table t1 and t2 are identical on master and slave;
92let $diff_tables= master:t1,slave:t1
93source include/diff_tables.inc;
94
95# clean up
96connection slave;
97start slave io_thread;
98source include/wait_for_slave_io_to_start.inc;
99eval set global relay_log_purge=$relay_log_purge;
100connection master;
101drop table t1;
102}
103
104--connection master
105# MDEV-22741: *SAN: ERROR: AddressSanitizer: use-after-poison on address in
106# instrings/strmake.c:36 from change_master (on optimized builds)
107CHANGE MASTER TO MASTER_USER='root', MASTER_SSL=0, MASTER_SSL_CA='', MASTER_SSL_CERT='',
108  MASTER_SSL_KEY='', MASTER_SSL_CRL='', MASTER_SSL_CRLPATH='';
109CHANGE MASTER TO MASTER_USER='root', MASTER_PASSWORD='', MASTER_SSL=0;
110
111--source include/rpl_end.inc
112