1# 2# Test verifies MTS behaviour with regard to 3# Change-Master. 4# 5# Related bugs: 6# Bug 12995174 - MTS: UNEXPECTED RECOVERY ATTEMPT ENDS WITH ER_MASTER_INFO OR ASSERTION 7 8--source include/not_gtid_enabled.inc 9--source include/master-slave.inc 10# The test for bug#12995174 is not format-specific but uses sleep 11# so it made to be run in ROW format that is the way the bug is reported. 12--source include/have_binlog_format_row.inc 13--source include/have_innodb.inc 14 15--connection slave 16call mtr.add_suppression("Slave SQL: .*Could not execute Write_rows event on table d1.t1; Duplicate entry '13' for key 'a'"); 17call mtr.add_suppression("Slave SQL: ... The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state."); 18call mtr.add_suppression("Error writing relay log configuration."); 19--source include/stop_slave.inc 20SET @save.slave_parallel_workers=@@global.slave_parallel_workers; 21SET @@global.slave_parallel_workers=2; 22--source include/start_slave.inc 23 24--connection master 25 26CREATE DATABASE d1; 27CREATE DATABASE d2; 28CREATE TABLE d1.t1 (a int unique) ENGINE=INNODB; 29CREATE TABLE d2.t1 (a int unique) ENGINE=INNODB; 30 31INSERT INTO d1.t1 VALUES (1); 32FLUSH LOGS; 33 34--source include/sync_slave_sql_with_master.inc 35 36--source include/stop_slave.inc 37CHANGE MASTER TO MASTER_DELAY=5; 38--source include/start_slave.inc 39 40--connection master 41INSERT INTO d1.t1 VALUES (3); 42--sleep 3 43INSERT INTO d1.t1 VALUES (5); 44FLUSH LOGS; 45 46--connection slave 47--source include/stop_slave.inc 48 49let $relay_file = query_get_value( SHOW SLAVE STATUS, Relay_Log_File, 1 ); 50let $relay_pos = query_get_value( SHOW SLAVE STATUS, Relay_Log_Pos, 1 ); 51 52--replace_regex /RELAY_LOG_FILE=[^,]+/RELAY_LOG_FILE=FILE/ /RELAY_LOG_POS=[0-9]+/ RELAY_LOG_POS= POS/ 53eval CHANGE MASTER TO RELAY_LOG_FILE='$relay_file', RELAY_LOG_POS=$relay_pos; 54 55--source include/start_slave.inc 56--sleep 5 57--source include/stop_slave.inc 58 59let $relay_file = query_get_value( SHOW SLAVE STATUS, Relay_Log_File, 1 ); 60let $relay_pos = query_get_value( SHOW SLAVE STATUS, Relay_Log_Pos, 1 ); 61--replace_regex /RELAY_LOG_FILE=[^,]+/RELAY_LOG_FILE=FILE/ /RELAY_LOG_POS=[0-9]+/ RELAY_LOG_POS= POS/ 62eval CHANGE MASTER TO RELAY_LOG_FILE='$relay_file', RELAY_LOG_POS=$relay_pos, MASTER_DELAY=0; 63 64--source include/start_slave.inc 65BEGIN; 66INSERT INTO d1.t1 VALUES (13); # to cause the dup key error 67# change-master with gaps 68--connection master 69 70INSERT INTO d1.t1 VALUES (6); 71INSERT INTO d2.t1 VALUES (7); 72INSERT INTO d1.t1 VALUES (13); 73INSERT INTO d2.t1 VALUES (8); # this worker will race over one inserting (13) 74INSERT INTO d2.t1 VALUES (9); 75 76--connection slave1 77# make sure workers doing d2.t1 raced the one that occupied with d1.t1 78--let $count= 1 79--let $table= d2.t1 80--let $wait_condition= select count(*) = 1 from $table where a = 8 81--source include/wait_condition.inc 82 83--connection slave 84# make worker executing (13) to error out 85COMMIT; 86 87--let $slave_sql_errno= 1062 88--source include/wait_for_slave_sql_error.inc 89 90--source include/stop_slave_io.inc 91 92let $relay_file = query_get_value( SHOW SLAVE STATUS, Relay_Log_File, 1 ); 93let $relay_pos = query_get_value( SHOW SLAVE STATUS, Relay_Log_Pos, 1 ); 94--replace_regex /RELAY_LOG_FILE=[^,]+/RELAY_LOG_FILE=FILE/ /RELAY_LOG_POS=[0-9]+/ RELAY_LOG_POS= POS/ 95--error ER_MTS_CHANGE_MASTER_CANT_RUN_WITH_GAPS 96eval CHANGE MASTER TO RELAY_LOG_FILE='$relay_file', RELAY_LOG_POS=$relay_pos; 97 98SET @@global.slave_parallel_workers= @save.slave_parallel_workers; # cleanup 99 100# 101# --relay-log-recovery= 1 and MTS gaps is handled similarly to Change-Master 102# 103--let $rpl_server_number= 2 104--let $rpl_server_parameters= --relay-log-recovery --skip-slave-start 105--source include/rpl_restart_server.inc 106 107--connection slave 108SELECT @@global.relay_log_recovery as 'must be ON'; 109call mtr.add_suppression("MTS recovery: automatic recovery failed.*"); 110call mtr.add_suppression("Failed to initialize the master info structure"); 111# 112# the following suppression applies to either restart. 113# The reason it was not required when the test run "normally" with the default 114# --relay-log-info-repository=FILE is here: 115# Bug #15858271 MTR INCORRECTLY PROPAGATES A SERVER OPTION FROM A PREVIOUS TEST TO THE CURRENT 116# todo: The suppression should be removed after the bug is fixed. 117# 118call mtr.add_suppression("It is not possible to change the type of the relay log repository because there are workers repositories with possible execution gaps. The value of --relay_log_info_repository is altered to one of the found Worker repositories"); 119--let $rpl_server_number= 2 120--let $rpl_server_parameters= --skip-slave-start 121--source include/rpl_restart_server.inc 122 123SELECT @@global.relay_log_recovery as 'must be OFF'; 124--connection slave 125DELETE FROM d1.t1 WHERE a = 13; 126--source include/start_slave.inc 127 128# 129# cleanup 130# 131--connection master 132DROP DATABASE d1; 133DROP DATABASE d2; 134--source include/sync_slave_sql_with_master.inc 135 136############################################################################### 137# Bug#20411374: CAN NOT EXECUTE CHANGE MASTER AFTER ERROR OCCURED IN MTS MODE 138# 139# Problem: 140# ======== 141# When error occurred in MTS mode, If user first change master 142# (ER_MTS_CHANGE_MASTER_CANT_RUN_WITH_GAPS received here), and then reset slave, 143# user can never change master (error ER_MTS_CHANGE_MASTER_CANT_RUN_WITH_GAPS 144# occurred again). The debug version mysqld will crash at this case. 145# 146# Test: 147# ===== 148# Generate MTS gaps and execute CHANGE MASTER command so that 149# ER_MTS_CHANGE_MASTER_CANT_RUN_WITH_GAPS error is reported. Execute RESET 150# SLAVE command. Reexecute the CHANGE MASTER command once again it should 151# report an assert in the case of bug scenario and it should succeed after the 152# fix. 153############################################################################### 154--source include/rpl_connection_slave.inc 155--source include/stop_slave.inc 156SET @save.slave_parallel_workers=@@global.slave_parallel_workers; 157SET @@global.slave_parallel_workers=2; 158SET @save.relay_log_info_repository=@@global.relay_log_info_repository; 159SET @@global.relay_log_info_repository='TABLE'; 160--source include/start_slave.inc 161 162--source include/rpl_connection_master.inc 163CREATE DATABASE d1; 164CREATE DATABASE d2; 165CREATE TABLE d1.t1 (a int unique) ENGINE=INNODB; 166CREATE TABLE d2.t1 (a int unique) ENGINE=INNODB; 167--source include/sync_slave_sql_with_master.inc 168BEGIN; 169INSERT INTO d1.t1 VALUES (13); # to cause the dup key error 170# change-master with gaps 171--source include/rpl_connection_master.inc 172INSERT INTO d1.t1 VALUES (6); 173INSERT INTO d2.t1 VALUES (7); 174INSERT INTO d1.t1 VALUES (13); 175INSERT INTO d2.t1 VALUES (8); # this worker will race over one inserting (13) 176INSERT INTO d2.t1 VALUES (9); 177 178--source include/rpl_connection_slave1.inc 179# make sure workers doing d2.t1 raced the one that occupied with d1.t1 180--let $count= 1 181--let $table= d2.t1 182--let $wait_condition= select count(*) = 1 from $table where a = 8 183--source include/wait_condition.inc 184 185--source include/rpl_connection_slave.inc 186# make worker executing (13) to error out 187COMMIT; 188 189--let $slave_sql_errno= 1062 190--source include/wait_for_slave_sql_error.inc 191 192--source include/stop_slave_io.inc 193 194--source include/rpl_connection_master.inc 195FLUSH LOGS; 196--let $file= query_get_value(SHOW MASTER STATUS, File, 1) 197--let $pos= query_get_value(SHOW MASTER STATUS, Position, 1) 198 199--source include/rpl_connection_slave.inc 200--replace_result $MASTER_MYPORT MASTER_PORT $file FILE $pos POS 201--replace_column 2 #### 202--error ER_MTS_CHANGE_MASTER_CANT_RUN_WITH_GAPS 203eval CHANGE MASTER TO MASTER_HOST= '127.0.0.1', MASTER_PORT= $MASTER_MYPORT, MASTER_USER= 'root',MASTER_LOG_FILE = '$file', MASTER_LOG_POS = $pos ; 204reset slave; 205--replace_result $MASTER_MYPORT MASTER_PORT $file FILE $pos POS 206--replace_column 2 #### 207eval CHANGE MASTER TO MASTER_HOST= '127.0.0.1', MASTER_PORT= $MASTER_MYPORT, MASTER_USER= 'root',MASTER_LOG_FILE = '$file', MASTER_LOG_POS = $pos ; 208 209SET @@global.slave_parallel_workers= @save.slave_parallel_workers; 210SET @@global.relay_log_info_repository= @save.relay_log_info_repository; 211--source include/start_slave.inc 212# 213# cleanup 214# 215--source include/rpl_connection_master.inc 216DROP DATABASE d1; 217DROP DATABASE d2; 218 219--source include/rpl_end.inc 220