mariadb/mysql-test/suite/multi_source/info_logs.test
Brandon Nesterenko 5ab5ff08b0 MDEV-19801: Change defaults for CHANGE MASTER TO so that GTID-based replication is used by default if master supports it
This commit makes replicas crash-safe by default by changing the
Using_Gtid value to be Slave_Pos on a fresh slave start and after
RESET SLAVE is issued. If the primary server does not support GTIDs
(i.e., version < 10), the replica will fall back to Using_Gtid=No on
slave start and after RESET SLAVE.

The following additional informational messages/warnings are added:

 1. When Using_Gtid is automatically changed. That is, if RESET
SLAVE reverts Using_Gtid back to Slave_Pos, or Using_Gtid is
inferred to No from a CHANGE MASTER TO given with log coordinates
without MASTER_USE_GTID.
 2. If options are ignored in CHANGE MASTER TO. If CHANGE MASTER TO
is given with log coordinates, yet also specifies
MASTER_USE_GTID=Slave_Pos, a warning message is given that the log
coordinate options are ignored.

Additionally, an MTR macro has been added for RESET SLAVE,
reset_slave.inc, which provides modes/options for resetting a slave
in log coordinate or gtid modes. When in log coordinates mode, the
macro will execute CHANGE MASTER TO MASTER_USE_GTID=No after the
RESET SLAVE command. When in GTID mode, an extra parameter,
reset_slave_keep_gtid_state, can be set to reset or preserve the
value of gtid_slave_pos.

Reviewed By:
===========
Andrei Elkin <andrei.elkin@mariadb.com>
2022-07-26 13:31:27 -06:00

203 lines
5.1 KiB
Text

#
# Check log files with multi-source
#
--source include/not_embedded.inc
--source include/binlog_start_pos.inc
--let $rpl_server_count= 0
--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
--let $datadir = `SELECT @@datadir`
#
# Check creation and updating of multi-source *info* logs
#
--echo #
--echo # List of files matching '*info*' pattern before starting any slaves
--list_files $datadir *info*
--echo # End of list
--echo #
--echo # Contents of multi-master.info
--cat_file $datadir/multi-master.info
--echo # EOF
--echo #
# Start replication from the first master
--replace_result $SERVER_MYPORT_1 MYPORT_1
eval change master 'master1' to
master_port=$SERVER_MYPORT_1,
master_host='127.0.0.1',
master_user='root',
master_use_gtid=no;
start slave 'master1';
set default_master_connection = 'master1';
--source include/wait_for_slave_to_start.inc
# Check the files
--echo #
--echo # List of files matching '*info*' pattern while 'master1' is running
--list_files $datadir *info*
--echo # End of list
--echo #
--echo # Contents of multi-master.info
--cat_file $datadir/multi-master.info
--echo # EOF
--echo #
# Start replication from the second master
--replace_result $SERVER_MYPORT_2 MYPORT_2
eval change master 'MASTER 2.2' to
master_port=$SERVER_MYPORT_2,
master_host='127.0.0.1',
master_user='root',
master_use_gtid=no;
start slave 'MASTER 2.2';
set default_master_connection = 'MASTER 2.2';
--source include/wait_for_slave_to_start.inc
--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2)
--save_master_pos
--connection slave
--sync_with_master 0,'MASTER 2.2'
# Check the files
--echo #
--echo # List of files matching '*info*' pattern
--echo # while 'master1' and 'MASTER 2.2' are running
--list_files $datadir *info*
--echo # End of list
--echo #
--echo # Contents of multi-master.info
--cat_file $datadir/multi-master.info
--echo # EOF
--echo #
# Remove master1 configuration
stop slave 'master1';
set default_master_connection = 'master1';
--source include/wait_for_slave_to_stop.inc
reset slave 'master1' all;
# Check the files
--echo #
--echo # List of files matching '*info*' pattern
--echo # after 'master1' was completely reset, 'MASTER 2.2' still running
--list_files $datadir *info*
--echo # End of list
--echo #
--echo # Contents of multi-master.info
--cat_file $datadir/multi-master.info
--echo # EOF
--echo #
# Start replication from the first master,
# now with the default empty name
set default_master_connection = '';
--replace_result $SERVER_MYPORT_1 MYPORT_1
eval change master to
master_port=$SERVER_MYPORT_1,
master_host='127.0.0.1',
master_user='root',
master_use_gtid=no;
start slave;
--source include/wait_for_slave_to_start.inc
--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1)
--save_master_pos
--connection slave
--sync_with_master
# Check the files
--echo #
--echo # List of files matching '*info*' pattern
--echo # while 'MASTER 2.2' and '' are running
--list_files $datadir *info*
--echo # End of list
--echo #
--echo # Contents of multi-master.info
--cat_file $datadir/multi-master.info
--echo # EOF
--echo #
let $wait_for_all= 1;
let $show_statement= SHOW ALL SLAVES STATUS;
let $field= Slave_IO_State;
let $condition= = 'Waiting for master to send event';
--source include/wait_show_condition.inc
let read_master_log_pos=`select $binlog_start_pos + 73`;
let relay_log_pos=`select 2*$binlog_start_pos + 117`;
let relay_log_space1=`select 3*$binlog_start_pos + 160`;
let relay_log_space2=`select 3*$binlog_start_pos + 179`;
--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2>
show all slaves status;
# Restart the slave server
--enable_reconnect
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.3.expect
restart
EOF
--shutdown_server
--source include/wait_until_connected_again.inc
--source include/wait_for_slave_to_start.inc
set default_master_connection = 'MASTER 2.2';
--source include/wait_for_slave_to_start.inc
set default_master_connection = '';
let $wait_for_all= 1;
let $show_statement= SHOW ALL SLAVES STATUS;
let $field= Slave_IO_State;
let $condition= = 'Waiting for master to send event';
--source include/wait_show_condition.inc
let relay_log_pos=`select 2*$binlog_start_pos + 44`;
let relay_log_space1=`select 3*$binlog_start_pos + 87`;
let relay_log_space2=`select 3*$binlog_start_pos + 106`;
--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2>
show all slaves status;
# Check the files
--echo #
--echo # List of files matching '*info*' pattern
--echo # after slave server restart
--echo # while 'MASTER 2.2' and '' are running
--list_files $datadir *info*
--echo # End of list
--echo #
--echo # Contents of multi-master.info
--cat_file $datadir/multi-master.info
--echo # EOF
--echo #
# Cleanup
--source include/reset_master_slave.inc
--disconnect slave
--connection master1
--source include/reset_master_slave.inc
--disconnect master1
--connection master2
--source include/reset_master_slave.inc
--disconnect master2