| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test will fake an upgrade from MySQL 5.6.30 to MySQL 5.7.13+, with |
| 4 |
# respect to the slave_master_info table, certifying that all slave |
| 5 |
# capabilities remain operational after the upgrade. It will also ensure that |
| 6 |
# a slave with Tls_version field of mysql.slave_master_info table switched |
| 7 |
# position with Channel_name field will handle the failure properly. Finally |
| 8 |
# it will setup and use three channels (default + two), will change the |
| 9 |
# repository table and will restart the slave to assert the expected errors |
| 10 |
# on generating the slave infrastructure based on the repository during |
| 11 |
# server initialization. |
| 12 |
# |
| 13 |
# First part: the upgrade |
| 14 |
# |
| 15 |
# The test case will drop the current slave_master_info table, creating one |
| 16 |
# just like MySQL 5.6.30 installation would create. |
| 17 |
# |
| 18 |
# Then, the test case will call mysql_upgrade, and will restart the slave |
| 19 |
# after the upgrade. |
| 20 |
# |
| 21 |
# The test case will create two additional channels, assert that the channels |
| 22 |
# were created and are displayed at SHOW SLAVE STATUS, will execute a RESET |
| 23 |
# SLAVE ALL and will recreate the default channel. |
| 24 |
# |
| 25 |
# Finally, the test will generate some workload on the master and will sync |
| 26 |
# the slave before finishing the test case. |
| 27 |
# |
| 28 |
# Second part: switching positions of Tls_version and Channel_name |
| 29 |
# |
| 30 |
# For this part, the test case will alter the table and try to perform |
| 31 |
# some channel operations. |
| 32 |
# |
| 33 |
# Notice that in this test case, because we need to run mysql_upgrade, we |
| 34 |
# inverted the server's roles (slave is server #1 and master is server #2). |
| 35 |
# |
| 36 |
# Third part: switching positions of Tls_version and Channel_name after having |
| 37 |
# channels configured and used. |
| 38 |
# |
| 39 |
# For this part, the test case will create and use (generating workload on the |
| 40 |
# master and waiting for it to be replicated) three channels (the default + two |
| 41 |
# additional channels). Then, the test will stop the slave, will alter the |
| 42 |
# repository table and will restart the slave server. After restarting, it will |
| 43 |
# try to perform some channel operations. |
| 44 |
# |
| 45 |
# Notice that in this test case, because we need to run mysql_upgrade, we |
| 46 |
# inverted the server's roles (slave is server #1 and master is server #2). |
| 47 |
# |
| 48 |
# ==== Related Bugs and Worklogs ==== |
| 49 |
# |
| 50 |
# BUG#23180202 REPLICATION CHANNELS ARE GETTING SAME NAME IN MSR AFTER UPGRADE |
| 51 |
# |
| 52 |
|
| 53 |
--source include/no_valgrind_without_big.inc |
| 54 |
--source include/not_group_replication_plugin.inc |
| 55 |
# This test case is binary log format agnostic |
| 56 |
--source include/have_binlog_format_mixed.inc |
| 57 |
# Test requires master-info-repository=TABLE, relay-log-info-repository=TABLE |
| 58 |
--source include/have_slave_repository_type_table.inc |
| 59 |
# Using this unusual topology because of mysql_upgrade |
| 60 |
--let $rpl_topology= 2->1 |
| 61 |
--source include/rpl_init.inc |
| 62 |
|
| 63 |
# First part: the upgrade |
| 64 |
|
| 65 |
--echo # DROP slave_master_info table and re-create it as of MySQL 5.6.30 |
| 66 |
--let $rpl_connection_name= server_1 |
| 67 |
--source include/rpl_connection.inc |
| 68 |
CALL mtr.add_suppression('A replica with the same server_uuid/server_id as this replica has connected to the source'); |
| 69 |
--source include/stop_slave.inc |
| 70 |
USE mysql; |
| 71 |
DROP TABLE `slave_master_info`; |
| 72 |
CREATE TABLE `slave_master_info` ( |
| 73 |
`Number_of_lines` INT(10) UNSIGNED NOT NULL COMMENT 'Number of lines in the file.', |
| 74 |
`Master_log_name` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log currently being read from the master.', |
| 75 |
`Master_log_pos` bigint(20) UNSIGNED NOT NULL COMMENT 'The master log position of the last read event.', |
| 76 |
`Host` CHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'The host name of the master.', |
| 77 |
`User_name` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.', |
| 78 |
`User_password` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.', |
| 79 |
`Port` INT(10) UNSIGNED NOT NULL COMMENT 'The network port used to connect to the master.', |
| 80 |
`Connect_retry` INT(10) UNSIGNED NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.', |
| 81 |
`Enabled_ssl` TINYINT(1) NOT NULL COMMENT 'Indicates whether the server supports SSL connections.', |
| 82 |
`Ssl_ca` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.', |
| 83 |
`Ssl_capath` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.', |
| 84 |
`Ssl_cert` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.', |
| 85 |
`Ssl_cipher` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.', |
| 86 |
`Ssl_key` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.', |
| 87 |
`Ssl_verify_server_cert` TINYINT(1) NOT NULL COMMENT 'Whether to verify the server certificate.', |
| 88 |
`Heartbeat` FLOAT NOT NULL, |
| 89 |
`Bind` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server', |
| 90 |
`Ignored_server_ids` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored, followed by the actual server IDs', |
| 91 |
`Uuid` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.', |
| 92 |
`Retry_count` BIGINT(20) UNSIGNED NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.', |
| 93 |
`Ssl_crl` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)', |
| 94 |
`Ssl_crlpath` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files', |
| 95 |
`Enabled_auto_position` TINYINT(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.', |
| 96 |
PRIMARY KEY (`Host`,`Port`) |
| 97 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information' TABLESPACE=mysql; |
| 98 |
|
| 99 |
--echo # Running mysql_upgrade to update slave_master_info table |
| 100 |
|
| 101 |
--let $rpl_server_parameters= --upgrade=FORCE |
| 102 |
--let $rpl_server_number= 1 |
| 103 |
--let $wait_counter= 10000 |
| 104 |
--source include/rpl_restart_server.inc |
| 105 |
|
| 106 |
# Create two additional channels on the slave |
| 107 |
--let $rpl_connection_name= server_1 |
| 108 |
--source include/rpl_connection.inc |
| 109 |
|
| 110 |
--replace_result $SERVER_MYPORT_2 MASTER_PORT |
| 111 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='root', SOURCE_HOST='127.0.0.1', SOURCE_PORT=$SERVER_MYPORT_2 FOR CHANNEL '' |
| 112 |
--replace_result $SERVER_MYPORT_2 MASTER_PORT |
| 113 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='root', SOURCE_HOST='127.0.0.1', SOURCE_PORT=$SERVER_MYPORT_2 FOR CHANNEL 'channel_1' |
| 114 |
--replace_result $SERVER_MYPORT_2 MASTER_PORT |
| 115 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='root', SOURCE_HOST='127.0.0.1', SOURCE_PORT=$SERVER_MYPORT_2 FOR CHANNEL 'channel_2' |
| 116 |
|
| 117 |
# Assert that all three channels are reached by name in SHOW SLAVE STATUS |
| 118 |
--let $channel_name= query_get_value(SHOW SLAVE STATUS, Channel_Name, 1) |
| 119 |
--let $assert_text= Default channel name is '' |
| 120 |
--let $assert_cond= "$channel_name" = "" |
| 121 |
--source include/assert.inc |
| 122 |
|
| 123 |
--let $channel_name= query_get_value(SHOW SLAVE STATUS, Channel_Name, 2) |
| 124 |
--let $assert_text= Second channel name is 'channel_1' |
| 125 |
--let $assert_cond= "$channel_name" = "channel_1" |
| 126 |
--source include/assert.inc |
| 127 |
|
| 128 |
--let $channel_name= query_get_value(SHOW SLAVE STATUS, Channel_Name, 3) |
| 129 |
--let $assert_text= Third channel name is 'channel_2' |
| 130 |
--let $assert_cond= "$channel_name" = "channel_2" |
| 131 |
--source include/assert.inc |
| 132 |
|
| 133 |
# Stop slave and reset the slave removing all channels |
| 134 |
--source include/stop_slave.inc |
| 135 |
RESET SLAVE ALL; |
| 136 |
|
| 137 |
# Create the default channel again |
| 138 |
--replace_result $SERVER_MYPORT_2 MASTER_PORT |
| 139 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='root', SOURCE_HOST='127.0.0.1', SOURCE_PORT=$SERVER_MYPORT_2 |
| 140 |
--source include/start_slave.inc |
| 141 |
|
| 142 |
# Generate traffic on the master |
| 143 |
--let $rpl_connection_name= server_2 |
| 144 |
--source include/rpl_connection.inc |
| 145 |
CREATE TABLE t1 (c1 INT); |
| 146 |
INSERT INTO t1 VALUES (1); |
| 147 |
--source include/save_master_pos.inc |
| 148 |
--let $rpl_connection_name= server_1 |
| 149 |
--source include/rpl_connection.inc |
| 150 |
--source include/sync_slave_sql.inc |
| 151 |
|
| 152 |
# In order to make check-testcase.test happy, we need to do two small changes |
| 153 |
# on mysql.slave_master_info table |
| 154 |
|
| 155 |
ALTER TABLE slave_master_info |
| 156 |
MODIFY Host CHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NULL COMMENT 'The host name of the master.', |
| 157 |
ALTER COLUMN Channel_name DROP DEFAULT; |
| 158 |
|
| 159 |
# Second part: switching positions of Tls_version and Channel_name |
| 160 |
|
| 161 |
--source include/stop_slave.inc |
| 162 |
|
| 163 |
# The slave will throw the following errors: |
| 164 |
CALL mtr.add_suppression('Info table has a problem with its key field.*slave_master_info'); |
| 165 |
CALL mtr.add_suppression('Error in checking mysql.slave_master_info repository info type of TABLE'); |
| 166 |
CALL mtr.add_suppression('Error creating connection metadata'); |
| 167 |
|
| 168 |
# Change the position of the slave_master_info table primary key |
| 169 |
ALTER TABLE slave_master_info |
| 170 |
MODIFY Channel_name CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL |
| 171 |
COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication' |
| 172 |
AFTER Tls_version; |
| 173 |
|
| 174 |
# We cannot perform repository operations until the repository be fixed |
| 175 |
|
| 176 |
--error ER_CONNECTION_METADATA |
| 177 |
RESET SLAVE ALL; |
| 178 |
|
| 179 |
# File to GREP |
| 180 |
--let $assert_file=$MYSQLTEST_VARDIR/tmp/slave.err |
| 181 |
# Show entries only after the last occurrence of the following pattern |
| 182 |
--let $assert_only_after=.* \[Note\] \[[^]]*\] \[[^]]*\] Shutting down replica threads |
| 183 |
# Each test will log only one warning line |
| 184 |
--let $assert_count= 1 |
| 185 |
# Assert that there is the expected warning log line but just after the last restart |
| 186 |
--let $assert_select=.* \[ERROR\] \[[^]]*\] \[[^]]*\] Info table has a problem with its key field.*slave_master_info |
| 187 |
--let $assert_text= Found the expected error line in the error log. |
| 188 |
--source include/assert_grep.inc |
| 189 |
|
| 190 |
--replace_result $SERVER_MYPORT_2 MASTER_PORT |
| 191 |
--error ER_REPLICA_CONFIGURATION |
| 192 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='root', SOURCE_HOST='127.0.0.1', SOURCE_PORT=$SERVER_MYPORT_2 |
| 193 |
|
| 194 |
--error ER_REPLICA_CONFIGURATION |
| 195 |
START SLAVE; |
| 196 |
|
| 197 |
# Restore the position of the slave_master_info table primary key |
| 198 |
ALTER TABLE slave_master_info |
| 199 |
MODIFY Channel_name CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL |
| 200 |
COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication' |
| 201 |
AFTER Enabled_auto_position; |
| 202 |
|
| 203 |
--let $rpl_server_number= 1 |
| 204 |
--let $rpl_server_parameters= |
| 205 |
--source include/rpl_restart_server.inc |
| 206 |
|
| 207 |
# This now should work fine now |
| 208 |
RESET SLAVE ALL; |
| 209 |
|
| 210 |
# Create the default channel again |
| 211 |
# to replicate from the last synced position |
| 212 |
--replace_result $SERVER_MYPORT_2 MASTER_PORT $_saved_file FILE $_saved_pos POS |
| 213 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='root', SOURCE_HOST='127.0.0.1', SOURCE_PORT=$SERVER_MYPORT_2, SOURCE_LOG_FILE='$_saved_file', SOURCE_LOG_POS=$_saved_pos |
| 214 |
--source include/start_slave.inc |
| 215 |
|
| 216 |
# Third part: switching positions of Tls_version and Channel_name after having |
| 217 |
# channels configured and used. |
| 218 |
|
| 219 |
# The slave will throw the following errors: |
| 220 |
CALL mtr.add_suppression('Failed to create a channel from connection metadata repository'); |
| 221 |
CALL mtr.add_suppression('Could not create channel list'); |
| 222 |
CALL mtr.add_suppression('Failed to create or recover replication info repositories'); |
| 223 |
|
| 224 |
# Make each channel to replicate something |
| 225 |
# On default channel |
| 226 |
--let $rpl_connection_name= server_2 |
| 227 |
--source include/rpl_connection.inc |
| 228 |
INSERT INTO t1 VALUES (2); |
| 229 |
--let $sync_slave_connection= server_1 |
| 230 |
# [--let $rpl_channel_name= 'NAME'] |
| 231 |
--source include/sync_slave_sql_with_master.inc |
| 232 |
--source include/stop_slave.inc |
| 233 |
|
| 234 |
# On channel_1 |
| 235 |
--replace_result $SERVER_MYPORT_2 MASTER_PORT $_saved_file FILE $_saved_pos POS |
| 236 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='root', SOURCE_HOST='127.0.0.1', SOURCE_PORT=$SERVER_MYPORT_2, SOURCE_LOG_FILE='$_saved_file', SOURCE_LOG_POS=$_saved_pos FOR CHANNEL 'channel_1' |
| 237 |
--let $rpl_channel_name= 'channel_1' |
| 238 |
--source include/start_slave.inc |
| 239 |
--let $rpl_connection_name= server_2 |
| 240 |
--source include/rpl_connection.inc |
| 241 |
INSERT INTO t1 VALUES (3); |
| 242 |
--let $sync_slave_connection= server_1 |
| 243 |
--source include/sync_slave_sql_with_master.inc |
| 244 |
--source include/stop_slave.inc |
| 245 |
|
| 246 |
# On channel_2 |
| 247 |
--replace_result $SERVER_MYPORT_2 MASTER_PORT $_saved_file FILE $_saved_pos POS |
| 248 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='root', SOURCE_HOST='127.0.0.1', SOURCE_PORT=$SERVER_MYPORT_2, SOURCE_LOG_FILE='$_saved_file', SOURCE_LOG_POS=$_saved_pos FOR CHANNEL 'channel_2' |
| 249 |
--let $rpl_channel_name= 'channel_2' |
| 250 |
--source include/start_slave.inc |
| 251 |
--let $rpl_connection_name= server_2 |
| 252 |
--source include/rpl_connection.inc |
| 253 |
INSERT INTO t1 VALUES (4); |
| 254 |
--let $sync_slave_connection= server_1 |
| 255 |
--source include/sync_slave_sql_with_master.inc |
| 256 |
--source include/stop_slave.inc |
| 257 |
|
| 258 |
# Change the position of the slave_master_info table primary key |
| 259 |
ALTER TABLE slave_master_info |
| 260 |
MODIFY Channel_name CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL |
| 261 |
COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication' |
| 262 |
AFTER Tls_version; |
| 263 |
|
| 264 |
--let $rpl_server_number= 1 |
| 265 |
--let $rpl_server_parameters= |
| 266 |
--source include/rpl_restart_server.inc |
| 267 |
|
| 268 |
# We cannot perform repository operations until the repository be fixed |
| 269 |
--error ER_REPLICA_CONFIGURATION |
| 270 |
RESET SLAVE ALL; |
| 271 |
|
| 272 |
# File to GREP |
| 273 |
--let $assert_file=$MYSQLTEST_VARDIR/tmp/slave.err |
| 274 |
# Show entries only after the last occurrence of the following pattern |
| 275 |
--let $assert_only_after=.* \[Note\] \[[^]]*\] \[[^]]*\] Shutting down replica threads |
| 276 |
# Each test will log only one warning line |
| 277 |
--let $assert_count= 1 |
| 278 |
# Assert that there is the expected warning log line but just after the last restart |
| 279 |
--let $assert_select=.* \[ERROR\] \[[^]]*\] \[[^]]*\] Replica: Failed to create a channel from connection metadata repository |
| 280 |
--let $assert_text= Found the expected error line in the error log generated on server startup. |
| 281 |
--source include/assert_grep.inc |
| 282 |
|
| 283 |
# Restore the position of the slave_master_info table primary key |
| 284 |
ALTER TABLE slave_master_info |
| 285 |
MODIFY Channel_name CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL |
| 286 |
COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication' |
| 287 |
AFTER Enabled_auto_position; |
| 288 |
|
| 289 |
--let $rpl_server_number= 1 |
| 290 |
--let $rpl_server_parameters= |
| 291 |
--source include/rpl_restart_server.inc |
| 292 |
|
| 293 |
# This now should work fine now |
| 294 |
--let $rpl_channel_name= |
| 295 |
--let $slave_io_errno= convert_error(ER_SERVER_SOURCE_FATAL_ERROR_READING_BINLOG) |
| 296 |
--source include/stop_slave.inc |
| 297 |
RESET SLAVE ALL; |
| 298 |
|
| 299 |
# Create the default channel again |
| 300 |
# to replicate from the last synced position |
| 301 |
--replace_result $SERVER_MYPORT_2 MASTER_PORT $_saved_file FILE $_saved_pos POS |
| 302 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='root', SOURCE_HOST='127.0.0.1', SOURCE_PORT=$SERVER_MYPORT_2, SOURCE_LOG_FILE='$_saved_file', SOURCE_LOG_POS=$_saved_pos |
| 303 |
--source include/start_slave.inc |
| 304 |
|
| 305 |
# Cleanup |
| 306 |
--let $rpl_connection_name= server_2 |
| 307 |
--source include/rpl_connection.inc |
| 308 |
DROP TABLE t1; |
| 309 |
--source include/rpl_end.inc |
| 310 |
|
| 311 |
# The above two assert_grep.inc sources require to restart server. |
| 312 |
--source include/force_restart.inc |