1# 2# Purpose: 3# This test ensures that issuing a CHANGE MASTER will not put a replica into 4# an inconsistent state if the slave cannot find the log files (i.e. the call to 5# find_log_pos in reset_logs fails). More specifically, right before a replica 6# purges the relay logs (part of the `CHANGE MASTER TO` logic), the relay log is 7# temporarily closed with state LOG_TO_BE_OPENED. If the server is issued a 8# CHANGE MASTER and it errors in-between the temporary log closure and purge, 9# i.e. during the function find_log_pos, the log should be closed. The bug 10# reported by MDEV-25284 revealed the log is not properly closed, such that 11# future relay log updates fail, and future CHANGE MASTER calls crash the 12# server. 13# 14# Methodology: 15# This test ensures that the relay log is properly closed by ensuring future 16# updates and CHANGE MASTER calls succeed. 17# 18# References: 19# MDEV-25284: Assertion `info->type == READ_CACHE || 20# info->type == WRITE_CACHE' failed 21# 22--source include/master-slave.inc 23--source include/have_debug.inc 24 25--echo # 26--echo # Failed CHANGE MASTER TO should not change relay log status 27--echo # 28 29--connection slave 30--source include/stop_slave.inc 31SET @@debug_dbug="d,simulate_find_log_pos_error"; 32error 1373; 33CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=SLAVE_POS; 34SET @@debug_dbug=""; 35--source include/start_slave.inc 36 37 38--echo # 39--echo # Ensure relay log can be updated after a failed CHANGE MASTER 40--echo # 41 42FLUSH RELAY LOGS; 43--let $slave_param= Relay_Log_File 44--let $slave_param_value= slave-relay-bin.000003 45--source include/wait_for_slave_param.inc 46 47 48--echo # 49--echo # Slave should continue to receive data from old master after failed 50--echo # CHANGE MASTER TO 51--echo # 52 53--connection master 54CREATE TABLE t1 (a int); 55insert into t1 values (1); 56--let $master_checksum= `CHECKSUM TABLE t1` 57--sync_slave_with_master 58 59--connection slave 60if ($master_checksum != `CHECKSUM TABLE t1`) 61{ 62 die("Replica failed to pull data from primary after failed CHANGE MASTER TO"); 63} 64 65 66--echo # 67--echo # Future CHANGE MASTER calls should succeed 68--echo # 69 70--source include/stop_slave.inc 71CHANGE MASTER TO MASTER_USE_GTID=SLAVE_POS; 72--source include/start_slave.inc 73 74 75--echo ######################## 76--echo # Cleanup 77--echo ######################## 78 79--connection master 80DROP TABLE t1; 81 82--connection slave 83--source include/stop_slave.inc 84RESET SLAVE ALL; 85--replace_result $MASTER_MYPORT MASTER_MYPORT 86eval change master to master_port=$MASTER_MYPORT, master_host='127.0.0.1', master_user='root'; 87--source include/start_slave.inc 88 89--disable_query_log 90call mtr.add_suppression("Failed to locate old binlog or relay log files"); 91--enable_query_log 92 93--source include/rpl_end.inc 94