| 1 |
############################################################################### |
| 2 |
# Check that replication will fail safely if we inappropriately change |
| 3 |
# replication tables. Besides we check if some maintenance commands |
| 4 |
# can run without a problem. |
| 5 |
############################################################################### |
| 6 |
|
| 7 |
--source include/not_group_replication_plugin.inc |
| 8 |
--source include/no_valgrind_without_big.inc |
| 9 |
--source include/not_mts_replica_parallel_workers.inc |
| 10 |
--source include/master-slave.inc |
| 11 |
--connection slave |
| 12 |
--source include/stop_slave.inc |
| 13 |
SHOW CREATE TABLE mysql.slave_relay_log_info; |
| 14 |
ALTER TABLE mysql.slave_relay_log_info ENGINE= Innodb; |
| 15 |
SHOW CREATE TABLE mysql.slave_relay_log_info; |
| 16 |
--let $saved_relay_repo= `SELECT @@global.relay_log_info_repository` |
| 17 |
--let $saved_master_repo= `SELECT @@global.master_info_repository` |
| 18 |
--let $saved_sync_master= `SELECT @@global.sync_source_info` |
| 19 |
SET @@global.relay_log_info_repository="TABLE"; |
| 20 |
SET @@global.master_info_repository="TABLE"; |
| 21 |
SET @@global.sync_source_info= 1; |
| 22 |
--source include/start_slave.inc |
| 23 |
|
| 24 |
--connection master |
| 25 |
CREATE TABLE t_innodb (id INTEGER) engine= Innodb; |
| 26 |
|
| 27 |
--connection slave |
| 28 |
call mtr.add_suppression("Error writing relay log configuration."); |
| 29 |
call mtr.add_suppression("Column count of mysql.slave_relay_log_info is wrong."); |
| 30 |
call mtr.add_suppression("Error running query, replica SQL thread aborted."); |
| 31 |
call mtr.add_suppression("Info table is not ready to be used."); |
| 32 |
call mtr.add_suppression("Error writing source configuration."); |
| 33 |
call mtr.add_suppression("Failed to flush connection metadata."); |
| 34 |
call mtr.add_suppression(" Error while checking replication metadata."); |
| 35 |
call mtr.add_suppression("Failed to create or recover replication info repository."); |
| 36 |
call mtr.add_suppression("Error in checking.* repository info type of"); |
| 37 |
call mtr.add_suppression("Error creating.*: Error checking repositories"); |
| 38 |
call mtr.add_suppression("Failed to create or recover replication info repositories."); |
| 39 |
call mtr.add_suppression("An unexpected event sequence was detected by the IO thread"); |
| 40 |
call mtr.add_suppression("GTID_LOG_EVENT .* is not expected in an event stream"); |
| 41 |
call mtr.add_suppression("Failed to initialize the connection metadata structure for channel ''"); |
| 42 |
|
| 43 |
############################################################################### |
| 44 |
# Checking if replication can fail safely (SQL Thread) |
| 45 |
############################################################################### |
| 46 |
# |
| 47 |
# The test executes the following steps: |
| 48 |
# 1 - Changes mysql.slave_relay_log_info and SQL Thread stops gracefully. |
| 49 |
# 2 - Shows that it is possible to restart the server although replication |
| 50 |
# is not properly configured and working. |
| 51 |
# 3 - Shows that after fixing the problem the server can be properly |
| 52 |
# restared. |
| 53 |
# 4 - Shows that trying to fix the problem with START SLAVE, RESET SLAVE may |
| 54 |
# not work and requires to manually back up positions to restart |
| 55 |
# replication. |
| 56 |
# |
| 57 |
|
| 58 |
# |
| 59 |
# 1 - Changes mysql.slave_relay_log_info and SQL Thread stops gracefully. |
| 60 |
# |
| 61 |
--connection master |
| 62 |
INSERT INTO t_innodb VALUES (1), (2), (3); |
| 63 |
--source include/sync_slave_sql_with_master.inc |
| 64 |
ALTER TABLE mysql.slave_relay_log_info DROP COLUMN Number_of_workers; |
| 65 |
--connection master |
| 66 |
INSERT INTO t_innodb VALUES (1), (2), (3); |
| 67 |
--connection slave |
| 68 |
# ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2 1805 |
| 69 |
--let $slave_sql_errno= 1805 |
| 70 |
--let $show_slave_sql_error= 1 |
| 71 |
--source include/wait_for_slave_sql_error.inc |
| 72 |
--source include/stop_slave_io.inc |
| 73 |
|
| 74 |
# |
| 75 |
# 2 - Shows that it is possible to restart the server although replication |
| 76 |
# is not properly configured and working. |
| 77 |
# |
| 78 |
--let $rpl_server_number= 2 |
| 79 |
--let $rpl_server_parameters= --sync-source-info=1 --master-info-repository=TABLE --relay-log-info-repository=TABLE |
| 80 |
--source include/rpl_restart_server.inc |
| 81 |
--connection slave |
| 82 |
--error ER_REPLICA_CONFIGURATION |
| 83 |
START SLAVE SQL_THREAD; |
| 84 |
ALTER TABLE mysql.slave_relay_log_info ADD COLUMN Number_of_workers INTEGER UNSIGNED AFTER Sql_delay; |
| 85 |
UPDATE mysql.slave_relay_log_info SET Number_of_workers= 0; |
| 86 |
|
| 87 |
# |
| 88 |
# 3 - Shows that after fixing the problem the server can be properly |
| 89 |
# restared. |
| 90 |
# |
| 91 |
--let $rpl_server_number= 2 |
| 92 |
--let $rpl_server_parameters= --sync-source-info=1 --master-info-repository=TABLE --relay-log-info-repository=TABLE |
| 93 |
--source include/rpl_restart_server.inc |
| 94 |
--connection slave |
| 95 |
--source include/start_slave.inc |
| 96 |
|
| 97 |
# 4 - Shows that trying to fix the problem with START SLAVE, RESET SLAVE may |
| 98 |
# not work and requires to manually back up positions to restart |
| 99 |
# replication. |
| 100 |
# |
| 101 |
--connection master |
| 102 |
INSERT INTO t_innodb VALUES (1), (2), (3); |
| 103 |
--source include/sync_slave_sql_with_master.inc |
| 104 |
ALTER TABLE mysql.slave_relay_log_info DROP COLUMN Number_of_workers; |
| 105 |
--connection master |
| 106 |
INSERT INTO t_innodb VALUES (1), (2), (3); |
| 107 |
--connection slave |
| 108 |
# ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2 1805 |
| 109 |
--let $slave_sql_errno= 1805 |
| 110 |
--let $show_slave_sql_error= 1 |
| 111 |
--source include/wait_for_slave_sql_error.inc |
| 112 |
--source include/stop_slave_io.inc |
| 113 |
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2 |
| 114 |
START SLAVE SQL_THREAD; |
| 115 |
|
| 116 |
--let $_slave_master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1) |
| 117 |
--let $_slave_master_user= query_get_value(SHOW SLAVE STATUS, Master_User, 1) |
| 118 |
--let $_slave_master_port= query_get_value(SHOW SLAVE STATUS, Master_Port, 1) |
| 119 |
--let $_slave_master_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1) |
| 120 |
--let $_slave_master_log_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1) |
| 121 |
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2 |
| 122 |
RESET SLAVE ALL; |
| 123 |
--replace_result $_slave_master_host MASTER_HOST $_slave_master_user MASTER_USER $_slave_master_port MASTER_PORT $_slave_master_log_file MASTER_LOG_FILE $_slave_master_log_pos MASTER_LOG_POS |
| 124 |
--replace_column 2 #### |
| 125 |
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2 |
| 126 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST= '$_slave_master_host', SOURCE_USER= '$_slave_master_user', SOURCE_PORT= $_slave_master_port, SOURCE_LOG_FILE= '$_slave_master_log_file', SOURCE_LOG_POS= $_slave_master_log_pos |
| 127 |
ALTER TABLE mysql.slave_relay_log_info ADD COLUMN Number_of_workers INTEGER UNSIGNED AFTER Sql_delay; |
| 128 |
UPDATE mysql.slave_relay_log_info SET Number_of_workers= 0; |
| 129 |
RESET SLAVE ALL; |
| 130 |
--replace_result $_slave_master_host MASTER_HOST $_slave_master_user MASTER_USER $_slave_master_port MASTER_PORT $_slave_master_log_file MASTER_LOG_FILE $_slave_master_log_pos MASTER_LOG_POS |
| 131 |
--replace_column 2 #### |
| 132 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST= '$_slave_master_host', SOURCE_USER= '$_slave_master_user', SOURCE_PORT= $_slave_master_port, SOURCE_LOG_FILE= '$_slave_master_log_file', SOURCE_LOG_POS= $_slave_master_log_pos |
| 133 |
--source include/start_slave.inc |
| 134 |
--connection master |
| 135 |
--source include/sync_slave_sql_with_master.inc |
| 136 |
|
| 137 |
############################################################################### |
| 138 |
# Checking if replication can fail safely (I/O Thread) |
| 139 |
############################################################################### |
| 140 |
# |
| 141 |
# The test executes the following steps: |
| 142 |
# 1 - Changes mysql.slave_master_info and SQL Thread stops gracefully. |
| 143 |
# 2 - Shows that it is possible to restart the server although replication |
| 144 |
# is not properly configured and working. |
| 145 |
# 3 - Shows that after fixing the problem the server can be properly |
| 146 |
# restared. |
| 147 |
# 4 - Shows that trying to fix the problem with START SLAVE, RESET SLAVE may |
| 148 |
# not work and requires to manually back up positions to restart |
| 149 |
# replication. |
| 150 |
# |
| 151 |
|
| 152 |
# |
| 153 |
# 1 - Changes mysql.slave_master_info and SQL Thread stops gracefully. |
| 154 |
# |
| 155 |
--connection slave |
| 156 |
ALTER TABLE mysql.slave_master_info DROP COLUMN Enabled_auto_position; |
| 157 |
--connection master |
| 158 |
INSERT INTO t_innodb VALUES (1), (2), (3); |
| 159 |
--connection slave |
| 160 |
# ER_REPLICA_FATAL_ERROR |
| 161 |
--let $slave_io_errno= 13117 |
| 162 |
--let $show_slave_io_error= 1 |
| 163 |
--source include/wait_for_slave_io_error.inc |
| 164 |
--source include/stop_slave_sql.inc |
| 165 |
|
| 166 |
# |
| 167 |
# 2 - Shows that it is possible to restart the server although replication |
| 168 |
# is not properly configured and working. |
| 169 |
# |
| 170 |
--let $rpl_server_number= 2 |
| 171 |
--let $rpl_server_parameters= --sync-source-info=1 --master-info-repository=TABLE --relay-log-info-repository=TABLE |
| 172 |
--source include/rpl_restart_server.inc |
| 173 |
--connection slave |
| 174 |
--error ER_REPLICA_CONFIGURATION |
| 175 |
START SLAVE SQL_THREAD; |
| 176 |
ALTER TABLE mysql.slave_master_info ADD COLUMN Enabled_auto_position BOOLEAN NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.' AFTER Ssl_crlpath; |
| 177 |
UPDATE mysql.slave_master_info SET Enabled_auto_position= 0; |
| 178 |
|
| 179 |
# |
| 180 |
# 3 - Shows that after fixing the problem the server can be properly |
| 181 |
# restared. |
| 182 |
# |
| 183 |
--let $rpl_server_number= 2 |
| 184 |
--let $rpl_server_parameters= --sync-source-info=1 --master-info-repository=TABLE --relay-log-info-repository=TABLE |
| 185 |
--source include/rpl_restart_server.inc |
| 186 |
--connection slave |
| 187 |
|
| 188 |
--source include/start_slave.inc |
| 189 |
|
| 190 |
# 4 - Shows that trying to fix the problem with START SLAVE, RESET SLAVE may |
| 191 |
# not work and requires to manually back up positions to restart |
| 192 |
# replication. |
| 193 |
# |
| 194 |
--connection slave |
| 195 |
ALTER TABLE mysql.slave_master_info DROP COLUMN Enabled_auto_position; |
| 196 |
--connection master |
| 197 |
INSERT INTO t_innodb VALUES (1), (2), (3); |
| 198 |
--connection slave |
| 199 |
# ER_REPLICA_FATAL_ERROR |
| 200 |
--let $slave_io_errno= 13117 |
| 201 |
--let $show_slave_io_error= 1 |
| 202 |
--source include/wait_for_slave_io_error.inc |
| 203 |
--source include/stop_slave_sql.inc |
| 204 |
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2 |
| 205 |
START SLAVE SQL_THREAD; |
| 206 |
|
| 207 |
--let $_slave_master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1) |
| 208 |
--let $_slave_master_user= query_get_value(SHOW SLAVE STATUS, Master_User, 1) |
| 209 |
--let $_slave_master_port= query_get_value(SHOW SLAVE STATUS, Master_Port, 1) |
| 210 |
--let $_slave_master_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1) |
| 211 |
--let $_slave_master_log_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1) |
| 212 |
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2 |
| 213 |
RESET SLAVE ALL; |
| 214 |
--replace_result $_slave_master_host MASTER_HOST $_slave_master_user MASTER_USER $_slave_master_port MASTER_PORT $_slave_master_log_file MASTER_LOG_FILE $_slave_master_log_pos MASTER_LOG_POS |
| 215 |
--replace_column 2 #### |
| 216 |
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2 |
| 217 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST= '$_slave_master_host', SOURCE_USER= '$_slave_master_user', SOURCE_PORT= $_slave_master_port, SOURCE_LOG_FILE= '$_slave_master_log_file', SOURCE_LOG_POS= $_slave_master_log_pos |
| 218 |
ALTER TABLE mysql.slave_master_info ADD COLUMN Enabled_auto_position BOOLEAN NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.' AFTER Ssl_crlpath; |
| 219 |
UPDATE mysql.slave_master_info SET Enabled_auto_position= 0; |
| 220 |
RESET SLAVE ALL; |
| 221 |
--replace_result $_slave_master_host MASTER_HOST $_slave_master_user MASTER_USER $_slave_master_port MASTER_PORT $_slave_master_log_file MASTER_LOG_FILE $_slave_master_log_pos MASTER_LOG_POS |
| 222 |
--replace_column 2 #### |
| 223 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST= '$_slave_master_host', SOURCE_USER= '$_slave_master_user', SOURCE_PORT= $_slave_master_port, SOURCE_LOG_FILE= '$_slave_master_log_file', SOURCE_LOG_POS= $_slave_master_log_pos |
| 224 |
--source include/start_slave.inc |
| 225 |
--connection master |
| 226 |
--source include/sync_slave_sql_with_master.inc |
| 227 |
|
| 228 |
############################################################################### |
| 229 |
# Checking ANALYZE TABLE, CHECK TABLE, CHECKSUM TABLE, OPTIMIZE TABLE, |
| 230 |
# REPAIR TABLE, SHOW CREATE TABLE and MYSQLDUMP |
| 231 |
############################################################################### |
| 232 |
|
| 233 |
# |
| 234 |
# Check ANALYZE TABLE, CHECK TABLE and CHECKSUM TABLE |
| 235 |
# |
| 236 |
ANALYZE TABLE mysql.slave_master_info, mysql.slave_relay_log_info; |
| 237 |
CHECK TABLE mysql.slave_master_info, mysql.slave_relay_log_info EXTENDED; |
| 238 |
|
| 239 |
# |
| 240 |
# Check OPTIMIZE TABLE and REPAIR TABLE |
| 241 |
# |
| 242 |
OPTIMIZE TABLE mysql.slave_master_info, mysql.slave_relay_log_info; |
| 243 |
REPAIR TABLE mysql.slave_master_info, mysql.slave_relay_log_info EXTENDED; |
| 244 |
|
| 245 |
# |
| 246 |
# Check SHOW CREATE TABLE |
| 247 |
# |
| 248 |
SHOW CREATE TABLE mysql.slave_master_info; |
| 249 |
SHOW CREATE TABLE mysql.slave_relay_log_info; |
| 250 |
|
| 251 |
# |
| 252 |
# Check MYSQLDUMP |
| 253 |
# |
| 254 |
--echo # Search for occurrences of slave_master_info in the output from mysqldump |
| 255 |
--let $MYSQLD_DATADIR= `select @@datadir` |
| 256 |
--exec $MYSQL_DUMP mysql slave_master_info slave_relay_log_info > $MYSQLTEST_VARDIR/tmp/accessing_repository.sql |
| 257 |
--let OUTF=$MYSQLTEST_VARDIR/tmp/accessing_repository.sql |
| 258 |
perl; |
| 259 |
use strict; |
| 260 |
my $outf= $ENV{'OUTF'} or die "OUTF not set"; |
| 261 |
open(FILE, "$outf") or die("Unable to open $outf: $!\n"); |
| 262 |
my $count = () = grep(/CREATE TABLE IF NOT EXISTS `slave_master_info`/gi,<FILE>); |
| 263 |
print "- Occurrences: $count\n"; |
| 264 |
close(FILE); |
| 265 |
EOF |
| 266 |
--remove_file $MYSQLTEST_VARDIR/tmp/accessing_repository.sql |
| 267 |
|
| 268 |
############################################################################### |
| 269 |
# Cleaning up |
| 270 |
############################################################################### |
| 271 |
--connection master |
| 272 |
DROP TABLE t_innodb; |
| 273 |
--source include/sync_slave_sql_with_master.inc |
| 274 |
|
| 275 |
--source include/stop_slave.inc |
| 276 |
|
| 277 |
--disable_query_log |
| 278 |
--eval SET @@global.relay_log_info_repository="$saved_relay_repo" |
| 279 |
--eval SET @@global.master_info_repository="$saved_master_repo" |
| 280 |
--eval SET @@global.sync_source_info=$saved_sync_master |
| 281 |
--enable_query_log |
| 282 |
|
| 283 |
--query_vertical SELECT * FROM mysql.slave_master_info |
| 284 |
--query_vertical SELECT * FROM mysql.slave_relay_log_info |
| 285 |
|
| 286 |
--let $rpl_server_number= 2 |
| 287 |
--let $rpl_server_parameters= |
| 288 |
--source include/rpl_restart_server.inc |
| 289 |
|
| 290 |
--connection slave |
| 291 |
--source include/start_slave.inc |
| 292 |
|
| 293 |
--source include/rpl_end.inc |