# ==== Purpose ==== # # The purpose of this test script is to verify the persistence of # PRIVILEGE_CHECKS_USERNAME, and PRIVILEGE_CHECKS_HOSTNAME in both # TABLE and FILE type of relay-log-info-repository. # # ==== Requirements ===== # # File type repo: # ------------------- # R.P.F1: CHANGE MASTER sets the PRIVILEGE_CHECKS_USER correctly. # R.P.F2: PRIVILEGE_CHECKS_USER persists after restarting the server. # # TABLE type repo: # ------------------- # R.P.T1: CHANGE MASTER sets the PRIVILEGE_CHECKS_USER correctly. # R.P.T2: PRIVILEGE_CHECKS_USER persists after restarting the server. # R.P.T3: RESET SLAVE should keep value of PRIVILEGE_CHECKS_USER. # # ERROR/Warning in following Test Cases: # ----------------- # For FILE repo: # --------- # R.E.F1: privilege_checks_username has more than 32 length. # R.E.F2: privilege_checks_hostname has more than 255 length. # R.E.F3: privilege_checks_hostname has @. # R.E.F5. privilege_checks_username is anonymous. # R.E.F6. privilege_checks_user is a non existent user. # # For TABLE repo: # ---------- # R.E.T1: privilege_checks_username has more than 32 length. # R.E.T2: privilege_checks_hostname has more than 255 length. # R.E.T3: privilege_checks_hostname has @. # R.E.T4. privilege_checks_username is NULL and privilege_checks_hostname is not # NULL. # R.E.T5. privilege_checks_username is anonymous. # R.E.T6. privilege_checks_user is a non existent user. # # ==== Implementation ==== # # Prerequisites: # 1. add mtr suppression statement for errors on various error test cases for # FILE and TABLE type repository. # 2. create user replication_applier to use in change master as # privilege_checks_user with REPLICATION_APPLIER privilege. # # TC.P.F1: CHANGE MASTER sets the PRIVILEGE_CHECKS_USER correctly. # 1. issue change master for channel "" to have PRIVILEGE_CHECKS_USER as # 'replication_applier'@'localhost'. # 2. verify that pfs table has correct PRIVILEGE_CHECKS_USER # 3. also verify privlege_checks_user info in repo file relay_info.log. # # TC.P.F2: PRIVILEGE_CHECKS_USER persists after restarting the server. # 1. restart the slave server. # 2. verify that pfs table has correct PRIVILEGE_CHECKS_USER # 3. also verify privlege_checks_user info in repo file relay_info.log. # # TC.P.T1: CHANGE MASTER sets the PRIVILEGE_CHECKS_USER correctly. # 1. create two channels ch1 and ch2 when slave is configured with TABLE type # repo. "ch1" has not PRIVILEGE_CHECKS_USER, "ch2" has # 'replication_applier'@'localhost' as PRIVILEGE_CHECK_USER. # 2. verify that there are three channel entries in both pfs and # slave_relay_log_info tables. # 3. verify that "ch1" has NULL, and (NULL,NULL) for PRIVILEGE_CHECKS_USER, # and (Privilege_checks_username, Privilege_checks_hostname) in # respectively pfs and slave_relay_log_info tables. # # TC.P.T2: PRIVILEGE_CHECKS_USER persists after restarting the server. # 1. restart the slave server. # 2. verify that there are three channel entries in both pfs and # slave_relay_log_info tables. # 3. verify that "ch1" has NULL, and (NULL,NULL) for PRIVILEGE_CHECKS_USER, # and (Privilege_checks_username, Privilege_checks_hostname) in # respectively pfs and slave_relay_log_info tables. # # TC.P.T3: RESET SLAVE should keep value of PRIVILEGE_CHECKS_USER. # 1. reset slave for channel "". # 2. verify that slave_relay_log_info table and pfs have 3 records. # 3. verify that "ch1" kept values for PRIVILEGE_CHECKS_USER, # and (Privilege_checks_username, Privilege_checks_hostname) in # respectively pfs and slave_relay_log_info tables. # # TC.E.F1: privilege_checks_username has more than 32 length. # a. CHANGE MASTER will result in ER_CLIENT_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. issue change master for default channel "" to set # privilege_checks_user with privilege_check_username more than 32 char. # 2. change master fails due to ER_WRONG_STRING_LENGTH. # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. set debug point simulate_priv_check_username_above_limit to simulate # failure of channel config due to more than 32 chars # privilege_checks_username. # 2. start the slave server. # 3. verify channel "" entry has privilege_checks_user = "". # c. SLAVE START will result in failure due to invalid config. # 1. start slave should fail due to ER_REPLICA_AM_INIT_REPOSITORY. # # TC.E.F2: privilege_checks_username has more than 255 length. # a. CHANGE MASTER will result in ER_CLIENT_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. issue change master for default channel "" to set # privilege_checks_user with privilege_check_hostname more than 255 # char. # 2. change master fails due to ER_WRONG_STRING_LENGTH. # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. set debug point simulate_priv_check_hostname_above_limit to simulate # failure of channel config due to more than 255 chars # privilege_checks_hostname. # 2. start the slave server. # 3. verify channel "" entry has privilege_checks_user = "". # c. SLAVE START will result in failure due to invalid config. # 1. start slave should fail due to ER_REPLICA_AM_INIT_REPOSITORY. # # TC.E.F3: privilege_checks_hostname has @. # a. CHANGE MASTER will result in ER_UNKNOWN_ERROR. # 1. issue change master for default channel "" to set # privilege_checks_user with privilege_check_hostname has @. # 2. change master fails due to ER_UNKNOWN_ERROR. # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. create relay_info.log with privilege_checks_hostname to have @. # 2. start the slave server. # 3. verify channel "" entry has privilege_checks_user = "". # c. SLAVE START will result in failure due to invalid config. # 1. start slave should fail due to ER_REPLICA_AM_INIT_REPOSITORY. # # TC.E.F5. privilege_checks_username is anonymous. # a. CHANGE MASTER will result in # ER_CLIENT_PRIVILEGE_CHECKS_USER_CANNOT_BE_ANONYMOUS. # 1. issue change master for default channel "" to set # privilege_checks_user as ''@'localhost'. # 2. change master fails due to # ER_CLIENT_PRIVILEGE_CHECKS_USER_CANNOT_BE_ANONYMOUS. # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. create relay_info.log with empty string for privilege_checks_hostname. # 2. start the slave server. # 3. verify channel "" entry has privilege_checks_user = "". # c. SLAVE START will result in failure due to invalid config. # 1. start slave should fail due to ER_REPLICA_AM_INIT_REPOSITORY. # # TC.E.F6. privilege_checks_user is a non existent user. # a. CHANGE MASTER will result in # ER_CLIENT_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST. # 1. issue change master for default channel "" to set # privilege_checks_user as 'replication_applier_nonexist@'localhost', # this user doesn't exist. # 2. change master fails due to # ER_CLIENT_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST. # b. server start will result in # ER_LOG_WARN_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST. # 1. create relay_info.log with replication_applier_nonexist for # privilege_checks_hostname. # 2. start the slave server. # 3. verify channel "" entry has privilege_checks_user = "". # c. SLAVE START will result in failure due to invalid config. # 1. start slave should fail due to ER_REPLICA_AM_INIT_REPOSITORY. # # TC.E.T1: privilege_checks_username has more than 32 length. # a. CHANGE MASTER will result in ER_CLIENT_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. issue change master for default channel "ch1" to set # privilege_checks_user with privilege_check_username more than 32 char. # 2. change master fails due to ER_WRONG_STRING_LENGTH. # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. set debug point simulate_priv_check_username_above_limit to simulate # failure of reading channel config of ch1 due to # privilege_checks_username having more than 32 chars. # 2. restart the slave server. # 3. verify that channel config entry of "ch1" in pfs table has "" # as PRIVILEGE_CHECKS_USER. # c. SLAVE START will result in failure due to invalid config. # 1. start slave should fail due to ER_REPLICA_AM_INIT_REPOSITORY. # # TC.E.T2: privilege_checks_hostname has more than 255 length. # a. CHANGE MASTER will result in ER_CLIENT_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. issue change master for default channel "ch1" to set # privilege_checks_user with privilege_check_hostname more than 255 # char. # 2. change master fails due to ER_WRONG_STRING_LENGTH. # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. set debug point simulate_priv_check_hostname_above_limit to simulate # failure of reading channel config of ch1 due to # privilege_checks_hostname having more than 255 chars. # 2. restart the slave server. # 3. verify that channel config entry of "ch1" in pfs table has "" # as PRIVILEGE_CHECKS_USER. # c. SLAVE START will result in failure due to invalid config. # 1. start slave should fail due to ER_REPLICA_AM_INIT_REPOSITORY. # # TC.E.T3: privilege_checks_hostname has @. # a. CHANGE MASTER will result in ER_UNKNOWN_ERROR. # 1. issue change master for default channel "ch1" to set # privilege_checks_user with privilege_check_hostname has @. # 2. change master fails due to ER_UNKNOWN_ERROR. # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. update config entry of channel "ch1" in mysql.slave_relay_log_info to # 'l@calhost' in privilege_checks_hostname. # 2. restart the slave server. # 3. verify that channel config entry of "ch1" in pfs table has "" # as PRIVILEGE_CHECKS_USER. # c. SLAVE START will result in failure due to invalid config. # 1. start slave should fail due to ER_REPLICA_AM_INIT_REPOSITORY. # # TC.E.T4. privilege_checks_username is NULL and privilege_checks_hostname is # not NULL. # a. CHANGE MASTER will result in ER_CLIENT_PRIVILEGE_CHECKS_USER_CORRUPT. # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. # c. SLAVE START will result in failure due to invalid config. # 1. start slave should fail due to ER_REPLICA_AM_INIT_REPOSITORY. # # TC.E.T5. privilege_checks_username is anonymous. # a. CHANGE MASTER will result in # ER_CLIENT_PRIVILEGE_CHECKS_USER_CANNOT_BE_ANONYMOUS. # 1. issue change master for default channel "" to set # privilege_checks_user as ''@'localhost'. # 2. change master fails due to # ER_CLIENT_PRIVILEGE_CHECKS_USER_CANNOT_BE_ANONYMOUS. # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. # 1. update config entry of channel "ch1" in mysql.slave_relay_log_info to # '' in privilege_checks_username. # 2. restart the slave server. # 3. verify that channel config entry of "ch1" in pfs table has "" # as PRIVILEGE_CHECKS_USER. # c. SLAVE START will result in failure due to invalid config. # 1. start slave should fail due to ER_REPLICA_AM_INIT_REPOSITORY. # # TC.E.T6. privilege_checks_user is a non existent user. # a. CHANGE MASTER will result in # ER_CLIENT_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST. # 1. issue change master for default channel "" to set # privilege_checks_user as 'replication_applier_nonexist@'localhost', # this user doesn't exist. # 2. change master fails due to # ER_CLIENT_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST. # b. server start will result in # ER_LOG_WARN_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST. # 1. update config entry of channel "ch1" in mysql.slave_relay_log_info to # 'replication_applier_nonexist' in privilege_checks_username. # 2. restart the slave server. # 3. verify that channel config entry of "ch1" in pfs table has "" # as PRIVILEGE_CHECKS_USER. # c. SLAVE START will result in failure due to invalid config. # 1. start slave should fail due to ER_REPLICA_AM_INIT_REPOSITORY. # # ==== References ==== # # Step #7 of WL#12966 # --source include/have_debug.inc --source include/have_debug_sync.inc --source include/not_group_replication_plugin.inc --source include/not_master_info_file.inc --source include/have_binlog_format_row.inc --source include/not_mts_replica_parallel_workers.inc --source include/not_have_privilege_checks_user.inc --source include/master-slave.inc # When relay-log-info-repository=FILE, # mysql.slave_relay_log_info will not have config information for default # channel. performance_schema.replication_applier_configuration should have # entry for default channel "" with correct PRIVILEGE_CHECKS_USER. --write_file $MYSQL_TMP_DIR/assert_default_channel_config_with_file_repo.inc END_OF_PROCEDURE --let $assert_text = Check that mysql.slave_relay_log_info does not have any entry --let $assert_cond = [SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE CHANNEL_NAME=""] = 0 --source include/assert.inc --let $count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE CHANNEL_NAME="" AND PRIVILEGE_CHECKS_USER="'replication_applier'@'localhost'"` --let $assert_text = Check entry for default channel "" in performance_schema.replication_applier_configuration --let $assert_cond = $count = 1 --source include/assert.inc END_OF_PROCEDURE --write_file $MYSQL_TMP_DIR/verify_priv_check_user_config_in_repo_file.inc END_OF_PROCEDURE --let $grep_file = $MYSQLD_DATADIR/$filename --let $grep_pattern = $priv_checks_username --source include/grep_pattern.inc --let $grep_pattern = $priv_checks_hostname --source include/grep_pattern.inc END_OF_PROCEDURE --write_file $MYSQL_TMP_DIR/restart_slave_with_debug_point.inc END_OF_PROCEDURE --let $rpl_server_number = 2 --let $rpl_force_stop=1 --source include/rpl_stop_server.inc --let $rpl_server_parameters=--skip_replica_start --debug=d,$debug_point --let $explicit_default_wait_counter = 15000 --source include/rpl_start_server.inc END_OF_PROCEDURE # validate that channel "" has privilege_checks_user as '' in # performance_schema.replication_applier_configuration # This is used after starting slave with invalid config for channel ''. --write_file $MYSQL_TMP_DIR/assert_default_channel_invalid_config_with_file_repo.inc END_OF_PROCEDURE SELECT * FROM performance_schema.replication_applier_configuration; --let $count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE CHANNEL_NAME="" AND PRIVILEGE_CHECKS_USER=""` --let $assert_text = Check entry for default channel "" in performance_schema.replication_applier_configuration --let $assert_cond = $count = 1 --source include/assert.inc END_OF_PROCEDURE # Number of channel config entries in mysql.slave_relay_log_info and # performance_schema.replication_applier_configuration. Before each usage, # $channel will be set. # Both the tables should have $channel number of entires. --write_file $MYSQL_TMP_DIR/assert_config_entry_count_with_table_repo.inc END_OF_PROCEDURE --let $assert_text = Check that mysql.slave_relay_log_info has $num_channels entries for $num_channels channels --let $assert_cond = [SELECT COUNT(*) FROM mysql.slave_relay_log_info] = $num_channels --source include/assert.inc --let $assert_text = Check that performance_schema.replication_applier_configuration has $num_channels entries for $num_channels channels --let $assert_cond = [SELECT COUNT(*) FROM performance_schema.replication_applier_configuration] = $num_channels --source include/assert.inc END_OF_PROCEDURE # Verify (PRIVILEGE_CHECKS_USERNAME, PRIVILEGE_CHECKS_HOSTNAME) and # PRIVILEGE_CHECKS_USER information respectively in mysql.slave_relay_log_info # and performance_schema.replication_applier_configuration tables. Following # params are set before every usage: # priv_chks_user_expected_value: expected value of PRIVILEGE_CHECKS_USER. # priv_chks_username: expected value of PRIVILEGE_CHECKS_USERNAME. # priv_chks_hostname: expected value of PRIVILEGE_CHECKS_HOSTNAME. --write_file $MYSQL_TMP_DIR/assert_channel_config_with_table_repo.inc END_OF_PROCEDURE if ($priv_chks_user_expected_value == NULL) { --let $count1 = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE CHANNEL_NAME=$channel AND PRIVILEGE_CHECKS_USER IS NULL` } if ($priv_chks_user_expected_value != NULL) { --let $count1 = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE CHANNEL_NAME=$channel AND PRIVILEGE_CHECKS_USER="$priv_chks_user_expected_value"` } --let $priv_chks_username = query_get_value(SELECT Privilege_checks_username FROM mysql.slave_relay_log_info WHERE Channel_name=$channel, Privilege_checks_username, 1) --let $priv_chks_hostname = query_get_value(SELECT Privilege_checks_hostname FROM mysql.slave_relay_log_info WHERE Channel_name=$channel, Privilege_checks_hostname, 1) --let $assert_text = Check that priv_chks_username for channel $channel is correct --let $assert_cond = "$priv_chks_username" = "$priv_chks_username_expected_value" --source include/assert.inc --let $assert_text = Check that priv_chks_hostname for channel $channel is correct --let $assert_cond = "$priv_chks_hostname" = "$priv_chks_hostname_expected_value" --source include/assert.inc END_OF_PROCEDURE # Used the channel config in pfs after slave restart. # if debug_point is set then # - update given channel's given config in mysql.slave_relay_log_info. # force stop the slave server. # verify that pfs table "" entry for the given channel. --write_file $MYSQL_TMP_DIR/assert_channel_invalid_config_update_of_table_repo_entry.inc END_OF_PROCEDURE BEGIN; --eval UPDATE mysql.slave_relay_log_info SET Privilege_checks_username=$priv_chks_username, Privilege_checks_hostname=$priv_chks_hostname WHERE Channel_name=$channel COMMIT; --let $rpl_server_number = 2 --let $rpl_force_stop=1 if ($debug_point != '') { --let $rpl_server_parameters = --relay-log-info-repository=TABLE --skip_replica_start --debug=d,$debug_point,simulate_priv_check_user_nullptr_t } if ($debug_point == '') { --let $rpl_server_parameters = --relay-log-info-repository=TABLE --skip_replica_start } --let $explicit_default_wait_counter = 15000 --source include/rpl_restart_server.inc --let $count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE CHANNEL_NAME=$channel AND PRIVILEGE_CHECKS_USER=""` --let $assert_text = Check entry for channel $channel in performance_schema.replication_applier_configuration --let $assert_cond = $count = 1 --source include/assert.inc END_OF_PROCEDURE --source include/rpl_connection_slave.inc # Prerequisites: # 1. add mtr suppression statement for errors on various error test cases for # FILE and TABLE type repository. CALL mtr.add_suppression("Error reading relay log configuration"); CALL mtr.add_suppression("Failed to create or recover replication info repositories"); # Adding suppression of errors/warning for FILE repo test cases. CALL mtr.add_suppression("Replica SQL for channel '': Invalid, corrupted PRIVILEGE_CHECKS_USER was found in the replication configuration repository"); CALL mtr.add_suppression("PRIVILEGE_CHECKS_USER for replication channel '' was set to `replication_applier_nonexist`@`localhost`, but this is not an existing user"); CALL mtr.add_suppression("Replica: Failed to initialize the connection metadata structure for channel '';"); CALL mtr.add_suppression("Replica SQL for channel '': Replica failed to initialize applier metadata structure from the repository"); # Adding suppression of errors/warning for TABLE repo test cases. CALL mtr.add_suppression("Replica SQL for channel 'ch1': Invalid, corrupted PRIVILEGE_CHECKS_USER was found in the replication configuration repository"); CALL mtr.add_suppression("PRIVILEGE_CHECKS_USER for replication channel 'ch1' was set to `replication_applier_nonexist`@`localhost`, but this is not an existing user"); CALL mtr.add_suppression("Replica: Failed to initialize the connection metadata structure for channel 'ch1';"); CALL mtr.add_suppression("Replica SQL for channel 'ch1': Replica failed to initialize applier metadata structure from the repository"); --let $MYSQLD_DATADIR= `select @@datadir` --let $filename = `SELECT @@relay_log_info_file` # 2. create user replication_applier to use in change master as # privilege_checks_user with REPLICATION_APPLIER privilege. CREATE USER 'replication_applier'@'localhost' IDENTIFIED BY 'password'; GRANT REPLICATION_APPLIER ON * . * TO 'replication_applier'@'localhost'; FLUSH PRIVILEGES; --echo # --echo # TC.P.F1: CHANGE MASTER sets the PRIVILEGE_CHECKS_USER correctly. --echo # # 1. issue change master for default channel "" to set privilege_checks_user. STOP SLAVE; # NULL value is accepted CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=10, PRIVILEGE_CHECKS_USER=NULL; # and NON-NULL value is accepted CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=10, PRIVILEGE_CHECKS_USER='replication_applier'@'localhost'; FLUSH RELAY LOGS; START SLAVE; # 2. verify that pfs table has correct PRIVILEGE_CHECKS_USER --source $MYSQL_TMP_DIR/assert_default_channel_config_with_file_repo.inc # 3. also verify privlege_checks_user info in repo file relay_info.log. --let $priv_checks_username = replication_applier --let $priv_checks_hostname = localhost --source $MYSQL_TMP_DIR/verify_priv_check_user_config_in_repo_file.inc --echo # --echo # TC.P.F2: PRIVILEGE_CHECKS_USER persists after restarting the server. --echo # # 1. restart the slave server. --let $rpl_server_number = 2 --let $explicit_default_wait_counter = 15000 --source include/rpl_restart_server.inc # 2. verify that pfs table has correct PRIVILEGE_CHECKS_USER --source $MYSQL_TMP_DIR/assert_default_channel_config_with_file_repo.inc --let $priv_checks_username = replication_applier --let $priv_checks_hostname = localhost # 3. also verify privlege_checks_user info in repo file relay_info.log. --source $MYSQL_TMP_DIR/verify_priv_check_user_config_in_repo_file.inc STOP SLAVE FOR CHANNEL ""; --echo # --echo # TC.E.F1: privilege_checks_username has more than 32 length. --echo # # a. CHANGE MASTER will result in ER_CLIENT_PRIVILEGE_CHECKS_USER_CORRUPT. --error ER_WRONG_STRING_LENGTH CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=10, PRIVILEGE_CHECKS_USER='repli_priv_checks_user_more_than_32'@'localhost' FOR CHANNEL ""; # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. --let $debug_point = simulate_priv_check_username_above_limit --let $slave_server_num = 2 --source $MYSQL_TMP_DIR/restart_slave_with_debug_point.inc --source $MYSQL_TMP_DIR/assert_default_channel_invalid_config_with_file_repo.inc --source include/remove_debug_point.inc # c. SLAVE START will result in failure due to invalid config. --error ER_REPLICA_AM_INIT_REPOSITORY START SLAVE FOR CHANNEL ""; # Restore the correct channel config after error test case. RESET SLAVE FOR CHANNEL ""; CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=10, PRIVILEGE_CHECKS_USER='replication_applier'@'localhost'; --echo # --echo # TC.E.F2: privilege_checks_hostname has more than 255 length. --echo # # a. CHANGE MASTER will result in ER_CLIENT_PRIVILEGE_CHECKS_USER_CORRUPT. --error ER_WRONG_STRING_LENGTH CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=12, PRIVILEGE_CHECKS_USER='replication_applier'@'replication_privilege_checks_hostname_more_than_255_replication_privilege_checks_hostname_more_than_255_replication_privilege_checks_hostname_more_than_255_replication_privilege_checks_hostname_more_than_255_replication_privilege_checks_hostname_more_than255' FOR CHANNEL "" ; # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. --let $debug_point = simulate_priv_check_hostname_above_limit --source $MYSQL_TMP_DIR/restart_slave_with_debug_point.inc --source $MYSQL_TMP_DIR/assert_default_channel_invalid_config_with_file_repo.inc --source include/remove_debug_point.inc # c. SLAVE START will result in failure due to invalid config. --error ER_REPLICA_AM_INIT_REPOSITORY START SLAVE FOR CHANNEL ""; --let $debug_point = # Restore the correct channel config after error test case. RESET SLAVE FOR CHANNEL ""; CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=10, PRIVILEGE_CHECKS_USER='replication_applier'@'localhost'; --echo # --echo # TC.E.F3: privilege_checks_hostname has @. --echo # # a. CHANGE MASTER will result in ER_UNKNOWN_ERROR. --error ER_UNKNOWN_ERROR CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=12, PRIVILEGE_CHECKS_USER='replication_applier'@'l@calhost' FOR CHANNEL "" ; # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. --let $sub_testcase = host_name_has_@ --let $slave_server_num = 2 --let $rpl_server_restart_parameters = --skip_replica_start --source extra/rpl_tests/restart_slave_with_custom_relaylog_repo_file.inc --let $priv_checks_username = replication_applier --let $priv_checks_hostname = l@calhost --source $MYSQL_TMP_DIR/verify_priv_check_user_config_in_repo_file.inc --source $MYSQL_TMP_DIR/assert_default_channel_invalid_config_with_file_repo.inc # c. SLAVE START will result in failure due to invalid config. --error ER_REPLICA_AM_INIT_REPOSITORY START SLAVE FOR CHANNEL ""; # Restore the correct channel config after error test case. RESET SLAVE FOR CHANNEL ""; CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=10, PRIVILEGE_CHECKS_USER='replication_applier'@'localhost'; --echo # --echo # TC.E.F5. privilege_checks_username is anonymous. --echo # # a. CHANGE MASTER will result in ER_CLIENT_PRIVILEGE_CHECKS_USER_CANNOT_BE_ANONYMOUS. --error ER_CLIENT_PRIVILEGE_CHECKS_USER_CANNOT_BE_ANONYMOUS CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=12, PRIVILEGE_CHECKS_USER=''@'localhost' FOR CHANNEL "" ; # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. --let $sub_testcase = anonymous_user --let $slave_server_num = 2 --let $rpl_server_restart_parameters = --skip_replica_start --source extra/rpl_tests/restart_slave_with_custom_relaylog_repo_file.inc --source $MYSQL_TMP_DIR/assert_default_channel_invalid_config_with_file_repo.inc # c. SLAVE START will result in failure due to invalid config. --error ER_REPLICA_AM_INIT_REPOSITORY START SLAVE FOR CHANNEL ""; # Restore the correct channel config after error test case. RESET SLAVE FOR CHANNEL ""; CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=10, PRIVILEGE_CHECKS_USER='replication_applier'@'localhost'; --echo # --echo # TC.E.F6. privilege_checks_user is a non existent user. --echo # # a. CHANGE MASTER will result in # ER_CLIENT_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST. --error ER_CLIENT_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=12, PRIVILEGE_CHECKS_USER='replication_applier_nonexist'@'localhost' FOR CHANNEL "" ; # b. server start will result in # ER_LOG_WARN_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST. --let $sub_testcase = nonexist_user --let $slave_server_num = 2 --let $rpl_server_restart_parameters = --skip_replica_start --source extra/rpl_tests/restart_slave_with_custom_relaylog_repo_file.inc --let $priv_checks_username = replication_applier_nonexist --let $priv_checks_hostname = localhost --source $MYSQL_TMP_DIR/verify_priv_check_user_config_in_repo_file.inc --source $MYSQL_TMP_DIR/assert_default_channel_invalid_config_with_file_repo.inc # c. SLAVE START will result in failure due to invalid config. --error ER_REPLICA_AM_INIT_REPOSITORY START SLAVE FOR CHANNEL ""; # Restore the correct channel config after error test case. RESET SLAVE FOR CHANNEL ""; CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=10, PRIVILEGE_CHECKS_USER='replication_applier'@'localhost'; --let $assert_text = Found 4 warning in the error log --let $assert_file = $MYSQLTEST_VARDIR/tmp/rpl_log_info_repository_persistence.2.err --let $assert_select = \[Warning\] \[[^]]*\] \[Repl\] Replica SQL for channel '': Invalid, corrupted PRIVILEGE_CHECKS_USER was found.* --let $assert_count = 4 --source include/assert_grep.inc --let $assert_text = Found 1 warning in the error log --let $assert_file = $MYSQLTEST_VARDIR/tmp/rpl_log_info_repository_persistence.2.err --let $assert_select = \[Warning\] \[[^]]*\] \[Repl\] Replica SQL for channel '': PRIVILEGE_CHECKS_USER for replication channel '' was set to `replication_applier_nonexist`@`localhost`, but this is not an existing user --let $assert_count = 1 --source include/assert_grep.inc # Restart the slave with relay-log-info-repository=TABLE # The debug point tests the execution flow where isn't nullptr # that is being passed to set_info but a variable with nullptr value. --echo # --echo # Restart slave with TABLE repository to test with privilege_checks_user config. --echo # --let $rpl_server_number = 2 --let $rpl_server_parameters = --relay-log-info-repository=TABLE --debug=d,simulate_priv_check_user_nullptr_t --let $explicit_default_wait_counter = 15000 --source include/rpl_restart_server.inc # verify (privilege_checks_username, privilege_checks_hostname), and # privilege_checks_user for default channel in mysql.slave_relay_log_info, # and performance_schema.replication_applier_configuration. There will be # one entry for default channel. --let $num_channels = 1 --source $MYSQL_TMP_DIR/assert_config_entry_count_with_table_repo.inc --let $channel = "" --let $priv_chks_user_expected_value = 'replication_applier'@'localhost' --let $priv_chks_username_expected_value = replication_applier --let $priv_chks_hostname_expected_value = localhost --source $MYSQL_TMP_DIR/assert_channel_config_with_table_repo.inc --echo # --echo # TC.P.T1: CHANGE MASTER sets the PRIVILEGE_CHECKS_USER correctly. --echo # # 1. create two channels ch1 and ch2 when slave is configured with TABLE type # repo. "ch1" has not PRIVILEGE_CHECKS_USER, "ch2" has # 'replication_applier'@'localhost' as PRIVILEGE_CHECK_USER. CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=11, PRIVILEGE_CHECKS_USER=NULL FOR CHANNEL "ch1"; CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=12, PRIVILEGE_CHECKS_USER='replication_applier'@'localhost' FOR CHANNEL "ch2" ; FLUSH RELAY LOGS FOR CHANNEL "ch1"; FLUSH RELAY LOGS FOR CHANNEL "ch2"; # 2. verify that there are three channel entries in both pfs and # slave_relay_log_info tables. --let $num_channels = 3 --source $MYSQL_TMP_DIR/assert_config_entry_count_with_table_repo.inc # 3. verify that "ch1" and "ch2" have expected values in # pfs and slave_relay_log_info tables. --let $channel = "ch1" --let $priv_chks_user_expected_value = NULL --let $priv_chks_username_expected_value = NULL --let $priv_chks_hostname_expected_value = NULL --source $MYSQL_TMP_DIR/assert_channel_config_with_table_repo.inc --let $channel = "ch2" --let $priv_chks_user_expected_value = 'replication_applier'@'localhost' --let $priv_chks_username_expected_value = replication_applier --let $priv_chks_hostname_expected_value = localhost --source $MYSQL_TMP_DIR/assert_channel_config_with_table_repo.inc --echo # --echo # TC.P.T2: PRIVILEGE_CHECKS_USER persists after restarting the server. --echo # # 1. restart the slave server. --let $rpl_server_number = 2 --let $rpl_server_parameters = --relay-log-info-repository=TABLE --let $explicit_default_wait_counter = 15000 --source include/rpl_restart_server.inc # 2. verify that there are three channel entries in both pfs and # slave_relay_log_info tables. --let $num_channels = 3 --source $MYSQL_TMP_DIR/assert_config_entry_count_with_table_repo.inc # 3. verify that "ch1" and "ch2" retained the values in # pfs and slave_relay_log_info tables after restart. --let $channel = "ch1" --let $priv_chks_user_expected_value = NULL --let $priv_chks_username_expected_value = NULL --let $priv_chks_hostname_expected_value = NULL --source $MYSQL_TMP_DIR/assert_channel_config_with_table_repo.inc --let $channel = "ch2" --let $priv_chks_user_expected_value = 'replication_applier'@'localhost' --let $priv_chks_username_expected_value = replication_applier --let $priv_chks_hostname_expected_value = localhost --source $MYSQL_TMP_DIR/assert_channel_config_with_table_repo.inc --echo # --echo # TC.P.T3: RESET SLAVE should keep value of PRIVILEGE_CHECKS_USER. --echo # # 1. reset slave for channel "". RESET SLAVE FOR CHANNEL ""; # 2. verify that slave_relay_log_info table and pfs have 3 records. --let $assert_text = Check that mysql.slave_relay_log_info has 2 entries for 2 channels --let $assert_cond = [SELECT COUNT(*) FROM mysql.slave_relay_log_info] = 3 --source include/assert.inc --let $assert_text = Check that performance_schema.replication_applier_configuration has 3 entries for 3 channels --let $assert_cond = [SELECT COUNT(*) FROM performance_schema.replication_applier_configuration] = 3 --source include/assert.inc # 3. verify that default channel has entry in pfs table. # Also verify that "ch1" and "ch2" kept values in # pfs and slave_relay_log_info tables after reset slave for default channel. --let $priv_chks_user = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE CHANNEL_NAME="" AND PRIVILEGE_CHECKS_USER="'replication_applier'@'localhost'"` --let $assert_text = Check that priv_chks_user for channel "" is correct --let $assert_cond = $priv_chks_user = 1 --source include/assert.inc --let $channel = "ch1" --let $priv_chks_user_expected_value = NULL --let $priv_chks_username_expected_value = NULL --let $priv_chks_hostname_expected_value = NULL --source $MYSQL_TMP_DIR/assert_channel_config_with_table_repo.inc --let $channel = "ch2" --let $priv_chks_user_expected_value = 'replication_applier'@'localhost' --let $priv_chks_username_expected_value = replication_applier --let $priv_chks_hostname_expected_value = localhost --source $MYSQL_TMP_DIR/assert_channel_config_with_table_repo.inc # removing all the other channel except "ch1", otherwise all the other channel # config processing will be erred due to debug points. RESET SLAVE ALL FOR CHANNEL ""; RESET SLAVE ALL FOR CHANNEL "ch2"; STOP SLAVE FOR CHANNEL "ch1"; --let $channel = "ch1" --echo # --echo # TC.E.T1: privilege_checks_username has more than 32 length. --echo # # a. CHANGE MASTER will result in ER_CLIENT_PRIVILEGE_CHECKS_USER_CORRUPT. --error ER_WRONG_STRING_LENGTH CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=10, PRIVILEGE_CHECKS_USER='repli_priv_checks_user_more_than_32'@'localhost' FOR CHANNEL "ch1"; # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. --let $debug_point = simulate_priv_check_username_above_limit --let $priv_chks_username = "repl_priv_chcks_usr_more_than_32" --let $priv_chks_hostname = "localhost" --source $MYSQL_TMP_DIR/assert_channel_invalid_config_update_of_table_repo_entry.inc --source include/remove_debug_point.inc # c. SLAVE START will result in failure due to invalid config. --error ER_REPLICA_AM_INIT_REPOSITORY START SLAVE FOR CHANNEL "ch1"; # Restore the correct channel config after error test case. RESET SLAVE FOR CHANNEL "ch1"; CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=11 FOR CHANNEL "ch1"; --echo # --echo # TC.E.T2: privilege_checks_hostname has more than 255 length. --echo # # a. CHANGE MASTER will result in ER_CLIENT_PRIVILEGE_CHECKS_USER_CORRUPT. --error ER_WRONG_STRING_LENGTH CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=12, PRIVILEGE_CHECKS_USER='replication_applier'@'replication_privilege_checks_hostname_more_than_255_replication_privilege_checks_hostname_more_than_255_replication_privilege_checks_hostname_more_than_255_replication_privilege_checks_hostname_more_than_255_replication_privilege_checks_hostname_more_than255' FOR CHANNEL "ch1" ; # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. --let $debug_point = simulate_priv_check_hostname_above_limit --let $priv_chks_username = "replication_applier" --let $priv_chks_hostname = "replication_applier_hostname_more_than_255" --source $MYSQL_TMP_DIR/assert_channel_invalid_config_update_of_table_repo_entry.inc --source include/remove_debug_point.inc # c. SLAVE START will result in failure due to invalid config. --error ER_REPLICA_AM_INIT_REPOSITORY START SLAVE FOR CHANNEL "ch1"; --let $debug_point = # Restore the correct channel config after error test case. RESET SLAVE FOR CHANNEL "ch1"; CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=11 FOR CHANNEL "ch1"; --echo # --echo # TC.E.T3: privilege_checks_hostname has @. --echo # # a. CHANGE MASTER will result in ER_UNKNOWN_ERROR. --error ER_UNKNOWN_ERROR CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=12, PRIVILEGE_CHECKS_USER='replication_applier'@'l@calhost' FOR CHANNEL "ch1" ; # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. --let $priv_chks_username = 'replication_applier' --let $priv_chks_hostname = 'l@calhost' --source $MYSQL_TMP_DIR/assert_channel_invalid_config_update_of_table_repo_entry.inc # c. SLAVE START will result in failure due to invalid config. --error ER_REPLICA_AM_INIT_REPOSITORY START SLAVE FOR CHANNEL "ch1"; # Restore the correct channel config after error test case. RESET SLAVE FOR CHANNEL "ch1"; CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=11 FOR CHANNEL "ch1"; --echo # --echo # TC.E.T4. privilege_checks_username is NULL and # privilege_checks_hostname is not NULL. --echo # # a. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. --let $priv_chks_username = NULL --let $priv_chks_hostname = "localhost" --source $MYSQL_TMP_DIR/assert_channel_invalid_config_update_of_table_repo_entry.inc # b. SLAVE START will result in failure due to invalid config. --error ER_REPLICA_AM_INIT_REPOSITORY START SLAVE FOR CHANNEL "ch1"; # Restore the correct channel config after error test case. RESET SLAVE FOR CHANNEL "ch1"; CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=11 FOR CHANNEL "ch1"; --echo # --echo # TC.E.T5. privilege_checks_username is anonymous. --echo # # a. CHANGE MASTER will result in # ER_CLIENT_PRIVILEGE_CHECKS_USER_CANNOT_BE_ANONYMOUS. --error ER_CLIENT_PRIVILEGE_CHECKS_USER_CANNOT_BE_ANONYMOUS CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=12, PRIVILEGE_CHECKS_USER=''@'localhost' FOR CHANNEL "ch1" ; # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_CORRUPT. --let $priv_chks_username = "" --let $priv_chks_hostname = "localhost" --source $MYSQL_TMP_DIR/assert_channel_invalid_config_update_of_table_repo_entry.inc # c. SLAVE START will result in failure due to invalid config. --error ER_REPLICA_AM_INIT_REPOSITORY START SLAVE FOR CHANNEL "ch1"; # Restore the correct channel config after error test case. RESET SLAVE FOR CHANNEL "ch1"; CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=11 FOR CHANNEL "ch1"; --echo # --echo # TC.E.T6. privilege_checks_user is a non existent user. --echo # # a. CHANGE MASTER will result in ER_CLIENT_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST. --error ER_CLIENT_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST CHANGE REPLICATION SOURCE TO SOURCE_HOST="localhost", SOURCE_PORT=12, PRIVILEGE_CHECKS_USER='replication_applier_nonexist'@'localhost' FOR CHANNEL "ch1" ; # b. server start will result in ER_LOG_WARN_PRIVILEGE_CHECKS_USER_DOES_NOT_EXIST. --let $priv_chks_username = "replication_applier_nonexist" --let $priv_chks_hostname = "localhost" --source $MYSQL_TMP_DIR/assert_channel_invalid_config_update_of_table_repo_entry.inc # c. SLAVE START will result in failure due to invalid config. --error ER_REPLICA_AM_INIT_REPOSITORY START SLAVE FOR CHANNEL "ch1"; # Restore the correct channel config after error test case. RESET SLAVE FOR CHANNEL "ch1"; CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1", SOURCE_PORT=11 FOR CHANNEL "ch1"; --let $assert_text = Found 5 warning in the error log --let $assert_file = $MYSQLTEST_VARDIR/tmp/rpl_log_info_repository_persistence.2.err --let $assert_select = \[Warning\] \[[^]]*\] \[Repl\] Replica SQL for channel 'ch1': Invalid, corrupted PRIVILEGE_CHECKS_USER was found.* --let $assert_count = 5 --source include/assert_grep.inc --let $assert_text = Found 1 warning in the error log --let $assert_file = $MYSQLTEST_VARDIR/tmp/rpl_log_info_repository_persistence.2.err --let $assert_select = \[Warning\] \[[^]]*\] \[Repl\] Replica SQL for channel 'ch1': PRIVILEGE_CHECKS_USER for replication channel 'ch1' was set to `replication_applier_nonexist`@`localhost`, but this is not an existing user --let $assert_count = 1 --source include/assert_grep.inc DROP USER 'replication_applier'@'localhost'; --remove_file $MYSQL_TMP_DIR/assert_default_channel_config_with_file_repo.inc --remove_file $MYSQL_TMP_DIR/restart_slave_with_debug_point.inc --remove_file $MYSQL_TMP_DIR/verify_priv_check_user_config_in_repo_file.inc --remove_file $MYSQL_TMP_DIR/assert_default_channel_invalid_config_with_file_repo.inc --remove_file $MYSQL_TMP_DIR/assert_config_entry_count_with_table_repo.inc --remove_file $MYSQL_TMP_DIR/assert_channel_config_with_table_repo.inc --remove_file $MYSQL_TMP_DIR/assert_channel_invalid_config_update_of_table_repo_entry.inc --source include/stop_slave.inc RESET REPLICA ALL; --connection slave SET @@global.relay_log_info_repository=FILE; --replace_result $MASTER_MYPORT MASTER_MYPORT --eval CHANGE REPLICATION SOURCE TO SOURCE_USER='root', SOURCE_HOST="127.0.0.1", SOURCE_PORT=$MASTER_MYPORT; --source include/start_slave.inc --let $rpl_channel_name= --let $rpl_skip_sync= 1 source include/rpl_end.inc;