mirror of
https://github.com/MariaDB/server.git
synced 2025-02-04 21:02:17 +01:00
5ab5ff08b0
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>
56 lines
1.8 KiB
Text
56 lines
1.8 KiB
Text
include/master-slave.inc
|
|
[connection master]
|
|
"Command: STOP SLAVE --> STOP REPLICA"
|
|
connection slave;
|
|
STOP REPLICA;
|
|
include/wait_for_slave_io_to_stop.inc
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
connection master;
|
|
CREATE USER 'repl_user';
|
|
"Privilege: SLAVE --> REPLICA"
|
|
GRANT REPLICATION REPLICA on *.* TO repl_user;
|
|
FLUSH PRIVILEGES;
|
|
connection slave;
|
|
"SHOW SLAVE STATUS --> SHOW REPLICA STATUS"
|
|
CHANGE MASTER TO MASTER_USER= 'repl_user';
|
|
"Command: START SLAVE --> START REPLICA"
|
|
START REPLICA;
|
|
include/wait_for_slave_io_to_start.inc
|
|
include/wait_for_slave_sql_to_start.inc
|
|
connection master;
|
|
connection slave;
|
|
connection master;
|
|
"Command: SHOW SLAVE HOSTS --> SHOW REPLICA HOSTS"
|
|
DROP USER 'repl_user';
|
|
connection slave;
|
|
"Command: SHOW SLAVE IO/SQL THREAD --> SHOW REPLICA IO/SQL THREAD"
|
|
STOP REPLICA IO_THREAD;
|
|
STOP REPLICA SQL_THREAD;
|
|
include/wait_for_slave_io_to_stop.inc
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
"Command: RESET SLAVE ALL --> RESET REPLICA ALL"
|
|
RESET REPLICA ALL;
|
|
set @@global.gtid_slave_pos= "";
|
|
connection master;
|
|
RESET MASTER;
|
|
CREATE TABLE t(f INT) ENGINE=INNODB;
|
|
INSERT INTO t VALUES (10);
|
|
DROP TABLE t;
|
|
connection slave;
|
|
CHANGE MASTER TO MASTER_HOST='127.0.0.1',MASTER_PORT=MASTER_PORT,MASTER_USER='root';
|
|
"Command: START SLAVE UNTIL --> START REPLICA UNTIL"
|
|
START REPLICA UNTIL MASTER_LOG_FILE='MASTER_LOG_FILE', MASTER_LOG_POS=MASTER_POS;
|
|
include/wait_for_slave_sql_to_stop.inc
|
|
include/stop_slave_io.inc
|
|
SELECT * FROM t;
|
|
f
|
|
10
|
|
include/check_slave_param.inc [Exec_Master_Log_Pos]
|
|
"MASTER_USE_GTID=SLAVE_POS --> MASTER_USE_GTID=REPLICA_POS"
|
|
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT, MASTER_USE_GTID=REPLICA_POS;
|
|
include/start_slave.inc
|
|
connection master;
|
|
CREATE TABLE t2 (f INT PRIMARY KEY) ENGINE=INNODB;
|
|
INSERT INTO t2 VALUES (10);
|
|
DROP TABLE t2;
|
|
include/rpl_end.inc
|