1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +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

@ -10,7 +10,8 @@ multi-master.info
change master 'master1' to
master_port=MYPORT_1,
master_host='127.0.0.1',
master_user='root';
master_user='root',
master_use_gtid=no;
start slave 'master1';
set default_master_connection = 'master1';
include/wait_for_slave_to_start.inc
@ -28,7 +29,8 @@ master1
change master 'MASTER 2.2' to
master_port=MYPORT_2,
master_host='127.0.0.1',
master_user='root';
master_user='root',
master_use_gtid=no;
start slave 'MASTER 2.2';
set default_master_connection = 'MASTER 2.2';
include/wait_for_slave_to_start.inc
@ -53,6 +55,8 @@ stop slave 'master1';
set default_master_connection = 'master1';
include/wait_for_slave_to_stop.inc
reset slave 'master1' all;
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
#
# List of files matching '*info*' pattern
# after 'master1' was completely reset, 'MASTER 2.2' still running
@ -69,7 +73,8 @@ set default_master_connection = '';
change master to
master_port=MYPORT_1,
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
connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1;

View File

@ -30,7 +30,8 @@
eval change master 'master1' to
master_port=$SERVER_MYPORT_1,
master_host='127.0.0.1',
master_user='root';
master_user='root',
master_use_gtid=no;
start slave 'master1';
set default_master_connection = 'master1';
@ -54,7 +55,8 @@ set default_master_connection = 'master1';
eval change master 'MASTER 2.2' to
master_port=$SERVER_MYPORT_2,
master_host='127.0.0.1',
master_user='root';
master_user='root',
master_use_gtid=no;
start slave 'MASTER 2.2';
set default_master_connection = 'MASTER 2.2';
@ -107,7 +109,8 @@ set default_master_connection = '';
eval change master to
master_port=$SERVER_MYPORT_1,
master_host='127.0.0.1',
master_user='root';
master_user='root',
master_use_gtid=no;
start slave;
--source include/wait_for_slave_to_start.inc

View File

@ -24,9 +24,9 @@ insert into t1 values(1);
create table t2(a int);
insert into t2 values(1);
connection server_4;
change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root';
change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root';
change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root';
change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
start all slaves;
set default_master_connection = 'm1';
include/wait_for_slave_to_start.inc
@ -65,14 +65,20 @@ Note 1938 SLAVE 'm2' stopped
Note 1938 SLAVE '' stopped
Note 1938 SLAVE 'm1' stopped
RESET SLAVE 'm1' ALL ;
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
RESET SLAVE 'm2' ALL ;
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
RESET SLAVE ALL ;
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
drop database a;
drop database b;
drop database c;
change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root';
change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root';
change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root';
change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
start all slaves;
Warnings:
Note 1937 SLAVE 'm2' started
@ -124,3 +130,6 @@ SET default_master_connection = "m2";
include/wait_for_slave_to_stop.inc
SET default_master_connection = "";
include/wait_for_slave_to_stop.inc
RESET SLAVE ALL;
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'

View File

@ -40,11 +40,11 @@ insert into t2 values(1);
--connection server_4
--disable_warnings
--replace_result $SERVER_MYPORT_1 MYPORT_1
eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root';
eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
--replace_result $SERVER_MYPORT_2 MYPORT_2
eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root';
eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
--replace_result $SERVER_MYPORT_3 MYPORT_3
eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root';
eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
start all slaves;
set default_master_connection = 'm1';
--source include/wait_for_slave_to_start.inc
@ -78,11 +78,11 @@ drop database a;
drop database b;
drop database c;
--replace_result $SERVER_MYPORT_1 MYPORT_1
eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root';
eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
--replace_result $SERVER_MYPORT_2 MYPORT_2
eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root';
eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
--replace_result $SERVER_MYPORT_3 MYPORT_3
eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root';
eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
start all slaves;
set default_master_connection = 'm1';
--source include/wait_for_slave_to_start.inc
@ -139,3 +139,4 @@ SET default_master_connection = "m2";
--source include/wait_for_slave_to_stop.inc
SET default_master_connection = "";
--source include/wait_for_slave_to_stop.inc
RESET SLAVE ALL;

View File

