| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test checks that the slave parameter require_row_format is persisted |
| 4 |
# and also upgraded correctly using either table or files. |
| 5 |
# |
| 6 |
# ==== Requirements ==== |
| 7 |
# |
| 8 |
# TC1: Verify that the column is added when doing an upgrade |
| 9 |
# TC2: On upgrade verify that the value for REQUIRE_ROW_FORMAT is 0 |
| 10 |
# TC3: On upgrade verify that the value for REQUIRE_ROW_FORMAT is 1 for |
| 11 |
# group replication channels |
| 12 |
# TC4: Verify that TC2 and TC3 are true when upgrading from/to |
| 13 |
# File repositories |
| 14 |
# TC5: Verify that TC2, TC3 and TC4 are true when upgrading from/to |
| 15 |
# Table repositories |
| 16 |
# |
| 17 |
# ==== Implementation ==== |
| 18 |
# |
| 19 |
# 0. Create a user to use as a privilege_checks_user |
| 20 |
# Create some test auxiliary include files to avoid step repetition. |
| 21 |
# |
| 22 |
# 1. Basic operations with REQUIRE_ROW_FORMAT |
| 23 |
# |
| 24 |
# 1.1. Set REQUIRE_ROW_FORMAT to 1 |
| 25 |
# Check the performance_schema table and file repository are correct |
| 26 |
# 1.2. Set REQUIRE_ROW_FORMAT to 0 |
| 27 |
# Check the performance_schema table and file repository are correct |
| 28 |
# |
| 29 |
# 2. File to File upgrades |
| 30 |
# |
| 31 |
# 2.1 Upgrade the server while using File repositories |
| 32 |
# Start the server using a file repository that has no privileged user |
| 33 |
# REQUIRE_ROW_FORMAT must be 0 |
| 34 |
# 2.2 Upgrade the server while using File repositories |
| 35 |
# Start the server using a file repository that has a privileged user |
| 36 |
# REQUIRE_ROW_FORMAT must be 0 |
| 37 |
# |
| 38 |
# 3. File to Table upgrades |
| 39 |
# |
| 40 |
# 3.1 Upgrade the server to Table repositories from File repositories |
| 41 |
# Start the server using a file repository that has no privileged user |
| 42 |
# REQUIRE_ROW_FORMAT must be 0 |
| 43 |
# 3.2 Upgrade the server to Table repositories from File repositories |
| 44 |
# Start the server using a file repository that has a privileged user |
| 45 |
# REQUIRE_ROW_FORMAT must be 0 |
| 46 |
# |
| 47 |
# 4. Table to Table upgrades |
| 48 |
# |
| 49 |
# 4.1 Upgrade the server while using Table repositories |
| 50 |
# Have 3 channels: |
| 51 |
# 1. A channel with no privileged user (ch1) |
| 52 |
# 2. A group_replication channel (group_replication_recovery) |
| 53 |
# 3. A channel with a privileged user (default channel) |
| 54 |
# REQUIRE_ROW_FORMAT must be 0 for 1) and 3). It must be 1 for 2) |
| 55 |
# |
| 56 |
# 5. Cleanup |
| 57 |
# |
| 58 |
# ==== References ==== |
| 59 |
# |
| 60 |
# WL #12968 : Configure replication applier to require row-based replication |
| 61 |
|
| 62 |
--source include/big_test.inc |
| 63 |
--source include/not_valgrind.inc |
| 64 |
--source include/not_group_replication_plugin.inc |
| 65 |
--source include/have_binlog_format_row.inc |
| 66 |
--source include/not_master_info_file.inc |
| 67 |
--source include/not_have_privilege_checks_user.inc |
| 68 |
--source include/not_rpl_gtid_only.inc |
| 69 |
--source include/master-slave.inc |
| 70 |
|
| 71 |
--echo |
| 72 |
--echo # 0. Create a user to use as a privilege_checks_user |
| 73 |
--echo # Create some test auxiliary include files to avoid step repetition. |
| 74 |
|
| 75 |
--source include/rpl_connection_slave.inc |
| 76 |
|
| 77 |
CREATE USER 'replication_applier'@'localhost' IDENTIFIED BY 'password'; |
| 78 |
GRANT REPLICATION_APPLIER ON * . * TO 'replication_applier'@'localhost'; |
| 79 |
FLUSH PRIVILEGES; |
| 80 |
|
| 81 |
--write_file $MYSQL_TMP_DIR/check_require_row_format_enabled_in_file_repo.inc END_OF_PROCEDURE |
| 82 |
|
| 83 |
if ($rl_info_filename == '') |
| 84 |
{ |
| 85 |
--die !!!ERROR IN TEST: you must set $rl_info_filename |
| 86 |
} |
| 87 |
|
| 88 |
--let $assert_text = Check that mysql.slave_relay_log_info does not have any entry |
| 89 |
--let $assert_cond = [SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE CHANNEL_NAME=""] = 0 |
| 90 |
--source include/assert.inc |
| 91 |
|
| 92 |
--let $count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE REQUIRE_ROW_FORMAT = 'YES'` |
| 93 |
--let $assert_text = REQUIRE_ROW_FORMAT enabled for default channel "" in performance_schema.replication_applier_configuration |
| 94 |
--let $assert_cond = $count = 1 |
| 95 |
--source include/assert.inc |
| 96 |
|
| 97 |
--let $assert_text = In the file the field is set to 1 |
| 98 |
--let $assert_file = $MYSQLD_DATADIR/$rl_info_filename |
| 99 |
--let $assert_only_after = ^1\$ |
| 100 |
--let $assert_select = 1 |
| 101 |
--let $assert_count = 1 |
| 102 |
--source include/assert_grep.inc |
| 103 |
|
| 104 |
END_OF_PROCEDURE |
| 105 |
|
| 106 |
--write_file $MYSQL_TMP_DIR/check_require_row_format_disabled_in_file_repo.inc END_OF_PROCEDURE |
| 107 |
|
| 108 |
--let $assert_text = Check that mysql.slave_relay_log_info does not have any entry |
| 109 |
--let $assert_cond = [SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE CHANNEL_NAME=""] = 0 |
| 110 |
--source include/assert.inc |
| 111 |
|
| 112 |
--let $count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE REQUIRE_ROW_FORMAT = 'NO'` |
| 113 |
--let $assert_text = REQUIRE_ROW_FORMAT disabled for default channel "" in performance_schema.replication_applier_configuration |
| 114 |
--let $assert_cond = $count = 1 |
| 115 |
--source include/assert.inc |
| 116 |
|
| 117 |
END_OF_PROCEDURE |
| 118 |
|
| 119 |
--let $MYSQLD_DATADIR= `select @@datadir` |
| 120 |
--let $rl_info_filename = `SELECT @@relay_log_info_file` |
| 121 |
|
| 122 |
# 1. Basic operations with REQUIRE_ROW_FORMAT |
| 123 |
|
| 124 |
--echo |
| 125 |
--echo # 1.1. Set REQUIRE_ROW_FORMAT to 1 |
| 126 |
--echo # Check the performance_schema table and file repository are correct |
| 127 |
|
| 128 |
STOP SLAVE; |
| 129 |
|
| 130 |
CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", REQUIRE_ROW_FORMAT = 1; |
| 131 |
|
| 132 |
--source $MYSQL_TMP_DIR/check_require_row_format_enabled_in_file_repo.inc |
| 133 |
|
| 134 |
--echo |
| 135 |
--echo # 1.2. Set REQUIRE_ROW_FORMAT to 0 |
| 136 |
--echo # Check the performance_schema table and file repository are correct |
| 137 |
|
| 138 |
CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 0; |
| 139 |
|
| 140 |
--source $MYSQL_TMP_DIR/check_require_row_format_disabled_in_file_repo.inc |
| 141 |
|
| 142 |
# 2. File to File upgrades |
| 143 |
|
| 144 |
--echo |
| 145 |
--echo # 2.1 Upgrade the server while using File repositories |
| 146 |
--echo # Start the server using a file repository that has no privileged user |
| 147 |
--echo # REQUIRE_ROW_FORMAT must be 0 |
| 148 |
|
| 149 |
--let $sub_testcase = no_flag_no_priv_user |
| 150 |
--let $rpl_server_restart_parameters = --skip_replica_start |
| 151 |
--let $slave_server_num = 2 |
| 152 |
--source extra/rpl_tests/restart_slave_with_custom_relaylog_repo_file.inc |
| 153 |
|
| 154 |
--source $MYSQL_TMP_DIR/check_require_row_format_disabled_in_file_repo.inc |
| 155 |
|
| 156 |
--echo |
| 157 |
--echo # 2.2 Upgrade the server while using File repositories |
| 158 |
--echo # Start the server using a file repository that has a privileged user |
| 159 |
--echo # REQUIRE_ROW_FORMAT must be 0 |
| 160 |
|
| 161 |
--let $sub_testcase = no_flag_with_priv_user |
| 162 |
--let $rpl_server_restart_parameters = --skip_replica_start |
| 163 |
--let $slave_server_num = 2 |
| 164 |
--source extra/rpl_tests/restart_slave_with_custom_relaylog_repo_file.inc |
| 165 |
|
| 166 |
--source $MYSQL_TMP_DIR/check_require_row_format_disabled_in_file_repo.inc |
| 167 |
|
| 168 |
--echo # Reset the repository to default values |
| 169 |
|
| 170 |
CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER=NULL, REQUIRE_ROW_FORMAT = 0; |
| 171 |
|
| 172 |
--source $MYSQL_TMP_DIR/check_require_row_format_disabled_in_file_repo.inc |
| 173 |
|
| 174 |
# 3. File to Table upgrades |
| 175 |
|
| 176 |
--echo |
| 177 |
--echo # 3.1 Upgrade the server to Table repositories from File repositories |
| 178 |
--echo # Start the server using a file repository that has no privileged user |
| 179 |
--echo # REQUIRE_ROW_FORMAT must be 0 |
| 180 |
|
| 181 |
ALTER TABLE mysql.slave_relay_log_info DROP COLUMN Require_row_format; |
| 182 |
|
| 183 |
--let $sub_testcase = no_flag_no_priv_user |
| 184 |
--let $rpl_server_restart_parameters = --skip_replica_start --relay-log-info-repository=TABLE --upgrade=FORCE |
| 185 |
--let $slave_server_num = 2 |
| 186 |
--source extra/rpl_tests/restart_slave_with_custom_relaylog_repo_file.inc |
| 187 |
|
| 188 |
--let $assert_text = Check that mysql.slave_relay_log_info has an entry with REQUIRE_ROW_FORMAT set to 0 |
| 189 |
--let $assert_cond = [SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE CHANNEL_NAME="" AND REQUIRE_ROW_FORMAT = 0] = 1 |
| 190 |
--source include/assert.inc |
| 191 |
|
| 192 |
--let $count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE REQUIRE_ROW_FORMAT = 'NO'` |
| 193 |
--let $assert_text = Check entry for default channel "" in performance_schema.replication_applier_configuration |
| 194 |
--let $assert_cond = $count = 1 |
| 195 |
--source include/assert.inc |
| 196 |
|
| 197 |
--echo |
| 198 |
--echo # 3.2 Upgrade the server to Table repositories from File repositories |
| 199 |
--echo # Start the server using a file repository that has a privileged user |
| 200 |
--echo # REQUIRE_ROW_FORMAT must be 0 |
| 201 |
|
| 202 |
--let $rpl_server_number = 2 |
| 203 |
--let $rpl_server_parameters = --relay-log-info-repository=FILE |
| 204 |
--let $explicit_default_wait_counter = 15000 |
| 205 |
--source include/rpl_restart_server.inc |
| 206 |
|
| 207 |
ALTER TABLE mysql.slave_relay_log_info DROP COLUMN Require_row_format; |
| 208 |
|
| 209 |
--let $sub_testcase = no_flag_with_priv_user |
| 210 |
--let $rpl_server_restart_parameters = --skip_replica_start --relay-log-info-repository=TABLE --upgrade=FORCE |
| 211 |
--let $slave_server_num = 2 |
| 212 |
--source extra/rpl_tests/restart_slave_with_custom_relaylog_repo_file.inc |
| 213 |
|
| 214 |
--let $assert_text = Check that mysql.slave_relay_log_info has an entry with REQUIRE_ROW_FORMAT set to 0 |
| 215 |
--let $assert_cond = [SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE CHANNEL_NAME="" AND REQUIRE_ROW_FORMAT = 0] = 1 |
| 216 |
--source include/assert.inc |
| 217 |
|
| 218 |
--let $count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE REQUIRE_ROW_FORMAT = 'NO'` |
| 219 |
--let $assert_text = Check entry for default channel "" in performance_schema.replication_applier_configuration |
| 220 |
--let $assert_cond = $count = 1 |
| 221 |
--source include/assert.inc |
| 222 |
|
| 223 |
# 4. Table to Table upgrades |
| 224 |
|
| 225 |
--echo |
| 226 |
--echo # 4.1 Upgrade the server while using Table repositories |
| 227 |
--echo # Have 3 channels: |
| 228 |
--echo # 1. A channel with no privileged user (ch1) |
| 229 |
--echo # 2. A group_replication channel (group_replication_recovery) |
| 230 |
--echo # 3. A channel with a privileged user (default channel) |
| 231 |
--echo # REQUIRE_ROW_FORMAT must be 0 for 1) and 3). It must be 1 for 2) |
| 232 |
|
| 233 |
# For run where GTID mode is OFF we enable it so we can configure the GR recovery channel |
| 234 |
--let $rpl_gtid_mode= ON |
| 235 |
--let $rpl_server_numbers= 2 |
| 236 |
--let $rpl_set_enforce_gtid_consistency= 1 |
| 237 |
--let $rpl_skip_sync= 1 |
| 238 |
--let $no_extra_info = 1 |
| 239 |
--source include/rpl_set_gtid_mode.inc |
| 240 |
|
| 241 |
CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=12 FOR CHANNEL "ch1" ; |
| 242 |
--disable_warnings |
| 243 |
CHANGE REPLICATION SOURCE TO SOURCE_USER="root" FOR CHANNEL "group_replication_recovery"; |
| 244 |
--enable_warnings |
| 245 |
CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=12, PRIVILEGE_CHECKS_USER = 'replication_applier'@'localhost' FOR CHANNEL ""; |
| 246 |
|
| 247 |
# Revert the table to 10 lines (pre upgrade) |
| 248 |
ALTER TABLE mysql.slave_relay_log_info DROP COLUMN Require_row_format; |
| 249 |
UPDATE mysql.slave_relay_log_info SET Number_of_lines = 10; |
| 250 |
|
| 251 |
--let $rpl_server_number = 2 |
| 252 |
--let $rpl_server_parameters = --skip_replica_start --relay-log-info-repository=TABLE --upgrade=FORCE |
| 253 |
--let $explicit_default_wait_counter = 15000 |
| 254 |
--source include/rpl_restart_server.inc |
| 255 |
|
| 256 |
# We have only 1 table here as group_replication_recovery does not show up |
| 257 |
--let $count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE REQUIRE_ROW_FORMAT = 'YES'` |
| 258 |
--let $assert_text = Check the number of channels with enabled REQUIRE_ROW_FORMAT |
| 259 |
--let $assert_cond = $count = 0 |
| 260 |
--source include/assert.inc |
| 261 |
|
| 262 |
--let $count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE REQUIRE_ROW_FORMAT = 'NO'` |
| 263 |
--let $assert_text = Check the number of channels with disabled REQUIRE_ROW_FORMAT |
| 264 |
--let $assert_cond = $count = 2 |
| 265 |
--source include/assert.inc |
| 266 |
|
| 267 |
--let $assert_text = Check that mysql.slave_relay_log_info has an entry with REQUIRE_ROW_FORMAT set to 0 |
| 268 |
--let $assert_cond = [SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE CHANNEL_NAME="" AND REQUIRE_ROW_FORMAT = 0] = 1 |
| 269 |
--source include/assert.inc |
| 270 |
|
| 271 |
--let $assert_text = Check that mysql.slave_relay_log_info has an entry with REQUIRE_ROW_FORMAT set to 1 |
| 272 |
--let $assert_cond = [SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE CHANNEL_NAME="group_replication_recovery" AND REQUIRE_ROW_FORMAT = 1] = 1 |
| 273 |
--source include/assert.inc |
| 274 |
|
| 275 |
--let $assert_text = Check that mysql.slave_relay_log_info has an entry with REQUIRE_ROW_FORMAT set to 0 |
| 276 |
--let $assert_cond = [SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE CHANNEL_NAME="ch1" AND REQUIRE_ROW_FORMAT = 0] = 1 |
| 277 |
--source include/assert.inc |
| 278 |
|
| 279 |
--echo |
| 280 |
--echo # 5. Cleanup |
| 281 |
|
| 282 |
--remove_file $MYSQL_TMP_DIR/check_require_row_format_enabled_in_file_repo.inc |
| 283 |
--remove_file $MYSQL_TMP_DIR/check_require_row_format_disabled_in_file_repo.inc |
| 284 |
|
| 285 |
DROP USER 'replication_applier'@'localhost'; |
| 286 |
|
| 287 |
RESET SLAVE ALL FOR CHANNEL "ch1"; |
| 288 |
RESET SLAVE ALL FOR CHANNEL "group_replication_recovery"; |
| 289 |
|
| 290 |
if ($gtid_mode_on == 0) { |
| 291 |
--let $rpl_gtid_mode = 0 |
| 292 |
--let $rpl_set_enforce_gtid_consistency = 0 |
| 293 |
} |
| 294 |
--let $no_extra_info = 1 |
| 295 |
--source include/rpl_set_gtid_mode.inc |
| 296 |
|
| 297 |
--let $rpl_channel_name= |
| 298 |
--let $rpl_skip_sync= 1 |
| 299 |
--source include/rpl_end.inc |