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