| 1 |
############################################################################### |
| 2 |
# Bug#19021091: RELAY_LOG_RECOVERY KO WHEN CHANGE MASTER WITHOUT FILE AND |
| 3 |
# SQL_THREAD NOT STARTED |
| 4 |
# |
| 5 |
# Problem: |
| 6 |
# ======== |
| 7 |
# If, on an empty database: |
| 8 |
# - CHANGE MASTER TO without a MASTER_FILE and MASTER_POS is used, |
| 9 |
# - the IO_THREAD is started WITHOUT starting the SQL_THREAD, |
| 10 |
# - MySQL crashed, |
| 11 |
# - MySQL is restarted with relay_log_recovery = 1. |
| 12 |
# |
| 13 |
# Crash recovery will not work as expected: |
| 14 |
# - The IO_THREAD position will NOT be initialized to the SQL_THREAD position, |
| 15 |
# - SQL_THREAD position will NOT be initialized to the new relay log. |
| 16 |
# |
| 17 |
# It looks like, when the SQL_THREAD does not have a Relay_Master_Log_File, |
| 18 |
# relay_log_recovery does not work. |
| 19 |
# |
| 20 |
# Test: |
| 21 |
# ===== |
| 22 |
# If SQL_THREAD does not have a Relay_Master_Log_File set recovery process |
| 23 |
# will try to extract the first rotate event from the master and try to |
| 24 |
# extract master_log_file and master_log_pos from the rotate event. But when |
| 25 |
# replicate-same-server-id is set master and slave will have same server_id |
| 26 |
# and it will not be possible to identify the rotate event from master. Hence |
| 27 |
# if recovery is happening with empty Relay_Master_Log_File and |
| 28 |
# replicate-same-server-id is set we generate an error saying recovery is not |
| 29 |
# possible. |
| 30 |
# |
| 31 |
# Enable replicate-same-server-id. Set slave's info repository to be tables |
| 32 |
# and set relay-log-recovery=1. Start slave io_thread to ensure that |
| 33 |
# Relay_Master_Log_File is not initialized. Stop and restart the slave server. |
| 34 |
# Relay log recovery will not happen slave will generate an error in error log |
| 35 |
# as shown below. |
| 36 |
# |
| 37 |
# Error during --relay-log-recovery, replicate_same_server_id is in use and |
| 38 |
# sql thread's positions are not initialized, hence relay log recovery cannot |
| 39 |
# happen. |
| 40 |
############################################################################### |
| 41 |
--source include/force_restart.inc |
| 42 |
--source include/not_group_replication_plugin.inc |
| 43 |
# Test requires master-info-repository=TABLE, relay-log-info-repository=TABLE |
| 44 |
--source include/have_slave_repository_type_table.inc |
| 45 |
--source include/not_rpl_gtid_only.inc |
| 46 |
--source include/master-slave.inc |
| 47 |
|
| 48 |
--source include/rpl_connection_slave.inc |
| 49 |
call mtr.add_suppression("Failed to initialize the connection metadata structure"); |
| 50 |
call mtr.add_suppression("Error during --relay-log-recovery *"); |
| 51 |
CREATE TABLE t1 ( n INT); |
| 52 |
RESET MASTER; |
| 53 |
|
| 54 |
# replicate ourselves |
| 55 |
--source include/stop_slave.inc |
| 56 |
--source include/wait_for_slave_to_stop.inc |
| 57 |
--replace_result $SLAVE_MYPORT SLAVE_PORT |
| 58 |
eval CHANGE REPLICATION SOURCE TO SOURCE_PORT=$SLAVE_MYPORT; |
| 59 |
START SLAVE IO_THREAD; |
| 60 |
--source include/wait_for_slave_io_to_start.inc |
| 61 |
|
| 62 |
# Restart the slave server |
| 63 |
--let $rpl_server_number= 2 |
| 64 |
--source include/rpl_stop_server.inc |
| 65 |
|
| 66 |
--let $rpl_server_number= 2 |
| 67 |
--let $rpl_server_parameters=--skip_replica_start=FALSE --relay-log-recovery=1 |
| 68 |
--source include/rpl_start_server.inc |
| 69 |
|
| 70 |
--let $assert_text= One error should match 'Error during --relay-log-recovery' |
| 71 |
--let $assert_file= $MYSQLTEST_VARDIR/tmp/slave.err |
| 72 |
--let $assert_select= Error during --relay-log-recovery |
| 73 |
--let $assert_count= 1 |
| 74 |
--source include/assert_grep.inc |
| 75 |
|
| 76 |
# Clean up Server needs to be restarted with relay-log-recovery=0 |
| 77 |
--let $rpl_server_number= 2 |
| 78 |
--let $rpl_server_parameters=--relay-log-recovery=0 |
| 79 |
--source include/rpl_restart_server.inc |
| 80 |
|
| 81 |
DROP TABLE t1; |
| 82 |
--replace_result $MASTER_MYPORT MASTER_PORT |
| 83 |
eval CHANGE REPLICATION SOURCE to SOURCE_PORT=$MASTER_MYPORT; |
| 84 |
--source include/start_slave.inc |
| 85 |
|
| 86 |
--source include/rpl_end.inc |