mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
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>
This commit is contained in:
@@ -52,7 +52,7 @@ let $slave_net_timeout= query_get_value(SHOW VARIABLES LIKE 'slave_net_timeout',
|
||||
let $slave_heartbeat_timeout= query_get_value(SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period', Value, 1);
|
||||
let $result= query_get_value(SELECT $slave_net_timeout/$slave_heartbeat_timeout AS Result, Result, 1);
|
||||
--echo slave_net_timeout/slave_heartbeat_timeout=$result
|
||||
RESET SLAVE;
|
||||
--source include/reset_slave.inc
|
||||
--echo
|
||||
|
||||
# Reset slave set slave_heartbeat_timeout = slave_net_timeout/2
|
||||
@@ -62,7 +62,7 @@ SET @@global.slave_net_timeout=30;
|
||||
--enable_warnings
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=5;
|
||||
RESET SLAVE;
|
||||
--source include/reset_slave.inc
|
||||
SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
|
||||
--echo
|
||||
|
||||
@@ -75,7 +75,7 @@ SET @@global.slave_net_timeout=50;
|
||||
eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry;
|
||||
SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
|
||||
SET @@global.slave_net_timeout=@restore_slave_net_timeout;
|
||||
RESET SLAVE;
|
||||
--source include/reset_slave.inc
|
||||
--echo
|
||||
|
||||
# Set slave_net_timeout less than current value of slave_heartbeat_period
|
||||
@@ -320,8 +320,10 @@ INSERT INTO t1 VALUES (1, 'on slave', NULL);
|
||||
--connection master
|
||||
INSERT INTO t1 VALUES (1, 'on master', NULL);
|
||||
--connection slave
|
||||
set sql_log_bin= 0;
|
||||
call mtr.add_suppression("Slave SQL.*Duplicate entry .1. for key .PRIMARY.. on query.* error.* 1062");
|
||||
call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
|
||||
set sql_log_bin= 1;
|
||||
let $slave_errno= ER_DUP_ENTRY
|
||||
--source include/wait_for_slave_sql_error.inc
|
||||
let $rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
|
||||
@@ -330,7 +332,9 @@ let $rcvd_heartbeats_after= query_get_value(SHOW STATUS LIKE 'slave_received_hea
|
||||
let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_before) > 0 AS Result, Result, 1);
|
||||
--echo Heartbeat events are received while sql thread stopped (1 means 'yes'): $result
|
||||
--source include/stop_slave.inc
|
||||
set sql_log_bin= 0;
|
||||
DROP TABLE t1;
|
||||
set sql_log_bin= 1;
|
||||
--echo
|
||||
|
||||
# Check received heartbeat events while master send events to slave
|
||||
@@ -346,7 +350,7 @@ CREATE EVENT e1
|
||||
END|
|
||||
DELIMITER ;|
|
||||
--connection slave
|
||||
RESET SLAVE;
|
||||
--source include/reset_slave.inc
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=5;
|
||||
--source include/start_slave.inc
|
||||
@@ -404,8 +408,10 @@ DROP EVENT e1;
|
||||
# Check received heartbeat events while logs flushed on slave
|
||||
--echo *** Flush logs on slave ***
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
--source include/reset_slave.inc
|
||||
set sql_log_bin= 0;
|
||||
DROP TABLE t1;
|
||||
set sql_log_bin= 1;
|
||||
--connection master
|
||||
DROP TABLE t1;
|
||||
RESET MASTER;
|
||||
@@ -435,7 +441,7 @@ let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_b
|
||||
SET @@global.slave_compressed_protocol=1;
|
||||
--connection slave
|
||||
--source include/stop_slave.inc
|
||||
RESET SLAVE;
|
||||
--source include/reset_slave.inc
|
||||
SET @@global.slave_compressed_protocol=1;
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=0.1;
|
||||
@@ -455,7 +461,7 @@ SET @@global.slave_compressed_protocol=0;
|
||||
--echo *** Reset master ***
|
||||
--connection slave
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
--source include/reset_slave.inc
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=0.1;
|
||||
--source include/start_slave.inc
|
||||
@@ -474,7 +480,7 @@ let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_b
|
||||
--echo *** Reload master ***
|
||||
--connection slave
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
--source include/reset_slave.inc
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=0.1;
|
||||
--source include/start_slave.inc
|
||||
|
Reference in New Issue
Block a user