1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +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

@ -12,7 +12,7 @@ include/rpl_start_server.inc [server_number=1]
connection slave;
RESET SLAVE;
RESET MASTER;
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1, master_user='root', master_log_file='master-bin.000001', master_log_pos=4;
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1, master_user='root', master_log_file='master-bin.000001', master_log_pos=4, master_use_gtid=no;
include/start_slave.inc
DESC t1;
Field Type Null Key Default Extra

View File

@ -36,7 +36,7 @@
RESET SLAVE;
RESET MASTER;
--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1, master_user='root', master_log_file='master-bin.000001', master_log_pos=4;
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1, master_user='root', master_log_file='master-bin.000001', master_log_pos=4, master_use_gtid=no;
--source include/start_slave.inc
--sync_with_master
DESC t1;

View File

@ -4,6 +4,11 @@
include/rpl_init.inc [topology=1->2]
connection server_2;
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=NO;
include/start_slave.inc
connection server_1;
connection server_2;
include/stop_slave.inc
#####################################################
# Part 1: unencrypted master
#####################################################
@ -63,7 +68,9 @@ SHOW TABLES;
Tables_in_test
table1_no_encryption
include/stop_slave.inc
reset slave;
include/reset_slave.inc
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
##########
# Cleanup
##########

View File

@ -20,6 +20,13 @@
--let $rpl_topology= 1->2
--source include/rpl_init.inc
--connection server_2
--source include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=NO;
--source include/start_slave.inc
--connection server_1
--enable_connect_log
# We stop replication because we want it to happen after the switch
@ -132,7 +139,8 @@ SHOW TABLES;
--disable_connect_log
--source include/stop_slave.inc
--enable_connect_log
reset slave;
--let $master_use_gtid_option= No
--source include/reset_slave.inc
--echo ##########
--echo # Cleanup

View File

@ -99,7 +99,8 @@ set default_master_connection = '';
change master to
master_port=MYPORT_2,
master_host='127.0.0.1',
master_user='root';
master_user='root',
master_use_gtid=no;
start slave;
include/wait_for_slave_to_start.inc
#

View File

@ -232,6 +232,9 @@ connection master;
#######################################################################
include/rpl_reset.inc
connection slave;
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=NO;
include/start_slave.inc
call mtr.add_suppression("Slave I/O: Relay log write failure: could not queue event from master.*");
call mtr.add_suppression("Error writing file .*");
call mtr.add_suppression("Could not use .*");
@ -277,5 +280,7 @@ include/stop_slave_sql.inc
Warnings:
Note 1255 Slave already has been stopped
RESET SLAVE;
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
RESET MASTER;
include/rpl_end.inc

View File

@ -2,6 +2,9 @@ include/master-slave.inc
[connection master]
connection slave;
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=NO;
include/start_slave.inc
include/stop_slave.inc
connection master;
call mtr.add_suppression("Error in Log_event::read_log_event()");
include/rpl_stop_server.inc [server_number=1]
@ -10,7 +13,9 @@ show binlog events;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
connection slave;
call mtr.add_suppression("Slave I/O: Got fatal error 1236 from master when reading data from binary log");
reset slave;
include/reset_slave.inc
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
start slave;
include/wait_for_slave_param.inc [Last_IO_Errno]
Last_IO_Errno = '1236'
@ -20,6 +25,8 @@ reset master;
connection slave;
stop slave;
reset slave;
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
drop table if exists t;
reset master;
End of the tests

View File

@ -1,5 +1,10 @@
include/master-slave.inc
[connection master]
connection slave;
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=NO;
include/start_slave.inc
connection master;
call mtr.add_suppression('Slave can not handle replication events with the checksum that master is configured to log');
call mtr.add_suppression('Replication event checksum verification failed');
call mtr.add_suppression('Relay log write failure: could not queue event from master');
@ -122,7 +127,9 @@ must be zero
0
connection slave;
stop slave;
reset slave;
include/reset_slave.inc
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
flush logs;
connection master;

View File

@ -1,5 +1,10 @@
include/master-slave.inc
[connection master]
connection slave;
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=NO;
include/start_slave.inc
connection master;
call mtr.add_suppression('Found invalid event in binary log');
call mtr.add_suppression('Slave I/O: Relay log write failure: could not queue event from master');
call mtr.add_suppression('event read from binlog did not pass crc check');

View File

@ -1,5 +1,10 @@
include/master-slave.inc
[connection master]
connection slave;
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=NO;
include/start_slave.inc
connection master;
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
SET GLOBAL max_binlog_cache_size = 4096;
SET GLOBAL binlog_cache_size = 4096;

View File

@ -6,16 +6,18 @@ call mtr.add_suppression("Read semi-sync reply");
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
call mtr.add_suppression("mysqld: Got an error reading communication packets");
connection slave;
set sql_log_bin=0;
call mtr.add_suppression("Master server does not support semi-sync");
call mtr.add_suppression("Semi-sync slave .* reply");
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;
connection master;
#
# Uninstall semi-sync plugins on master and slave
#
connection slave;
include/stop_slave.inc
reset slave;
include/reset_slave.inc
set global rpl_semi_sync_master_enabled= 0;
set global rpl_semi_sync_slave_enabled= 0;
connection master;
@ -310,7 +312,7 @@ Variable_name Value
Rpl_semi_sync_master_yes_tx 0
connection slave;
include/stop_slave.inc
reset slave;
include/reset_slave.inc
include/kill_binlog_dump_threads.inc
connection slave;
include/start_slave.inc
@ -340,7 +342,7 @@ Rpl_semi_sync_master_yes_tx 3
#
connection slave;
include/stop_slave.inc
reset slave;
include/reset_slave.inc
connection master;
reset master;
include/kill_binlog_dump_threads.inc

View File

@ -1,6 +1,11 @@
include/master-slave.inc
[connection master]
connection slave;
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=NO;
include/start_slave.inc
connection master;
connection slave;
CREATE USER 'nonsuperuser'@'127.0.0.1';
GRANT ALTER,CREATE,DELETE,DROP,EVENT,INSERT,PROCESS,REPLICATION SLAVE,
SELECT,UPDATE ON *.* TO 'nonsuperuser'@'127.0.0.1';