mirror of
https://github.com/MariaDB/server.git
synced 2025-04-21 22:55:35 +02:00

Description: ============ If you have a relay log index file that has ended up with some relay log files that do not exists, then RESET SLAVE ALL is not enough to get back to a clean state. Analysis: ========= In the bug scenario slave server is in stopped state and some of the relay logs got deleted but the relay log index file is not updated. During slave server restart replication initialization fails as some of the required relay logs are missing. User executes RESET SLAVE/RESET SLAVE ALL command to start a clean slave. As per the documentation RESET SLAVE command clears the master info and relay log info repositories, deletes all the relay log files, and starts a new relay log file. But in a scenario where the slave server's Relay_log_info object is not initialized slave will not purge the existing relay logs. Hence the index file still remains in a bad state. Users will not be able to start the slave unless these files are cleared. Fix: === RESET SLAVE/RESET SLAVE ALL commands should do the cleanup even in a scenario where Relay_log_info object initialization failed. Backported a flag named 'error_on_rli_init_info' which is required to identify slave's Relay_log_info object initialization failure. This flag exists in MySQL-5.6 onwards as part of BUG#14021292 fix. During RESET SLAVE/RESET SLAVE ALL execution this flag indicates the Relay_log_info initialization failure. In such a case open the relay log index/relay log files and do the required clean up.
91 lines
2.9 KiB
Text
91 lines
2.9 KiB
Text
###############################################################################
|
|
# Bug#24901077: RESET SLAVE ALL DOES NOT ALWAYS RESET SLAVE
|
|
#
|
|
# Problem:
|
|
# =======
|
|
# If you have a relay log index file that has ended up with
|
|
# some relay log files that do not exists, then RESET SLAVE
|
|
# ALL is not enough to get back to a clean state.
|
|
###############################################################################
|
|
# Remove all slave-relay-bin.0* files (do not remove slave-relay-bin.index)
|
|
# During server restart rli initialization will fail as there are no
|
|
# relay logs. In case of bug RESET SLAVE will not do the required clean up
|
|
# as rli is not inited and subsequent START SLAVE will fail.
|
|
# Disable "Warning 1612 Being purged log ./slave-relay-bin.0* was not found"
|
|
# because it is different on Unix and Windows systems.
|
|
|
|
--source include/have_binlog_format_mixed.inc
|
|
--source include/master-slave.inc
|
|
|
|
--connection master
|
|
CREATE TABLE t1 (c1 INT);
|
|
INSERT INTO t1 (c1) VALUES (1);
|
|
--sync_slave_with_master
|
|
|
|
--connection slave
|
|
--source include/stop_slave_sql.inc
|
|
--let $MYSQLD_SLAVE_DATADIR= `select @@datadir`
|
|
|
|
--connection master
|
|
# Generate more relay logs on slave.
|
|
FLUSH LOGS;
|
|
FLUSH LOGS;
|
|
INSERT INTO t1 (c1) VALUES (2);
|
|
|
|
--source include/sync_slave_io_with_master.inc
|
|
call mtr.add_suppression("File '.*slave-relay-bin.");
|
|
call mtr.add_suppression("Could not open log file");
|
|
call mtr.add_suppression("Failed to open the relay log");
|
|
call mtr.add_suppression("Failed to initialize the master info structure");
|
|
|
|
# Stop slave
|
|
--let $rpl_server_number= 2
|
|
--source include/rpl_stop_server.inc
|
|
|
|
# Delete file(s)
|
|
--echo # Removing $remove_pattern file(s)
|
|
--let $remove_pattern= slave-relay-bin.0*
|
|
--remove_files_wildcard $MYSQLD_SLAVE_DATADIR $remove_pattern
|
|
|
|
# Start slave
|
|
--let $rpl_server_number= 2
|
|
--source include/rpl_start_server.inc
|
|
|
|
# Start slave must fail because of the removed file(s).
|
|
--error ER_MASTER_INFO
|
|
START SLAVE;
|
|
|
|
# Try a second time, it must fail again.
|
|
--error ER_MASTER_INFO
|
|
START SLAVE;
|
|
|
|
# Retrieve master executed position before reset slave.
|
|
--let $master_exec_file= query_get_value("SHOW SLAVE STATUS", Relay_Master_Log_File, 1)
|
|
--let $master_exec_pos= query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1)
|
|
|
|
# Reset slave.
|
|
# Disable "Warning 1612 Being purged log ./slave-relay-bin.0* was not found"
|
|
# because it is different on Unix and Windows systems.
|
|
--disable_warnings
|
|
RESET SLAVE;
|
|
--enable_warnings
|
|
DROP TABLE t1;
|
|
--replace_result $master_exec_file MASTER_LOG_FILE $master_exec_pos MASTER_LOG_POS
|
|
--eval START SLAVE UNTIL MASTER_LOG_FILE= '$master_exec_file', MASTER_LOG_POS= $master_exec_pos;
|
|
--source include/wait_for_slave_sql_to_stop.inc
|
|
--source include/stop_slave_io.inc
|
|
|
|
# Start slave.
|
|
--source include/start_slave.inc
|
|
|
|
--connection master
|
|
--sync_slave_with_master
|
|
# Check consistency.
|
|
--let $diff_tables= master:t1, slave:t1
|
|
--source include/diff_tables.inc
|
|
|
|
# Cleanup
|
|
--connection master
|
|
DROP TABLE t1;
|
|
--sync_slave_with_master
|
|
--source include/rpl_end.inc
|