1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-16 00:42:55 +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:
Brandon Nesterenko
2022-05-23 14:14:00 -06:00
parent 8c2faad576
commit 5ab5ff08b0
167 changed files with 1404 additions and 344 deletions

View File

@ -14,12 +14,12 @@ connection slave;
*** Default value ***
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root';
slave_net_timeout/slave_heartbeat_timeout=2.0000
RESET SLAVE;
include/reset_slave.inc
*** Reset slave affect ***
SET @@global.slave_net_timeout=30;
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=5;
RESET SLAVE;
include/reset_slave.inc
SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
Variable_name Value
Slave_heartbeat_period 15.000
@ -31,7 +31,7 @@ SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
Variable_name Value
Slave_heartbeat_period 25.000
SET @@global.slave_net_timeout=@restore_slave_net_timeout;
RESET SLAVE;
include/reset_slave.inc
*** Warning if updated slave_net_timeout < slave_heartbeat_timeout ***
SET @@global.slave_net_timeout=FLOOR(SLAVE_HEARTBEAT_TIMEOUT)-1;
@ -223,11 +223,15 @@ 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;
Heartbeat events are received while sql thread stopped (1 means 'yes'): 1
include/stop_slave.inc
set sql_log_bin= 0;
DROP TABLE t1;
set sql_log_bin= 1;
*** Master send to slave ***
connection master;
@ -240,7 +244,9 @@ END|
Warnings:
Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
connection slave;
RESET SLAVE;
include/reset_slave.inc
Warnings:
Warning 1948 Specified value for @@gtid_slave_pos contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-2. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=5;
include/start_slave.inc
connection master;
@ -256,8 +262,10 @@ connection slave;
*** Flush logs on slave ***
STOP SLAVE;
RESET SLAVE;
include/reset_slave.inc
set sql_log_bin= 0;
DROP TABLE t1;
set sql_log_bin= 1;
connection master;
DROP TABLE t1;
RESET MASTER;
@ -271,7 +279,7 @@ connection master;
SET @@global.slave_compressed_protocol=1;
connection slave;
include/stop_slave.inc
RESET SLAVE;
include/reset_slave.inc
SET @@global.slave_compressed_protocol=1;
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=0.1;
include/start_slave.inc
@ -283,7 +291,7 @@ SET @@global.slave_compressed_protocol=0;
*** Reset master ***
connection slave;
STOP SLAVE;
RESET SLAVE;
include/reset_slave.inc
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=0.1;
include/start_slave.inc
connection master;
@ -294,7 +302,7 @@ Heartbeat events are received after reset of master (1 means 'yes'): 1
*** Reload master ***
connection slave;
STOP SLAVE;
RESET SLAVE;
include/reset_slave.inc
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=0.1;
include/start_slave.inc
Heartbeat event received