@ -24,9 +24,9 @@ insert into t1 values(1);
create table t2(a int);
insert into t2 values(1);
connection server_4;
change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root';
change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root';
change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root';
change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
start all slaves;
set default_master_connection = 'm1';
include/wait_for_slave_to_start.inc
@ -88,3 +88,6 @@ SET default_master_connection = "m2";
include/wait_for_slave_to_stop.inc
SET default_master_connection = "";
include/wait_for_slave_to_stop.inc
change master to master_use_gtid=slave_pos;
change master 'm1' to master_use_gtid=slave_pos;
change master 'm2' to master_use_gtid=slave_pos;

View File

@ -37,11 +37,11 @@ insert into t2 values(1);
--connection server_4
--disable_warnings
--replace_result $SERVER_MYPORT_1 MYPORT_1
eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root';
eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
--replace_result $SERVER_MYPORT_2 MYPORT_2
eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root';
eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
--replace_result $SERVER_MYPORT_3 MYPORT_3
eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root';
eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root', master_use_gtid=no;
start all slaves;
set default_master_connection = 'm1';
--source include/wait_for_slave_to_start.inc
@ -114,3 +114,7 @@ SET default_master_connection = "m2";
SET default_master_connection = "";
--source include/wait_for_slave_to_stop.inc
# Reset for check-testcase
change master to master_use_gtid=slave_pos;
change master 'm1' to master_use_gtid=slave_pos;
change master 'm2' to master_use_gtid=slave_pos;

View File

@ -64,7 +64,7 @@ Replicate_Ignore_Server_Ids
Master_Server_Id 1
Master_SSL_Crl
Master_SSL_Crlpath
Using_Gtid No
Using_Gtid Slave_Pos
Gtid_IO_Pos
Replicate_Do_Domain_Ids
Replicate_Ignore_Domain_Ids
@ -125,7 +125,7 @@ Replicate_Ignore_Server_Ids
Master_Server_Id 2
Master_SSL_Crl
Master_SSL_Crlpath
Using_Gtid No
Using_Gtid Slave_Pos
Gtid_IO_Pos
Replicate_Do_Domain_Ids
Replicate_Ignore_Domain_Ids

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

@ -7,7 +7,8 @@ ERROR HY000: Incorrect arguments to MASTER_HOST
change master to
master_port=MYPORT_1,
master_host='127.0.0.1',
master_user='root'
master_user='root',
master_use_gtid=no
for channel 'master1';
start slave for channel 'master1';
set default_master_connection = 'master1';
@ -102,7 +103,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
#
@ -318,6 +320,8 @@ Last_SQL_Errno = '0'
# reset slave
#
RESET SLAVE for channel 'master1';
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
show slave status for channel 'master1'
Master_Port = 'MYPORT_1'

View File

@ -29,7 +29,8 @@ change master to master_host='' for channel 'abc2';
eval change master to
master_port=$SERVER_MYPORT_1,
master_host='127.0.0.1',
master_user='root'
master_user='root',
master_use_gtid=no
for channel 'master1';
start slave for channel 'master1';
@ -154,7 +155,8 @@ set default_master_connection = '';
eval change master to
master_port=$SERVER_MYPORT_2,
master_host='127.0.0.1',
master_user='root';
master_user='root',
master_use_gtid=no;
start slave;
--source include/wait_for_slave_to_start.inc

View File

@ -14,14 +14,14 @@ connection slave;
stop slave 'master1';
show slave 'master1' status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups
127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-master1.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space> None 0 No NULL No 0 0 1 No optimistic 0 NULL 2 1 0
127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-master1.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space> None 0 No NULL No 0 0 1 Slave_Pos 0-1-3 optimistic 0 NULL 2 1 0
mysqld-relay-bin-master1.000001
mysqld-relay-bin-master1.000002
mysqld-relay-bin-master1.index
reset slave 'master1';
show slave 'master1' status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups
127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space> None 0 No NULL No 0 0 1 No optimistic 0 NULL 2 1 0
127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space> None 0 No NULL No 0 0 1 Slave_Pos optimistic 0 NULL 2 1 0
reset slave 'master1' all;
show slave 'master1' status;
ERROR HY000: There is no master connection 'master1'

View File

