1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-26: Global transaction ID.

Change of user interface to be more logical and more in line with expectations
to work similar to old-style replication.

User can now explicitly choose in CHANGE MASTER whether binlog position is
taken into account (master_gtid_pos=current_pos) or not (master_gtid_pos=
slave_pos) when slave connects to master.

@@gtid_pos is replaced by three separate variables @@gtid_slave_pos (can
be set by user, replicated GTIDs only), @@gtid_binlog_pos (read only), and
@@gtid_current_pos (a combination of the two, most recent GTID within each
domain). mysql.rpl_slave_state is renamed to mysql.gtid_slave_pos to match.

This fixes MDEV-4474.
This commit is contained in:
unknown
2013-05-22 17:36:48 +02:00
parent d795bc9ff8
commit 1cd6eb5f94
84 changed files with 996 additions and 513 deletions

View File

@@ -1,30 +1,30 @@
include/master-slave.inc
[connection master]
*** Test that we check against incorrect table definition for mysql.rpl_slave_state ***
*** Test that we check against incorrect table definition for mysql.gtid_slave_pos ***
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
include/stop_slave.inc
ALTER TABLE mysql.rpl_slave_state CHANGE seq_no seq_no VARCHAR(20);
ALTER TABLE mysql.gtid_slave_pos CHANGE seq_no seq_no VARCHAR(20);
START SLAVE;
INSERT INTO t1 VALUES (1);
CALL mtr.add_suppression("Slave: Failed to open mysql.rpl_slave_state");
CALL mtr.add_suppression("Slave: Failed to open mysql.gtid_slave_pos");
include/wait_for_slave_sql_error.inc [errno=1942]
include/stop_slave.inc
ALTER TABLE mysql.rpl_slave_state CHANGE seq_no seq_no BIGINT UNSIGNED NOT NULL;
ALTER TABLE mysql.rpl_slave_state DROP PRIMARY KEY;
ALTER TABLE mysql.rpl_slave_state ADD PRIMARY KEY (sub_id, domain_id);
ALTER TABLE mysql.gtid_slave_pos CHANGE seq_no seq_no BIGINT UNSIGNED NOT NULL;
ALTER TABLE mysql.gtid_slave_pos DROP PRIMARY KEY;
ALTER TABLE mysql.gtid_slave_pos ADD PRIMARY KEY (sub_id, domain_id);
START SLAVE;
include/wait_for_slave_sql_error.inc [errno=1942]
include/stop_slave.inc
ALTER TABLE mysql.rpl_slave_state DROP PRIMARY KEY;
ALTER TABLE mysql.gtid_slave_pos DROP PRIMARY KEY;
START SLAVE;
include/wait_for_slave_sql_error.inc [errno=1942]
include/stop_slave.inc
ALTER TABLE mysql.rpl_slave_state ADD PRIMARY KEY (sub_id);
ALTER TABLE mysql.gtid_slave_pos ADD PRIMARY KEY (sub_id);
START SLAVE;
include/wait_for_slave_sql_error.inc [errno=1942]
include/stop_slave.inc
ALTER TABLE mysql.rpl_slave_state DROP PRIMARY KEY;
ALTER TABLE mysql.rpl_slave_state ADD PRIMARY KEY (domain_id, sub_id);
ALTER TABLE mysql.gtid_slave_pos DROP PRIMARY KEY;
ALTER TABLE mysql.gtid_slave_pos ADD PRIMARY KEY (domain_id, sub_id);
include/start_slave.inc
SELECT * FROM t1;
a
@@ -38,13 +38,22 @@ SET sql_log_bin = 0;
INSERT INTO t1 VALUES (2);
SET sql_log_bin = 1;
INSERT INTO t1 VALUES (3);
CHANGE MASTER TO master_use_gtid=1;
SET GLOBAL gtid_pos = "0-1-1";
ERROR HY000: Requested GTID_POS 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-11. To use the requested GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
SET GLOBAL gtid_pos = "";
ERROR HY000: Requested GTID_POS contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-11. To use the requested GTID_POS, the old binlog must be removed with RESET MASTER to avoid out-of-order binlog
CHANGE MASTER TO master_use_gtid=current_pos;
BEGIN;
SET GLOBAL gtid_slave_pos = "100-100-100";
ERROR 25000: You are not allowed to execute this command in a transaction
INSERT INTO t1 VALUES (100);
SET GLOBAL gtid_slave_pos = "100-100-100";
ERROR 25000: You are not allowed to execute this command in a transaction
ROLLBACK;
SET GLOBAL gtid_slave_pos = "0-1-1";
Warnings:
Warning 1947 Specified GTID 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-11. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos.
SET GLOBAL gtid_slave_pos = "";
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-11. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos.
RESET MASTER;
SET GLOBAL gtid_pos = "0-1-1";
SET GLOBAL gtid_slave_pos = "0-1-1";
START SLAVE;
SELECT * FROM t1 ORDER BY a;
a
@@ -54,7 +63,7 @@ a
4
*** Test slave requesting a GTID that is not present in the master's binlog ***
include/stop_slave.inc
SET GLOBAL gtid_pos = "0-1-3";
SET GLOBAL gtid_slave_pos = "0-1-3";
START SLAVE;
SET sql_log_bin=0;
CALL mtr.add_suppression("Got fatal error .* from master when reading data from binary log: 'Error: connecting slave requested to start from GTID .*, which is not in the master's binlog'");
@@ -63,9 +72,9 @@ include/wait_for_slave_io_error.inc [errno=1236]
Slave_IO_State = ''
Last_IO_Errno = '1236'
Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Error: connecting slave requested to start from GTID 0-1-3, which is not in the master's binlog''
Using_Gtid = '1'
Using_Gtid = 'Current_Pos'
include/stop_slave.inc
SET GLOBAL gtid_pos = "0-1-2";
SET GLOBAL gtid_slave_pos = "0-1-2";
START SLAVE;
include/wait_for_slave_to_start.inc
INSERT INTO t1 VALUES (5);