| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test script serves as the functionality testing for |
| 4 |
# WL#6120- Change master without stopping slave. |
| 5 |
# |
| 6 |
# This test script does the following: |
| 7 |
|
| 8 |
# - If at least one of the receiver or applier threads is running, relay logs |
| 9 |
# should not be purged. |
| 10 |
# - If relay_log_file/relay_log_pos options are used, relay logs should |
| 11 |
# not be purged. |
| 12 |
# - If both receiver and applier threads are stopped and there is no use of |
| 13 |
# relay_log_file/relay_log_pos options, relay logs should be |
| 14 |
# purged. |
| 15 |
# |
| 16 |
# ==== Related Worklog(s) And Bug(s)==== |
| 17 |
# |
| 18 |
# WL#6120- Change master without stopping Slave threads. |
| 19 |
# |
| 20 |
|
| 21 |
--source include/master-slave.inc |
| 22 |
--source include/have_binlog_format_mixed.inc |
| 23 |
|
| 24 |
FLUSH BINARY LOGS; |
| 25 |
|
| 26 |
--source include/sync_slave_sql_with_master.inc |
| 27 |
|
| 28 |
#save old values to restore after test in the cleanup section. |
| 29 |
let $slave_heartbeat_timeout_before_test= query_get_value(select HEARTBEAT_INTERVAL from performance_schema.replication_connection_configuration, HEARTBEAT_INTERVAL, 1); |
| 30 |
let $delay_before_test= query_get_value(SHOW SLAVE STATUS, SQL_Delay, 1); |
| 31 |
|
| 32 |
--echo |
| 33 |
--echo We now stop the IO thread and ensure that the relaylog files |
| 34 |
--echo are not deleted on doing a change master with a running SQL thread. |
| 35 |
--echo |
| 36 |
|
| 37 |
# Note down the current relaylog file. |
| 38 |
# CM stands for 'change master'. |
| 39 |
let $relay_log_file_before_CM= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1); |
| 40 |
|
| 41 |
# Execute change master command with running SQL thread. |
| 42 |
--source include/stop_slave_io.inc |
| 43 |
CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD= 10; |
| 44 |
|
| 45 |
# Note down the active relaylog after change master |
| 46 |
let $relay_log_file_after_CM= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1); |
| 47 |
|
| 48 |
--let $assert_text= The relaylog file should not change if change master command was executed while SQL thread was running. |
| 49 |
--let $assert_cond= "$relay_log_file_before_CM" = "$relay_log_file_after_CM" |
| 50 |
--source include/assert.inc |
| 51 |
|
| 52 |
--echo |
| 53 |
--echo We now stop the SQL thread and ensure that the relaylog files |
| 54 |
--echo are not deleted on doing a change master with a running IO thread. |
| 55 |
--echo |
| 56 |
|
| 57 |
--source include/stop_slave_sql.inc |
| 58 |
--source include/start_slave_io.inc |
| 59 |
CHANGE REPLICATION SOURCE TO SOURCE_DELAY= 20; |
| 60 |
|
| 61 |
# Note down the active relaylog after change master |
| 62 |
let $relay_log_file_after_CM= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1); |
| 63 |
|
| 64 |
--let $assert_text= The relaylog file should not change if change master command was executed while IO thread was running. |
| 65 |
--let $assert_cond= "$relay_log_file_before_CM" = "$relay_log_file_after_CM" |
| 66 |
--source include/assert.inc |
| 67 |
|
| 68 |
--echo |
| 69 |
--echo If the relay_log_file and relay_log_pos options are used, we dont purge |
| 70 |
--echo relaylogs. |
| 71 |
--echo |
| 72 |
|
| 73 |
# Lets stop IO thread again to make sure we are not purging relay logs only |
| 74 |
# because we have a use of relay_log_file/relay_log_pos options and not |
| 75 |
# because one of the slave threads is running. |
| 76 |
|
| 77 |
--source include/stop_slave_io.inc |
| 78 |
|
| 79 |
let $relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1); |
| 80 |
replace_result $relay_log_file RELAY_LOG_FILE; |
| 81 |
eval CHANGE REPLICATION SOURCE TO RELAY_LOG_FILE= '$relay_log_file'; |
| 82 |
|
| 83 |
let $relay_log_pos= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1); |
| 84 |
replace_result $relay_log_pos RELAY_LOG_POS; |
| 85 |
eval CHANGE REPLICATION SOURCE TO RELAY_LOG_POS= $relay_log_pos; |
| 86 |
|
| 87 |
let $relay_log_file_after_CM= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1); |
| 88 |
|
| 89 |
--let $assert_text= The relaylog file should not change if change master command contained relay_log_file or relay_log_pos option. |
| 90 |
--let $assert_cond= "$relay_log_file_before_CM" = "$relay_log_file_after_CM" |
| 91 |
--source include/assert.inc |
| 92 |
|
| 93 |
--echo |
| 94 |
--echo With both the threads stopped and no use of relay_log_file or |
| 95 |
--echo relay_log_pos options, the relaylogs should be deleted. |
| 96 |
--echo |
| 97 |
|
| 98 |
CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD= 20; |
| 99 |
|
| 100 |
let $relay_log_file_after_CM= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1); |
| 101 |
|
| 102 |
--let $assert_text= With both the threads stopped and no use of relay_log_file or relay_log_pos options in change master command, the relaylogs should be deleted. |
| 103 |
--let $assert_cond= "$relay_log_file_before_CM" != "$relay_log_file_after_CM" |
| 104 |
--source include/assert.inc |
| 105 |
|
| 106 |
--echo |
| 107 |
--echo cleanup |
| 108 |
--echo |
| 109 |
|
| 110 |
# Restore to default values now using the values saved before the tests. |
| 111 |
# No need to record the default values in the result file. |
| 112 |
--disable_query_log |
| 113 |
eval CHANGE REPLICATION SOURCE TO SOURCE_DELAY= $delay_before_test; |
| 114 |
eval CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD= $slave_heartbeat_timeout_before_test; |
| 115 |
--enable_query_log |
| 116 |
|
| 117 |
--source include/start_slave.inc |
| 118 |
--source include/rpl_end.inc |