mirror of
https://github.com/MariaDB/server.git
synced 2025-11-30 05:23:50 +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:
@@ -49,7 +49,7 @@ save_master_pos;
|
||||
connection server_4;
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
|
||||
MASTER_USE_GTID=1;
|
||||
MASTER_USE_GTID=CURRENT_POS;
|
||||
--source include/start_slave.inc
|
||||
sync_with_master;
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
@@ -60,7 +60,7 @@ connection server_2;
|
||||
--source include/stop_slave.inc
|
||||
--replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
|
||||
MASTER_USE_GTID=1;
|
||||
MASTER_USE_GTID=CURRENT_POS;
|
||||
--source include/start_slave.inc
|
||||
|
||||
connection server_4;
|
||||
@@ -85,7 +85,7 @@ COMMIT;
|
||||
connection server_3;
|
||||
--replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
|
||||
MASTER_USE_GTID=1;
|
||||
MASTER_USE_GTID=CURRENT_POS;
|
||||
--source include/start_slave.inc
|
||||
# This time, let's sync up without reference to binlog on D.
|
||||
--let $wait_condition= SELECT COUNT(*) = 7 FROM t2
|
||||
@@ -93,7 +93,7 @@ eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
|
||||
SELECT * FROM t2 ORDER BY a;
|
||||
|
||||
--echo *** Now change everything back to what it was, to make rpl_end.inc happy
|
||||
# Also check that MASTER_USE_GTID=1 is still enabled.
|
||||
# Also check that MASTER_USE_GTID=CURRENT_POS is still enabled.
|
||||
connection server_2;
|
||||
# We need to sync up server_2 before switching. If it happened to have reached
|
||||
# the point 'UPDATE t2 SET b="j1a" WHERE a=5' it will fail to connect to
|
||||
|
||||
@@ -13,7 +13,7 @@ call mtr.add_suppression("Checking table:");
|
||||
call mtr.add_suppression("client is using or hasn't closed the table properly");
|
||||
call mtr.add_suppression("Table .* is marked as crashed and should be repaired");
|
||||
|
||||
ALTER TABLE mysql.rpl_slave_state ENGINE=InnoDB;
|
||||
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (1, 0);
|
||||
--save_master_pos
|
||||
@@ -23,7 +23,7 @@ INSERT INTO t1 VALUES (1, 0);
|
||||
--source include/stop_slave.inc
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
|
||||
MASTER_USE_GTID=1;
|
||||
MASTER_USE_GTID=CURRENT_POS;
|
||||
|
||||
--connection server_1
|
||||
INSERT INTO t1 VALUES (2,1);
|
||||
@@ -79,7 +79,7 @@ DROP TABLE t1;
|
||||
--sync_with_master
|
||||
--source include/stop_slave.inc
|
||||
RESET MASTER;
|
||||
SET GLOBAL gtid_pos='';
|
||||
SET GLOBAL gtid_slave_pos='';
|
||||
|
||||
--connection server_1
|
||||
RESET MASTER;
|
||||
@@ -130,7 +130,7 @@ SELECT * FROM t1 ORDER BY a;
|
||||
|
||||
--echo *** Test crashing slave at various points and check that it recovers crash-safe. ***
|
||||
|
||||
# Crash the slave just before updating mysql.rpl_slave_state table.
|
||||
# Crash the slave just before updating mysql.gtid_slave_pos table.
|
||||
--source include/stop_slave.inc
|
||||
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
||||
wait
|
||||
|
||||
@@ -2,47 +2,47 @@
|
||||
--source include/have_debug.inc
|
||||
--source include/master-slave.inc
|
||||
|
||||
--echo *** Test that we check against incorrect table definition for mysql.rpl_slave_state ***
|
||||
--echo *** Test that we check against incorrect table definition for mysql.gtid_slave_pos ***
|
||||
--connection master
|
||||
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
--sync_slave_with_master
|
||||
|
||||
--connection slave
|
||||
--source 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;
|
||||
|
||||
--connection master
|
||||
INSERT INTO t1 VALUES (1);
|
||||
|
||||
--connection slave
|
||||
CALL mtr.add_suppression("Slave: Failed to open mysql.rpl_slave_state");
|
||||
CALL mtr.add_suppression("Slave: Failed to open mysql.gtid_slave_pos");
|
||||
--let $slave_sql_errno=1942
|
||||
--source include/wait_for_slave_sql_error.inc
|
||||
|
||||
--source 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;
|
||||
--let $slave_sql_errno=1942
|
||||
--source include/wait_for_slave_sql_error.inc
|
||||
|
||||
--source include/stop_slave.inc
|
||||
ALTER TABLE mysql.rpl_slave_state DROP PRIMARY KEY;
|
||||
ALTER TABLE mysql.gtid_slave_pos DROP PRIMARY KEY;
|
||||
START SLAVE;
|
||||
--let $slave_sql_errno=1942
|
||||
--source include/wait_for_slave_sql_error.inc
|
||||
|
||||
--source 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;
|
||||
--let $slave_sql_errno=1942
|
||||
--source include/wait_for_slave_sql_error.inc
|
||||
|
||||
--source 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);
|
||||
--source include/start_slave.inc
|
||||
|
||||
--connection master
|
||||
@@ -69,13 +69,22 @@ INSERT INTO t1 VALUES (2);
|
||||
SET sql_log_bin = 1;
|
||||
INSERT INTO t1 VALUES (3);
|
||||
|
||||
CHANGE MASTER TO master_use_gtid=1;
|
||||
--error ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG
|
||||
SET GLOBAL gtid_pos = "0-1-1";
|
||||
--error ER_MASTER_GTID_POS_MISSING_DOMAIN
|
||||
SET GLOBAL gtid_pos = "";
|
||||
CHANGE MASTER TO master_use_gtid=current_pos;
|
||||
# Most not change @@GLOBAL.gtid_slave_pos in the middle of a transaction.
|
||||
BEGIN;
|
||||
--error ER_CANT_DO_THIS_DURING_AN_TRANSACTION
|
||||
SET GLOBAL gtid_slave_pos = "100-100-100";
|
||||
INSERT INTO t1 VALUES (100);
|
||||
--error ER_CANT_DO_THIS_DURING_AN_TRANSACTION
|
||||
SET GLOBAL gtid_slave_pos = "100-100-100";
|
||||
ROLLBACK;
|
||||
|
||||
# In gtid non-strict mode, we get warnings for setting @@gtid_slave_pos back
|
||||
# to earlier than what is in the binlog.
|
||||
SET GLOBAL gtid_slave_pos = "0-1-1";
|
||||
SET GLOBAL gtid_slave_pos = "";
|
||||
RESET MASTER;
|
||||
SET GLOBAL gtid_pos = "0-1-1";
|
||||
SET GLOBAL gtid_slave_pos = "0-1-1";
|
||||
|
||||
START SLAVE;
|
||||
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1
|
||||
@@ -85,7 +94,7 @@ SELECT * FROM t1 ORDER BY a;
|
||||
|
||||
--echo *** Test slave requesting a GTID that is not present in the master's binlog ***
|
||||
--source 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;
|
||||
@@ -98,7 +107,7 @@ SET sql_log_bin=1;
|
||||
|
||||
--let $rpl_only_running_threads= 1
|
||||
--source include/stop_slave.inc
|
||||
SET GLOBAL gtid_pos = "0-1-2";
|
||||
SET GLOBAL gtid_slave_pos = "0-1-2";
|
||||
START SLAVE;
|
||||
--source include/wait_for_slave_to_start.inc
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# using START SLAVE UNTIL master_gtid_pos.
|
||||
|
||||
--connection server_1
|
||||
ALTER TABLE mysql.rpl_slave_state ENGINE=InnoDB;
|
||||
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
|
||||
CREATE TABLE t4 (a INT, b INT, PRIMARY KEY (a,b)) Engine=InnoDB;
|
||||
|
||||
# Function to extract one GTID from a list.
|
||||
@@ -31,22 +31,22 @@ delimiter ;|
|
||||
--connection server_2
|
||||
--sync_with_master
|
||||
--source include/stop_slave.inc
|
||||
CHANGE MASTER TO master_use_gtid=1;
|
||||
CHANGE MASTER TO master_use_gtid=current_pos;
|
||||
|
||||
--connection server_3
|
||||
--sync_with_master
|
||||
--source include/stop_slave.inc
|
||||
CHANGE MASTER TO master_use_gtid=1;
|
||||
CHANGE MASTER TO master_use_gtid=current_pos;
|
||||
|
||||
--connection server_4
|
||||
--sync_with_master
|
||||
--source include/stop_slave.inc
|
||||
CHANGE MASTER TO master_use_gtid=1;
|
||||
CHANGE MASTER TO master_use_gtid=current_pos;
|
||||
|
||||
--connection server_5
|
||||
--sync_with_master
|
||||
--source include/stop_slave.inc
|
||||
CHANGE MASTER TO master_use_gtid=1;
|
||||
CHANGE MASTER TO master_use_gtid=current_pos;
|
||||
|
||||
|
||||
# Create three separate replication streams on master server_1.
|
||||
@@ -59,39 +59,39 @@ CHANGE MASTER TO master_use_gtid=1;
|
||||
|
||||
SET gtid_domain_id= 1;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
--let $d1_begin= `SELECT extract_gtid("1", @@GLOBAL.gtid_pos)`
|
||||
--let $d1_begin= `SELECT extract_gtid("1", @@GLOBAL.gtid_binlog_pos)`
|
||||
INSERT INTO t1 VALUES (1);
|
||||
INSERT INTO t1 VALUES (2);
|
||||
INSERT INTO t4 VALUES (1, 1);
|
||||
--let $d1_mid= `SELECT extract_gtid("1", @@GLOBAL.gtid_pos)`
|
||||
--let $d1_mid= `SELECT extract_gtid("1", @@GLOBAL.gtid_binlog_pos)`
|
||||
INSERT INTO t1 VALUES (3);
|
||||
INSERT INTO t1 VALUES (4);
|
||||
INSERT INTO t4 VALUES (1, 3);
|
||||
--let $d1_end= `SELECT extract_gtid("1", @@GLOBAL.gtid_pos)`
|
||||
--let $d1_end= `SELECT extract_gtid("1", @@GLOBAL.gtid_binlog_pos)`
|
||||
|
||||
SET gtid_domain_id= 2;
|
||||
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
--let $d2_begin= `SELECT extract_gtid("2", @@GLOBAL.gtid_pos)`
|
||||
--let $d2_begin= `SELECT extract_gtid("2", @@GLOBAL.gtid_binlog_pos)`
|
||||
INSERT INTO t2 VALUES (1);
|
||||
INSERT INTO t2 VALUES (2);
|
||||
INSERT INTO t4 VALUES (2, 1);
|
||||
--let $d2_mid= `SELECT extract_gtid("2", @@GLOBAL.gtid_pos)`
|
||||
--let $d2_mid= `SELECT extract_gtid("2", @@GLOBAL.gtid_binlog_pos)`
|
||||
INSERT INTO t2 VALUES (3);
|
||||
INSERT INTO t2 VALUES (4);
|
||||
INSERT INTO t4 VALUES (2, 3);
|
||||
--let $d2_end= `SELECT extract_gtid("2", @@GLOBAL.gtid_pos)`
|
||||
--let $d2_end= `SELECT extract_gtid("2", @@GLOBAL.gtid_binlog_pos)`
|
||||
|
||||
SET gtid_domain_id= 3;
|
||||
CREATE TABLE t3 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
--let $d3_begin= `SELECT extract_gtid("3", @@GLOBAL.gtid_pos)`
|
||||
--let $d3_begin= `SELECT extract_gtid("3", @@GLOBAL.gtid_binlog_pos)`
|
||||
INSERT INTO t3 VALUES (1);
|
||||
INSERT INTO t3 VALUES (2);
|
||||
INSERT INTO t4 VALUES (3, 1);
|
||||
--let $d3_mid= `SELECT extract_gtid("3", @@GLOBAL.gtid_pos)`
|
||||
--let $d3_mid= `SELECT extract_gtid("3", @@GLOBAL.gtid_binlog_pos)`
|
||||
INSERT INTO t3 VALUES (3);
|
||||
INSERT INTO t3 VALUES (4);
|
||||
INSERT INTO t4 VALUES (3, 3);
|
||||
--let $d3_end= `SELECT extract_gtid("3", @@GLOBAL.gtid_pos)`
|
||||
--let $d3_end= `SELECT extract_gtid("3", @@GLOBAL.gtid_binlog_pos)`
|
||||
|
||||
|
||||
# Slave server_2 (that will be promoted to master) is in the middle
|
||||
@@ -135,7 +135,7 @@ SELECT * FROM t4 ORDER BY a,b;
|
||||
--echo *** Now replicate all extra changes from 3,4,5 to 2, in preparation for making 2 the new master. ***
|
||||
|
||||
--connection server_3
|
||||
--let $server3_pos= `SELECT @@GLOBAL.gtid_pos`
|
||||
--let $server3_pos= `SELECT @@GLOBAL.gtid_slave_pos`
|
||||
--connection server_2
|
||||
--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_3;
|
||||
@@ -147,7 +147,7 @@ SELECT * FROM t3 ORDER BY a;
|
||||
SELECT * FROM t4 ORDER BY a,b;
|
||||
|
||||
--connection server_4
|
||||
--let $server4_pos= `SELECT @@GLOBAL.gtid_pos`
|
||||
--let $server4_pos= `SELECT @@GLOBAL.gtid_slave_pos`
|
||||
--connection server_2
|
||||
--replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4;
|
||||
@@ -159,7 +159,7 @@ SELECT * FROM t3 ORDER BY a;
|
||||
SELECT * FROM t4 ORDER BY a,b;
|
||||
|
||||
--connection server_5
|
||||
--let $server5_pos= `SELECT @@GLOBAL.gtid_pos`
|
||||
--let $server5_pos= `SELECT @@GLOBAL.gtid_slave_pos`
|
||||
--connection server_2
|
||||
--replace_result $SERVER_MYPORT_5 SERVER_MYPORT_5
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_5;
|
||||
@@ -222,7 +222,7 @@ SELECT * FROM t4 ORDER BY a,b;
|
||||
--connection server_1
|
||||
--replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_2,
|
||||
master_user = "root", master_use_gtid = 1;
|
||||
master_user = "root", master_use_gtid = current_pos;
|
||||
--source include/start_slave.inc
|
||||
--sync_with_master
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
|
||||
@@ -24,7 +24,7 @@ reset slave all;
|
||||
connection server_1;
|
||||
--replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_2,
|
||||
master_user='root', MASTER_USE_GTID=1;
|
||||
master_user='root', MASTER_USE_GTID=CURRENT_POS;
|
||||
source include/start_slave.inc;
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
|
||||
@@ -38,7 +38,7 @@ save_master_pos;
|
||||
connection server_3;
|
||||
--replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_2,
|
||||
MASTER_USE_GTID=1;
|
||||
MASTER_USE_GTID=CURRENT_POS;
|
||||
source include/start_slave.inc;
|
||||
sync_with_master;
|
||||
|
||||
@@ -56,14 +56,14 @@ reset slave all;
|
||||
connection server_2;
|
||||
--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_USE_GTID=1;
|
||||
master_user = 'root', MASTER_USE_GTID=CURRENT_POS;
|
||||
source include/start_slave.inc;
|
||||
|
||||
connection server_3;
|
||||
source include/stop_slave.inc;
|
||||
--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_1,
|
||||
MASTER_USE_GTID=1;
|
||||
MASTER_USE_GTID=CURRENT_POS;
|
||||
source include/start_slave.inc;
|
||||
|
||||
connection server_1;
|
||||
|
||||
11
mysql-test/suite/rpl/t/rpl_gtid_mdev4474.cnf
Normal file
11
mysql-test/suite/rpl/t/rpl_gtid_mdev4474.cnf
Normal file
@@ -0,0 +1,11 @@
|
||||
!include suite/rpl/rpl_1slave_base.cnf
|
||||
!include include/default_client.cnf
|
||||
|
||||
|
||||
[mysqld.1]
|
||||
log-slave-updates
|
||||
loose-innodb
|
||||
|
||||
[mysqld.2]
|
||||
log-slave-updates
|
||||
loose-innodb
|
||||
76
mysql-test/suite/rpl/t/rpl_gtid_mdev4474.test
Normal file
76
mysql-test/suite/rpl/t/rpl_gtid_mdev4474.test
Normal file
@@ -0,0 +1,76 @@
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_binlog_format_mixed_or_statement.inc
|
||||
--let $rpl_topology=1->2->1
|
||||
--source include/rpl_init.inc
|
||||
|
||||
--echo #
|
||||
--echo # For now we'll only have 1->2 running
|
||||
|
||||
--echo #
|
||||
--echo # Server 1
|
||||
--echo # Stop replication 2->1
|
||||
--connection server_1
|
||||
--source include/stop_slave.inc
|
||||
|
||||
--echo #
|
||||
--echo # Server 2
|
||||
--echo # Use GTID for replication 1->2
|
||||
--connection server_2
|
||||
--source include/stop_slave.inc
|
||||
change master to master_use_gtid=slave_pos;
|
||||
--source include/start_slave.inc
|
||||
|
||||
--echo #
|
||||
--echo # Create some 0-1-* and 0-2-* events in binlog of server 2
|
||||
|
||||
--enable_connect_log
|
||||
|
||||
--connection server_1
|
||||
create table t1 (i int) engine=InnoDB;
|
||||
insert into t1 values (1);
|
||||
--save_master_pos
|
||||
|
||||
--connection server_2
|
||||
--sync_with_master
|
||||
create table t2 (i int) engine=InnoDB;
|
||||
--save_master_pos
|
||||
|
||||
--connection server_1
|
||||
insert into t1 values (2);
|
||||
--save_master_pos
|
||||
|
||||
--connection server_2
|
||||
--sync_with_master
|
||||
insert into t2 values (1);
|
||||
--save_master_pos
|
||||
|
||||
--disable_connect_log
|
||||
|
||||
--echo #
|
||||
--echo # All events are present in the binlog of server 2
|
||||
|
||||
--source include/show_binlog_events.inc
|
||||
|
||||
--echo #
|
||||
--echo # Server 1
|
||||
--echo # Start replication 2->1 using GTID,
|
||||
|
||||
--connection server_1
|
||||
change master to master_use_gtid=slave_pos;
|
||||
--source include/start_slave.inc
|
||||
--sync_with_master
|
||||
|
||||
select * from t1 order by i;
|
||||
select * from t2 order by i;
|
||||
|
||||
--connection server_2
|
||||
select * from t1 order by i;
|
||||
select * from t2 order by i;
|
||||
|
||||
--connection server_1
|
||||
drop table t1;
|
||||
|
||||
--connection server_2
|
||||
drop table t2;
|
||||
|
||||
--source include/rpl_end.inc
|
||||
@@ -26,7 +26,7 @@ INSERT INTO t1 VALUES (4, 2);
|
||||
--connection server_1
|
||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SLAVE_MYPORT,
|
||||
master_user = 'root', master_use_gtid = 1;
|
||||
master_user = 'root', master_use_gtid = current_pos;
|
||||
START SLAVE;
|
||||
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1
|
||||
--source include/wait_condition.inc
|
||||
@@ -41,7 +41,7 @@ INSERT INTO t1 VALUES (6, 1);
|
||||
--connection server_2
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
|
||||
master_use_gtid = 1;
|
||||
master_use_gtid = current_pos;
|
||||
START SLAVE;
|
||||
--let $wait_condition= SELECT COUNT(*) = 6 FROM t1
|
||||
--source include/wait_condition.inc
|
||||
|
||||
@@ -16,10 +16,10 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
--save_master_pos
|
||||
|
||||
--connection server_2
|
||||
SET GLOBAL gtid_pos="";
|
||||
SET GLOBAL gtid_slave_pos="";
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
|
||||
MASTER_USE_GTID=1;
|
||||
MASTER_USE_GTID=CURRENT_POS;
|
||||
--source include/start_slave.inc
|
||||
--sync_with_master
|
||||
SELECT * FROM t1;
|
||||
@@ -43,10 +43,10 @@ INSERT INTO t1 VALUES (2);
|
||||
--source include/show_binary_logs.inc
|
||||
|
||||
--connection server_2
|
||||
SET GLOBAL gtid_pos="";
|
||||
SET GLOBAL gtid_slave_pos="";
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
|
||||
MASTER_USE_GTID=1;
|
||||
MASTER_USE_GTID=CURRENT_POS;
|
||||
START SLAVE;
|
||||
--let $slave_io_errno= 1236
|
||||
--source include/wait_for_slave_io_error.inc
|
||||
@@ -62,17 +62,17 @@ SET sql_log_bin=0;
|
||||
call mtr.add_suppression('Could not find GTID state requested by slave in any binlog files');
|
||||
SET sql_log_bin=1;
|
||||
|
||||
--echo *** Test that we give error when explict @@gtid_pos=xxx that conflicts with what is in our binary log ***
|
||||
--echo *** Test that we give warning when explict @@gtid_slave_pos=xxx that conflicts with what is in our binary log ***
|
||||
--source include/stop_slave.inc
|
||||
|
||||
--connection server_1
|
||||
INSERT INTO t1 VALUES(3);
|
||||
|
||||
--connection server_2
|
||||
SET GLOBAL gtid_pos='0-1-3';
|
||||
SET GLOBAL gtid_slave_pos='0-1-3';
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
|
||||
MASTER_USE_GTID=1;
|
||||
MASTER_USE_GTID=CURRENT_POS;
|
||||
--source include/start_slave.inc
|
||||
--let $wait_condition= SELECT COUNT(*) = 3 FROM t1
|
||||
--source include/wait_condition.inc
|
||||
@@ -84,15 +84,14 @@ INSERT INTO t1 VALUES (4);
|
||||
|
||||
--connection server_2
|
||||
# Now add some local transactions that conflict with the GTID position
|
||||
# being set for GTID_POS.
|
||||
# being set for @@gtid_slave_pos.
|
||||
INSERT INTO t1 VALUES (10);
|
||||
DELETE FROM t1 WHERE a=10;
|
||||
--error ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG
|
||||
SET GLOBAL gtid_pos='0-1-4';
|
||||
SET GLOBAL gtid_slave_pos='0-1-4';
|
||||
|
||||
# Try again after RESET MASTER to remove the conflicting binlog.
|
||||
RESET MASTER;
|
||||
SET GLOBAL gtid_pos='0-1-4';
|
||||
SET GLOBAL gtid_slave_pos='0-1-4';
|
||||
START SLAVE;
|
||||
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1
|
||||
--source include/wait_condition.inc
|
||||
@@ -117,9 +116,9 @@ RESET MASTER;
|
||||
RESET MASTER;
|
||||
|
||||
--connection server_2
|
||||
SET GLOBAL gtid_pos='';
|
||||
SET GLOBAL gtid_slave_pos='';
|
||||
--replace_result $MASTER_MYPORT MASTER_PORT
|
||||
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$MASTER_MYPORT, master_user='root', master_use_gtid=1;
|
||||
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$MASTER_MYPORT, master_user='root', master_use_gtid=current_pos;
|
||||
--source include/start_slave.inc
|
||||
|
||||
--connection server_1
|
||||
@@ -145,22 +144,21 @@ INSERT INTO t1 VALUES (2);
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
|
||||
|
||||
--echo *** MDEV-4329: GTID_POS='' is not checked for conflicts with binlog ***
|
||||
--echo *** MDEV-4329: GTID_SLAVE_POS='' is not checked for conflicts with binlog ***
|
||||
|
||||
# Test starting the slave completely from scratch, deleting all tables and
|
||||
# replicating from the start of the master's binlog. This requires RESET
|
||||
# MASTER is run on the slave to avoid old junk in the binlog. The bug was
|
||||
# that the code did not catch the error of missing RESET MASTER when an
|
||||
# empty GTID_POS='' was specified.
|
||||
# empty GTID_SLAVE_POS='' was specified.
|
||||
|
||||
--connection server_2
|
||||
--source include/stop_slave.inc
|
||||
DROP TABLE t1;
|
||||
RESET SLAVE;
|
||||
--error ER_MASTER_GTID_POS_MISSING_DOMAIN
|
||||
SET GLOBAL gtid_pos="";
|
||||
SET GLOBAL gtid_slave_pos="";
|
||||
RESET MASTER;
|
||||
SET GLOBAL gtid_pos="";
|
||||
SET GLOBAL gtid_slave_pos="";
|
||||
|
||||
--source include/start_slave.inc
|
||||
--sync_with_master
|
||||
@@ -176,7 +174,7 @@ SET SQL_LOG_BIN=0;
|
||||
DROP TABLE t1;
|
||||
SET SQL_LOG_BIN=1;
|
||||
RESET SLAVE;
|
||||
SET GLOBAL gtid_pos="";
|
||||
SET GLOBAL gtid_slave_pos="";
|
||||
|
||||
--source include/start_slave.inc
|
||||
--sync_with_master
|
||||
@@ -197,7 +195,7 @@ START SLAVE;
|
||||
|
||||
# Going back to using GTID should fix things.
|
||||
STOP SLAVE IO_THREAD;
|
||||
CHANGE MASTER TO MASTER_USE_GTID=1;
|
||||
CHANGE MASTER TO MASTER_USE_GTID=CURRENT_POS;
|
||||
--source include/start_slave.inc
|
||||
|
||||
--connection server_1
|
||||
@@ -245,7 +243,7 @@ SELECT * FROM t1 ORDER BY a;
|
||||
--connection server_2
|
||||
--source include/stop_slave.inc
|
||||
RESET MASTER;
|
||||
SET GLOBAL gtid_pos="";
|
||||
SET GLOBAL gtid_slave_pos="";
|
||||
|
||||
--connection server_1
|
||||
RESET MASTER;
|
||||
@@ -260,25 +258,24 @@ INSERT INTO t1 VALUES (10); # Will be GTID 0-1-2
|
||||
SELECT * FROM t1;
|
||||
--let $value= query_get_value(SHOW SLAVE STATUS, "Using_Gtid", 1)
|
||||
eval SELECT '$value' AS Using_Gtid;
|
||||
--let $value= query_get_value(SHOW ALL SLAVES STATUS, "Gtid_Pos", 1)
|
||||
eval SELECT '$value' AS Gtid_Pos;
|
||||
--let $value= query_get_value(SHOW ALL SLAVES STATUS, "Gtid_Slave_Pos", 1)
|
||||
eval SELECT '$value' AS Gtid_Slave_Pos;
|
||||
|
||||
UPDATE t1 SET a=9 WHERE a=10;
|
||||
UPDATE t1 SET a=10 WHERE a=9;
|
||||
|
||||
--let $value= query_get_value(SHOW ALL SLAVES STATUS, "Gtid_Pos", 1)
|
||||
eval SELECT '$value' AS Gtid_Pos;
|
||||
--let $value= query_get_value(SHOW ALL SLAVES STATUS, "Gtid_Slave_Pos", 1)
|
||||
eval SELECT '$value' AS Gtid_Slave_Pos;
|
||||
|
||||
--source include/stop_slave.inc
|
||||
--error ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG
|
||||
SET GLOBAL gtid_pos='0-1-2';
|
||||
SET GLOBAL gtid_slave_pos='0-1-2';
|
||||
RESET MASTER;
|
||||
--let $value= query_get_value(SHOW ALL SLAVES STATUS, "Gtid_Pos", 1)
|
||||
eval SELECT '$value' AS Gtid_Pos;
|
||||
SET GLOBAL gtid_pos='0-1-2';
|
||||
--let $value= query_get_value(SHOW ALL SLAVES STATUS, "Gtid_Slave_Pos", 1)
|
||||
eval SELECT '$value' AS Gtid_Slave_Pos;
|
||||
SET GLOBAL gtid_slave_pos='0-1-2';
|
||||
--source include/start_slave.inc
|
||||
--let $value= query_get_value(SHOW ALL SLAVES STATUS, "Gtid_Pos", 1)
|
||||
eval SELECT '$value' AS Gtid_Pos;
|
||||
--let $value= query_get_value(SHOW ALL SLAVES STATUS, "Gtid_Slave_Pos", 1)
|
||||
eval SELECT '$value' AS Gtid_Slave_Pos;
|
||||
|
||||
# Clean up.
|
||||
--connection server_1
|
||||
|
||||
@@ -15,7 +15,7 @@ INSERT INTO t1 VALUES (1);
|
||||
--let $status_items= Master_Log_File,Using_Gtid
|
||||
--source include/show_slave_status.inc
|
||||
|
||||
CHANGE MASTER TO master_use_gtid=1;
|
||||
CHANGE MASTER TO master_use_gtid=current_pos;
|
||||
|
||||
# Now try to restart the slave mysqld server without starting the slave first
|
||||
# threads after the CHANGE MASTER.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
--source include/rpl_init.inc
|
||||
|
||||
--connection server_1
|
||||
ALTER TABLE mysql.rpl_slave_state ENGINE=InnoDB;
|
||||
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
|
||||
# Function to extract one GTID from a list.
|
||||
delimiter |;
|
||||
CREATE FUNCTION extract_gtid(d VARCHAR(100), s VARCHAR(100))
|
||||
@@ -37,12 +37,12 @@ START SLAVE UNTIL master_gtid_pos = "";
|
||||
--error ER_UNTIL_REQUIRES_USING_GTID
|
||||
START SLAVE UNTIL master_gtid_pos = "";
|
||||
|
||||
CHANGE MASTER TO master_use_gtid=1;
|
||||
CHANGE MASTER TO master_use_gtid=current_pos;
|
||||
|
||||
--connection server_1
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES(1);
|
||||
--let $gtid_pos=`SELECT @@GLOBAL.gtid_pos`
|
||||
--let $gtid_pos=`SELECT @@GLOBAL.gtid_binlog_pos`
|
||||
INSERT INTO t1 VALUES(2);
|
||||
|
||||
--connection server_2
|
||||
@@ -93,8 +93,8 @@ INSERT INTO t1 VALUES (3);
|
||||
SET gtid_domain_id = 2;
|
||||
CREATE TABLE t2 (a INT);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
--let $d1_point1= `SELECT extract_gtid("1", @@GLOBAL.gtid_pos)`
|
||||
--let $d2_point1= `SELECT extract_gtid("2", @@GLOBAL.gtid_pos)`
|
||||
--let $d1_point1= `SELECT extract_gtid("1", @@GLOBAL.gtid_binlog_pos)`
|
||||
--let $d2_point1= `SELECT extract_gtid("2", @@GLOBAL.gtid_binlog_pos)`
|
||||
FLUSH LOGS;
|
||||
SET gtid_domain_id = 1;
|
||||
INSERT INTO t1 VALUES (4);
|
||||
@@ -103,15 +103,15 @@ INSERT INTO t2 VALUES (4);
|
||||
FLUSH LOGS;
|
||||
SET gtid_domain_id = 1;
|
||||
INSERT INTO t1 VALUES (5);
|
||||
--let $d1_point2= `SELECT extract_gtid("1", @@GLOBAL.gtid_pos)`
|
||||
--let $d2_point2= `SELECT extract_gtid("2", @@GLOBAL.gtid_pos)`
|
||||
--let $d1_point2= `SELECT extract_gtid("1", @@GLOBAL.gtid_binlog_pos)`
|
||||
--let $d2_point2= `SELECT extract_gtid("2", @@GLOBAL.gtid_binlog_pos)`
|
||||
SET gtid_domain_id = 2;
|
||||
INSERT INTO t2 VALUES (5);
|
||||
FLUSH LOGS;
|
||||
SET gtid_domain_id = 1;
|
||||
INSERT INTO t1 VALUES (6);
|
||||
--let $d1_point3= `SELECT extract_gtid("1", @@GLOBAL.gtid_pos)`
|
||||
--let $d2_point3= `SELECT extract_gtid("2", @@GLOBAL.gtid_pos)`
|
||||
--let $d1_point3= `SELECT extract_gtid("1", @@GLOBAL.gtid_binlog_pos)`
|
||||
--let $d2_point3= `SELECT extract_gtid("2", @@GLOBAL.gtid_binlog_pos)`
|
||||
SET gtid_domain_id = 2;
|
||||
INSERT INTO t2 VALUES (6);
|
||||
SET gtid_domain_id = 0;
|
||||
@@ -170,7 +170,7 @@ SELECT * FROM t1 ORDER BY a;
|
||||
|
||||
--connection server_1
|
||||
CREATE TABLE t3 (a INT);
|
||||
--let $until_condition=`SELECT @@GLOBAL.gtid_pos`
|
||||
--let $until_condition=`SELECT @@GLOBAL.gtid_binlog_pos`
|
||||
DROP TABLE t3;
|
||||
--save_master_pos
|
||||
|
||||
@@ -187,7 +187,7 @@ SHOW CREATE TABLE t3;
|
||||
--source include/stop_slave.inc
|
||||
RESET SLAVE ALL;
|
||||
RESET MASTER;
|
||||
SET GLOBAL gtid_pos='';
|
||||
SET GLOBAL gtid_slave_pos='';
|
||||
|
||||
--connection server_1
|
||||
# Do it once to compute the right GTID, then throw it away and do it again
|
||||
@@ -195,7 +195,7 @@ SET GLOBAL gtid_pos='';
|
||||
RESET MASTER;
|
||||
INSERT INTO t1 VALUES (10);
|
||||
INSERT INTO t1 VALUES (11);
|
||||
--let $until_condition=`SELECT @@GLOBAL.gtid_pos`
|
||||
--let $until_condition=`SELECT @@GLOBAL.gtid_binlog_pos`
|
||||
INSERT INTO t1 VALUES (12);
|
||||
DELETE FROM t1 WHERE a >= 10;
|
||||
|
||||
@@ -205,7 +205,7 @@ INSERT INTO t1 VALUES (10);
|
||||
--connection server_2
|
||||
--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_use_gtid = 1;
|
||||
master_user = "root", master_use_gtid = current_pos;
|
||||
eval START SLAVE UNTIL master_gtid_pos = '$until_condition';
|
||||
--source include/wait_for_slave_to_start.inc
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
call mtr.add_suppression('Attempting backtrace');
|
||||
call mtr.add_suppression("Recovery from master pos .* and file master-bin.000001");
|
||||
# Use innodb so we do not get "table should be repaired" issues.
|
||||
ALTER TABLE mysql.rpl_slave_state ENGINE=InnoDB;
|
||||
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
|
||||
flush tables;
|
||||
CREATE TABLE t1(a INT, PRIMARY KEY(a)) engine=innodb;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user