mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +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:
@@ -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;
|
||||
create table t1 (n int not null auto_increment primary key);
|
||||
insert into t1 values(NULL);
|
||||
insert into t1 values(2);
|
||||
|
@@ -9,7 +9,7 @@ File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
|
||||
connection slave;
|
||||
include/stop_slave.inc
|
||||
change master to master_log_pos=MASTER_LOG_POS;
|
||||
change master to master_log_pos=MASTER_LOG_POS, master_use_gtid=no;
|
||||
start slave;
|
||||
include/wait_for_slave_io_error.inc [errno=1236]
|
||||
Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'binlog truncated in the middle of event; consider out of disk space on master; the first event 'master-bin.000001' at XXX, the last event read from 'master-bin.000001' at XXX, the last byte read from 'master-bin.000001' at XXX.''
|
||||
@@ -23,7 +23,7 @@ drop table if exists t1;
|
||||
create table t1 (n int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
connection slave;
|
||||
change master to master_log_pos=MASTER_LOG_POS;
|
||||
change master to master_log_pos=MASTER_LOG_POS, master_use_gtid=no;
|
||||
start slave;
|
||||
select * from t1 ORDER BY n;
|
||||
n
|
||||
|
@@ -7,7 +7,7 @@ include/stop_slave.inc
|
||||
change master to master_user='test';
|
||||
Master_User = 'test'
|
||||
Master_Host = '127.0.0.1'
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
Master_User = 'test'
|
||||
Master_Host = '127.0.0.1'
|
||||
change master to master_user='root';
|
||||
@@ -15,13 +15,13 @@ include/start_slave.inc
|
||||
Master_User = 'root'
|
||||
Master_Host = '127.0.0.1'
|
||||
include/stop_slave.inc
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
include/start_slave.inc
|
||||
connection master;
|
||||
create temporary table t1 (a int);
|
||||
connection slave;
|
||||
include/stop_slave.inc
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
include/start_slave.inc
|
||||
show status like 'slave_open_temp_tables';
|
||||
Variable_name Value
|
||||
@@ -30,7 +30,7 @@ connection master;
|
||||
drop temporary table if exists t1;
|
||||
connection slave;
|
||||
include/stop_slave.inc
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
include/check_slave_no_error.inc
|
||||
change master to master_user='impossible_user_name';
|
||||
start slave;
|
||||
@@ -44,13 +44,14 @@ change master to master_user='impossible_user_name';
|
||||
start slave;
|
||||
include/wait_for_slave_io_error.inc [errno=1045]
|
||||
include/stop_slave_sql.inc
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
include/check_slave_no_error.inc
|
||||
change master to master_user='root';
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
include/start_slave.inc
|
||||
include/stop_slave.inc
|
||||
reset slave all;
|
||||
set @@global.gtid_slave_pos= "";
|
||||
start slave;
|
||||
ERROR HY000: Misconfigured slave: MASTER_HOST was not set; Fix in config file or with CHANGE MASTER TO
|
||||
CHANGE MASTER TO MASTER_HOST= 'MASTER_HOST', MASTER_USER= 'MASTER_USER', MASTER_PORT= MASTER_PORT;
|
||||
|
@@ -10,7 +10,7 @@ INSERT INTO t2 VALUES (3),(4);
|
||||
DROP TABLE t2;
|
||||
connection slave;
|
||||
include/stop_slave.inc
|
||||
RESET SLAVE;
|
||||
include/reset_slave.inc
|
||||
CHANGE MASTER TO MASTER_USER='root', MASTER_CONNECT_RETRY=1, MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_MYPORT;
|
||||
connection slave;
|
||||
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=master_pos_drop_t1;
|
||||
@@ -52,7 +52,7 @@ START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', MASTER_LOG_POS=MASTER
|
||||
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
|
||||
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=MASTER_LOG_POS;
|
||||
include/stop_slave.inc
|
||||
RESET SLAVE;
|
||||
include/reset_slave.inc
|
||||
include/start_slave.inc
|
||||
include/rpl_reset.inc
|
||||
connection master;
|
||||
|
@@ -1,6 +1,9 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
connection slave;
|
||||
include/stop_slave.inc
|
||||
CHANGE MASTER TO MASTER_USE_GTID=NO;
|
||||
include/start_slave.inc
|
||||
create table t1 (n int);
|
||||
reset master;
|
||||
stop slave;
|
||||
|
@@ -7,7 +7,7 @@ include/stop_slave.inc
|
||||
change master to master_user='test';
|
||||
Master_User = 'test'
|
||||
Master_Host = '127.0.0.1'
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
Master_User = 'test'
|
||||
Master_Host = '127.0.0.1'
|
||||
change master to master_user='root';
|
||||
@@ -15,13 +15,13 @@ include/start_slave.inc
|
||||
Master_User = 'root'
|
||||
Master_Host = '127.0.0.1'
|
||||
include/stop_slave.inc
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
include/start_slave.inc
|
||||
connection master;
|
||||
create temporary table t1 (a int);
|
||||
connection slave;
|
||||
include/stop_slave.inc
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
include/start_slave.inc
|
||||
show status like 'slave_open_temp_tables';
|
||||
Variable_name Value
|
||||
@@ -30,7 +30,7 @@ connection master;
|
||||
drop temporary table if exists t1;
|
||||
connection slave;
|
||||
include/stop_slave.inc
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
include/check_slave_no_error.inc
|
||||
change master to master_user='impossible_user_name';
|
||||
start slave;
|
||||
@@ -44,13 +44,14 @@ change master to master_user='impossible_user_name';
|
||||
start slave;
|
||||
include/wait_for_slave_io_error.inc [errno=1045]
|
||||
include/stop_slave_sql.inc
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
include/check_slave_no_error.inc
|
||||
change master to master_user='root';
|
||||
reset slave;
|
||||
include/reset_slave.inc
|
||||
include/start_slave.inc
|
||||
include/stop_slave.inc
|
||||
reset slave all;
|
||||
set @@global.gtid_slave_pos= "";
|
||||
start slave;
|
||||
ERROR HY000: Misconfigured slave: MASTER_HOST was not set; Fix in config file or with CHANGE MASTER TO
|
||||
CHANGE MASTER TO MASTER_HOST= 'MASTER_HOST', MASTER_USER= 'MASTER_USER', MASTER_PORT= MASTER_PORT;
|
||||
|
@@ -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");
|
||||
create table t1 (a int auto_increment, primary key (a), b int, rand_value double not null);
|
||||
create table t2 (a int auto_increment, primary key (a), b int);
|
||||
@@ -960,7 +965,9 @@ include/rpl_stop_server.inc [server_number=1]
|
||||
include/rpl_start_server.inc [server_number=1]
|
||||
--> Master binlog: Server ver: 5.0.16-debug-log, Binlog ver: 4
|
||||
connection 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'
|
||||
include/start_slave.inc
|
||||
SELECT MASTER_POS_WAIT('master-bin.000001', 513) >= 0;
|
||||
MASTER_POS_WAIT('master-bin.000001', 513) >= 0
|
||||
@@ -991,7 +998,9 @@ DROP TRIGGER trg1;
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
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'
|
||||
connection master;
|
||||
SHOW TABLES LIKE 't_';
|
||||
Tables_in_test (t_)
|
||||
|
@@ -5,6 +5,12 @@
|
||||
--source include/have_binlog_format_mixed_or_statement.inc
|
||||
--source include/master-slave.inc
|
||||
|
||||
connection slave;
|
||||
--source include/stop_slave.inc
|
||||
CHANGE MASTER TO MASTER_USE_GTID=NO;
|
||||
--source include/start_slave.inc
|
||||
--connection master
|
||||
|
||||
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
||||
|
||||
#
|
||||
@@ -315,7 +321,8 @@ let $binlog_version= query_get_value(SHOW BINLOG EVENTS, Info, 1);
|
||||
# Make the slave to replay the new binlog.
|
||||
|
||||
connection slave;
|
||||
RESET SLAVE;
|
||||
--let $master_use_gtid_option= No
|
||||
--source include/reset_slave.inc
|
||||
--source include/start_slave.inc
|
||||
|
||||
SELECT MASTER_POS_WAIT('master-bin.000001', 513) >= 0;
|
||||
@@ -342,7 +349,7 @@ DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
|
||||
--source include/stop_slave.inc
|
||||
RESET SLAVE;
|
||||
--source include/reset_slave.inc
|
||||
|
||||
# The master should be clean.
|
||||
|
||||
|
Reference in New Issue
Block a user