@ -62,7 +62,7 @@ Replicate_Ignore_Server_Ids
Master_Server_Id 1
Master_SSL_Crl
Master_SSL_Crlpath
Using_Gtid No
Using_Gtid Slave_Pos
Gtid_IO_Pos
Replicate_Do_Domain_Ids
Replicate_Ignore_Domain_Ids
@ -123,7 +123,7 @@ Replicate_Ignore_Server_Ids
Master_Server_Id 2
Master_SSL_Crl
Master_SSL_Crlpath
Using_Gtid No
Using_Gtid Slave_Pos
Gtid_IO_Pos
Replicate_Do_Domain_Ids
Replicate_Ignore_Domain_Ids
@ -148,7 +148,7 @@ CHANNEL_NAME slave2
HOST 127.0.0.1
PORT #
USER root
USING_GTID NO
USING_GTID SLAVE_POS
SSL_ALLOWED NO
SSL_CA_FILE
SSL_CA_PATH
@ -168,7 +168,7 @@ CHANNEL_NAME slave1
HOST 127.0.0.1
PORT #
USER root
USING_GTID NO
USING_GTID SLAVE_POS
SSL_ALLOWED NO
SSL_CA_FILE
SSL_CA_PATH
@ -249,7 +249,7 @@ Replicate_Ignore_Server_Ids
Master_Server_Id 1
Master_SSL_Crl
Master_SSL_Crlpath
Using_Gtid No
Using_Gtid Slave_Pos
Gtid_IO_Pos
Replicate_Do_Domain_Ids
Replicate_Ignore_Domain_Ids
@ -306,7 +306,7 @@ Replicate_Ignore_Server_Ids
Master_Server_Id 1
Master_SSL_Crl
Master_SSL_Crlpath
Using_Gtid No
Using_Gtid Slave_Pos
Gtid_IO_Pos
Replicate_Do_Domain_Ids
Replicate_Ignore_Domain_Ids
@ -367,7 +367,7 @@ Replicate_Ignore_Server_Ids
Master_Server_Id 2
Master_SSL_Crl
Master_SSL_Crlpath
Using_Gtid No
Using_Gtid Slave_Pos
Gtid_IO_Pos
Replicate_Do_Domain_Ids
Replicate_Ignore_Domain_Ids
@ -430,7 +430,7 @@ Replicate_Ignore_Server_Ids
Master_Server_Id 2
Master_SSL_Crl
Master_SSL_Crlpath
Using_Gtid No
Using_Gtid Slave_Pos
Gtid_IO_Pos
Replicate_Do_Domain_Ids
Replicate_Ignore_Domain_Ids
@ -495,7 +495,7 @@ Replicate_Ignore_Server_Ids
Master_Server_Id 2
Master_SSL_Crl
Master_SSL_Crlpath
Using_Gtid No
Using_Gtid Slave_Pos
Gtid_IO_Pos
Replicate_Do_Domain_Ids
Replicate_Ignore_Domain_Ids

View File

@ -12,7 +12,8 @@ connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3;
change master 'master1' to
master_port=MYPORT_1,
master_host='127.0.0.1',
master_user='root';
master_user='root',
master_use_gtid=no;
start slave 'master1';
set default_master_connection = 'master1';
include/wait_for_slave_to_start.inc
@ -20,7 +21,8 @@ set default_master_connection = 'master2';
change master 'master2' to
master_port=MYPORT_2,
master_host='127.0.0.1',
master_user='root';
master_user='root',
master_use_gtid=no;
set global sql_slave_skip_counter = 2;
select @@global.sql_slave_skip_counter;
@@global.sql_slave_skip_counter

View File

@ -38,7 +38,8 @@ create table db.t3 (i int) engine=MyISAM;
eval change master 'master1' to
master_port=$SERVER_MYPORT_1,
master_host='127.0.0.1',
master_user='root';
master_user='root',
master_use_gtid=no;
start slave 'master1';
set default_master_connection = 'master1';
@ -53,7 +54,8 @@ set default_master_connection = 'master2';
eval change master 'master2' to
master_port=$SERVER_MYPORT_2,
master_host='127.0.0.1',
master_user='root';
master_user='root',
master_use_gtid=no;
# the schema creation will be replicated from the 1st master,
# so we want to skip it in the second replication connection