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