summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/include/save_master_gtid.inc28
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_basic.result5
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_crash.result14
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_nobinlog.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_startpos.result12
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_stop_start.result4
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_basic.test13
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_crash.test28
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test12
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_nobinlog.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_startpos.test24
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_stop_start.test8
13 files changed, 118 insertions, 48 deletions
diff --git a/mysql-test/include/save_master_gtid.inc b/mysql-test/include/save_master_gtid.inc
new file mode 100644
index 00000000000..4fd0d3266a2
--- /dev/null
+++ b/mysql-test/include/save_master_gtid.inc
@@ -0,0 +1,28 @@
+# ==== Purpose ====
+#
+# Save the current binlog GTID position on the master, to be used
+# with include/sync_with_master_gtid.inc.
+#
+#
+# ==== Usage ====
+#
+# [--let $rpl_debug= 1]
+# --source include/save_master_gtid.inc
+#
+# Parameters:
+# $rpl_debug
+# See include/rpl_init.inc
+
+
+--let $include_filename= save_master_gtid.inc
+--source include/begin_include_file.inc
+
+--let $master_pos= `SELECT @@gtid_binlog_pos`
+
+if ($rpl_debug)
+{
+ --echo save_master_gtid saved master_pos='$master_pos'
+}
+
+--let $include_filename= save_master_gtid.inc
+--source include/end_include_file.inc
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_basic.result b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
index d15de315914..49891e1abd3 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_basic.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
@@ -103,9 +103,11 @@ BEGIN;
INSERT INTO t2 VALUES (6, "i6b");
INSERT INTO t2 VALUES (7, "i7b");
COMMIT;
+include/save_master_gtid.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_4,
MASTER_USE_GTID=CURRENT_POS;
include/start_slave.inc
+include/sync_with_master_gtid.inc
SELECT * FROM t2 ORDER BY a;
a b
1 i1
@@ -116,6 +118,7 @@ a b
6 i6b
7 i7b
*** Now change everything back to what it was, to make rpl_end.inc happy
+include/sync_with_master_gtid.inc
include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_MYPORT;
include/start_slave.inc
@@ -123,6 +126,7 @@ include/wait_for_slave_to_start.inc
include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SLAVE_MYPORT;
include/start_slave.inc
+include/sync_with_master_gtid.inc
include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_3;
include/start_slave.inc
@@ -196,6 +200,7 @@ SET GLOBAL gtid_binlog_state = @old_state;
CREATE TABLE t1 (a INT PRIMARY KEY);
SET gtid_seq_no=100;
INSERT INTO t1 VALUES (1);
+include/save_master_gtid.inc
include/start_slave.inc
include/sync_with_master_gtid.inc
SELECT * FROM t1;
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_crash.result b/mysql-test/suite/rpl/r/rpl_gtid_crash.result
index 9c3b9a95323..986c9d30773 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_crash.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_crash.result
@@ -12,10 +12,14 @@ MASTER_USE_GTID=CURRENT_POS;
INSERT INTO t1 VALUES (2,1);
INSERT INTO t1 VALUES (3,1);
include/start_slave.inc
+include/save_master_gtid.inc
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
SELECT 1;
Got one of the listed errors
+include/sync_with_master_gtid.inc
INSERT INTO t1 VALUES (1000, 3);
+include/save_master_gtid.inc
+include/sync_with_master_gtid.inc
DROP TABLE t1;
*** Test crashing the master mysqld and check that binlog state is recovered. ***
include/stop_slave.inc
@@ -64,22 +68,32 @@ include/stop_slave.inc
SET GLOBAL debug_dbug="+d,inject_crash_before_write_rpl_slave_state";
START SLAVE;
INSERT INTO t1 VALUES (4);
+include/save_master_gtid.inc
+include/sync_with_master_gtid.inc
include/stop_slave.inc
SET GLOBAL debug_dbug="+d,crash_commit_before";
START SLAVE;
INSERT INTO t1 VALUES (5);
+include/save_master_gtid.inc
+include/sync_with_master_gtid.inc
include/stop_slave.inc
SET GLOBAL debug_dbug="+d,crash_commit_after";
START SLAVE;
INSERT INTO t1 VALUES (6);
+include/save_master_gtid.inc
+include/sync_with_master_gtid.inc
include/stop_slave.inc
SET GLOBAL debug_dbug="+d,inject_crash_before_flush_rli";
START SLAVE;
INSERT INTO t1 VALUES (7);
+include/save_master_gtid.inc
+include/sync_with_master_gtid.inc
include/stop_slave.inc
SET GLOBAL debug_dbug="+d,inject_crash_after_flush_rli";
START SLAVE;
INSERT INTO t1 VALUES (8);
+include/save_master_gtid.inc
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a
1
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result b/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result
index 98a8c0b2d87..385a374888c 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result
@@ -57,6 +57,7 @@ include/stop_slave.inc
RESET MASTER;
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (4);
+include/save_master_gtid.inc
SET sql_log_bin = 0;
INSERT INTO t1 VALUES (2);
SET sql_log_bin = 1;
@@ -84,6 +85,7 @@ Warning 1948 Specified value for @@gtid_slave_pos contains no value for replicat
RESET MASTER;
SET GLOBAL gtid_slave_pos = "0-1-1";
START SLAVE;
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a
1
@@ -93,6 +95,7 @@ a
*** MDEV-4688: Empty value of @@GLOBAL.gtid_slave_pos ***
include/stop_slave.inc
INSERT INTO t1 VALUES (5);
+include/save_master_gtid.inc
SET @old_dbug= @@GLOBAL.debug_dbug;
SET GLOBAL debug_dbug="+d,dummy_disable_default_dbug_output";
SET GLOBAL debug_dbug="+d,gtid_fail_after_record_gtid";
@@ -112,6 +115,7 @@ a
4
SET GLOBAL debug_dbug= @old_dbug;
START SLAVE SQL_THREAD;
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a
1
@@ -136,6 +140,8 @@ SET GLOBAL gtid_slave_pos = "0-1-3";
START SLAVE;
include/wait_for_slave_to_start.inc
INSERT INTO t1 VALUES (6);
+include/save_master_gtid.inc
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a
1
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_nobinlog.result b/mysql-test/suite/rpl/r/rpl_gtid_nobinlog.result
index 7f27f2bdeee..6ffd9569e1a 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_nobinlog.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_nobinlog.result
@@ -23,6 +23,7 @@ START SLAVE;
include/wait_for_slave_to_start.inc
INSERT INTO t1 VALUES (3, 2);
INSERT INTO t1 VALUES (4, 2);
+include/save_master_gtid.inc
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
@@ -31,6 +32,7 @@ slave-bin.000001 # Query # # COMMIT
slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4, 2)
slave-bin.000001 # Query # # COMMIT
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a b
1 1
@@ -41,9 +43,11 @@ include/stop_slave.inc
RESET SLAVE;
INSERT INTO t1 VALUES (5, 1);
INSERT INTO t1 VALUES (6, 1);
+include/save_master_gtid.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
master_use_gtid = current_pos;
START SLAVE;
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a b
1 1
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_startpos.result b/mysql-test/suite/rpl/r/rpl_gtid_startpos.result
index 9be5903b2e9..8043e2eb5b8 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_startpos.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_startpos.result
@@ -43,10 +43,12 @@ SET sql_log_bin=1;
*** Test that we give warning when explict @@gtid_slave_pos=xxx that conflicts with what is in our binary log ***
include/stop_slave.inc
INSERT INTO t1 VALUES(3);
+include/save_master_gtid.inc
SET GLOBAL gtid_slave_pos='0-1-3';
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_USE_GTID=CURRENT_POS;
include/start_slave.inc
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER by a;
a
1
@@ -54,6 +56,7 @@ a
3
include/stop_slave.inc
INSERT INTO t1 VALUES (4);
+include/save_master_gtid.inc
INSERT INTO t1 VALUES (10);
DELETE FROM t1 WHERE a=10;
SET GLOBAL gtid_slave_pos='0-1-4';
@@ -62,6 +65,7 @@ Warning 1947 Specified GTID 0-1-4 conflicts with the binary log which contains a
RESET MASTER;
SET GLOBAL gtid_slave_pos='0-1-4';
START SLAVE;
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER by a;
a
1
@@ -125,6 +129,8 @@ STOP SLAVE IO_THREAD;
CHANGE MASTER TO MASTER_USE_GTID=CURRENT_POS;
include/start_slave.inc
INSERT INTO t1 VALUES(3);
+include/save_master_gtid.inc
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a
1
@@ -136,6 +142,8 @@ SET SQL_LOG_BIN=1;
*** Test reconnecting slave with GTID after purge logs on master. ***
FLUSH LOGS;
INSERT INTO t1 VALUES (4);
+include/save_master_gtid.inc
+include/sync_with_master_gtid.inc
include/stop_slave.inc
FLUSH LOGS;
FLUSH LOGS;
@@ -144,8 +152,10 @@ show binary logs;
Log_name File_size
master-bin.000004 #
INSERT INTO t1 VALUES (5);
+include/save_master_gtid.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT;
include/start_slave.inc
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a
1
@@ -160,7 +170,9 @@ SET GLOBAL gtid_slave_pos="";
RESET MASTER;
TRUNCATE TABLE t1;
INSERT INTO t1 VALUES (10);
+include/save_master_gtid.inc
include/start_slave.inc
+include/sync_with_master_gtid.inc
SELECT * FROM t1;
a
10
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result
index 61c2fc0a0e9..ddcbaf8dffd 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result
@@ -14,10 +14,12 @@ master-bin.000002 #
INSERT INTO t1 VALUES (2);
FLUSH LOGS;
INSERT INTO t1 VALUES (3);
+include/save_master_gtid.inc
show binary logs;
Log_name File_size
master-bin.000002 #
master-bin.000003 #
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a
1
@@ -43,6 +45,8 @@ master-bin.000003 #
master-bin.000004 #
master-bin.000005 #
INSERT INTO t1 VALUES(5);
+include/save_master_gtid.inc
+include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a
1
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_basic.test b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
index dff7609cb99..b8453766195 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_basic.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_basic.test
@@ -101,15 +101,14 @@ BEGIN;
INSERT INTO t2 VALUES (6, "i6b");
INSERT INTO t2 VALUES (7, "i7b");
COMMIT;
+--source include/save_master_gtid.inc
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=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
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t2 ORDER BY a;
--echo *** Now change everything back to what it was, to make rpl_end.inc happy
@@ -118,8 +117,7 @@ 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
# server_1, which is (deliberately) missing that transaction.
---let $wait_condition= SELECT COUNT(*) = 7 FROM t2
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
--source include/stop_slave.inc
--replace_result $MASTER_MYPORT MASTER_MYPORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT;
@@ -131,8 +129,7 @@ connection server_3;
--replace_result $SLAVE_MYPORT SLAVE_MYPORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SLAVE_MYPORT;
--source include/start_slave.inc
---let $wait_condition= SELECT COUNT(*) = 7 FROM t2
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
connection server_4;
--source include/stop_slave.inc
@@ -192,7 +189,7 @@ SET GLOBAL gtid_binlog_state = @old_state;
CREATE TABLE t1 (a INT PRIMARY KEY);
SET gtid_seq_no=100;
INSERT INTO t1 VALUES (1);
---let $master_pos= `SELECT @@GLOBAL.gtid_binlog_pos`
+--source include/save_master_gtid.inc
--connection server_2
--source include/start_slave.inc
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_crash.test b/mysql-test/suite/rpl/t/rpl_gtid_crash.test
index 18a391aa100..940be858902 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_crash.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_crash.test
@@ -46,6 +46,7 @@ while ($1)
dec $1;
}
--enable_query_log
+--source include/save_master_gtid.inc
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
--error 2006,2013
@@ -60,15 +61,14 @@ EOF
--source include/wait_until_connected_again.inc
--connection server_2
---let $wait_condition= SELECT COUNT(*) = 200 FROM t1 WHERE b=2
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
--connection server_1
INSERT INTO t1 VALUES (1000, 3);
+--source include/save_master_gtid.inc
--connection server_2
---let $wait_condition= SELECT COUNT(*) = 1 FROM t1 WHERE b=3
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
--connection server_1
DROP TABLE t1;
@@ -141,6 +141,7 @@ START SLAVE;
--connection server_1
INSERT INTO t1 VALUES (4);
+--source include/save_master_gtid.inc
--connection server_2
--source include/wait_until_disconnected.inc
@@ -152,8 +153,7 @@ EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
---let $wait_condition= SELECT COUNT(*) = 4 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
# Crash the slave just before committing.
--source include/stop_slave.inc
@@ -165,6 +165,7 @@ START SLAVE;
--connection server_1
INSERT INTO t1 VALUES (5);
+--source include/save_master_gtid.inc
--connection server_2
--source include/wait_until_disconnected.inc
@@ -176,8 +177,7 @@ EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
---let $wait_condition= SELECT COUNT(*) = 5 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
# Crash the slave just after committing.
--source include/stop_slave.inc
@@ -189,6 +189,7 @@ START SLAVE;
--connection server_1
INSERT INTO t1 VALUES (6);
+--source include/save_master_gtid.inc
--connection server_2
--source include/wait_until_disconnected.inc
@@ -200,8 +201,7 @@ EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
---let $wait_condition= SELECT COUNT(*) = 6 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
# Crash the slave just before updating relay-log.info
--source include/stop_slave.inc
@@ -213,6 +213,7 @@ START SLAVE;
--connection server_1
INSERT INTO t1 VALUES (7);
+--source include/save_master_gtid.inc
--connection server_2
--source include/wait_until_disconnected.inc
@@ -224,8 +225,7 @@ EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
---let $wait_condition= SELECT COUNT(*) = 7 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
# Crash the slave just after updating relay-log.info
--source include/stop_slave.inc
@@ -237,6 +237,7 @@ START SLAVE;
--connection server_1
INSERT INTO t1 VALUES (8);
+--source include/save_master_gtid.inc
--connection server_2
--source include/wait_until_disconnected.inc
@@ -248,8 +249,7 @@ EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
---let $wait_condition= SELECT COUNT(*) = 8 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
# Check that everything was replicated correctly.
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test b/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test
index d2a7445c0bc..31492b7c096 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test
@@ -79,6 +79,7 @@ RESET MASTER;
INSERT INTO t1 VALUES (2);
# And this will be GTID 0-1-2
INSERT INTO t1 VALUES (4);
+--source include/save_master_gtid.inc
--connection slave
SET sql_log_bin = 0;
@@ -110,8 +111,7 @@ RESET MASTER;
SET GLOBAL gtid_slave_pos = "0-1-1";
START SLAVE;
---let $wait_condition= SELECT COUNT(*) = 4 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
--echo *** MDEV-4688: Empty value of @@GLOBAL.gtid_slave_pos ***
@@ -125,6 +125,7 @@ SELECT * FROM t1 ORDER BY a;
--connection master
# This will be GTID 0-1-3
INSERT INTO t1 VALUES (5);
+--source include/save_master_gtid.inc
--connection slave
SET @old_dbug= @@GLOBAL.debug_dbug;
@@ -141,8 +142,7 @@ SELECT @@GLOBAL.gtid_slave_pos;
SELECT * FROM t1 ORDER BY a;
SET GLOBAL debug_dbug= @old_dbug;
START SLAVE SQL_THREAD;
---let $wait_condition= SELECT COUNT(*) = 5 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
@@ -167,10 +167,10 @@ START SLAVE;
--connection master
INSERT INTO t1 VALUES (6);
+--source include/save_master_gtid.inc
--connection slave
---let $wait_condition= SELECT COUNT(*) = 6 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_nobinlog.test b/mysql-test/suite/rpl/t/rpl_gtid_nobinlog.test
index 1e33520efb5..a5caebf0276 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_nobinlog.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_nobinlog.test
@@ -32,12 +32,12 @@ START SLAVE;
--connection server_2
INSERT INTO t1 VALUES (3, 2);
INSERT INTO t1 VALUES (4, 2);
+--source include/save_master_gtid.inc
--source include/show_binlog_events.inc
--connection server_1
---let $wait_condition= SELECT COUNT(*) = 4 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
@@ -45,14 +45,14 @@ SELECT * FROM t1 ORDER BY a;
RESET SLAVE;
INSERT INTO t1 VALUES (5, 1);
INSERT INTO t1 VALUES (6, 1);
+--source include/save_master_gtid.inc
--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 = current_pos;
START SLAVE;
---let $wait_condition= SELECT COUNT(*) = 6 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_startpos.test b/mysql-test/suite/rpl/t/rpl_gtid_startpos.test
index 0797eead0ee..abe6b94ee7a 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_startpos.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_startpos.test
@@ -67,6 +67,7 @@ SET sql_log_bin=1;
--connection server_1
INSERT INTO t1 VALUES(3);
+--source include/save_master_gtid.inc
--connection server_2
SET GLOBAL gtid_slave_pos='0-1-3';
@@ -74,13 +75,13 @@ SET GLOBAL gtid_slave_pos='0-1-3';
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
MASTER_USE_GTID=CURRENT_POS;
--source include/start_slave.inc
---let $wait_condition= SELECT COUNT(*) = 3 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER by a;
--source include/stop_slave.inc
--connection server_1
INSERT INTO t1 VALUES (4);
+--source include/save_master_gtid.inc
--connection server_2
# Now add some local transactions that conflict with the GTID position
@@ -93,8 +94,7 @@ SET GLOBAL gtid_slave_pos='0-1-4';
RESET MASTER;
SET GLOBAL gtid_slave_pos='0-1-4';
START SLAVE;
---let $wait_condition= SELECT COUNT(*) = 4 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER by a;
--connection server_1
@@ -200,10 +200,10 @@ CHANGE MASTER TO MASTER_USE_GTID=CURRENT_POS;
--connection server_1
INSERT INTO t1 VALUES(3);
+--source include/save_master_gtid.inc
--connection server_2
---let $wait_condition= SELECT COUNT(*) = 3 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
SET SQL_LOG_BIN=0;
call mtr.add_suppression("Slave: Table 't1' already exists error.* 1050");
@@ -215,10 +215,10 @@ SET SQL_LOG_BIN=1;
--connection server_1
FLUSH LOGS;
INSERT INTO t1 VALUES (4);
+--source include/save_master_gtid.inc
--connection server_2
---let $wait_condition= SELECT COUNT(*) = 4 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
--source include/stop_slave.inc
--connection server_1
@@ -228,13 +228,13 @@ FLUSH LOGS;
--source include/wait_for_purge.inc
--source include/show_binary_logs.inc
INSERT INTO t1 VALUES (5);
+--source include/save_master_gtid.inc
--connection server_2
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT;
--source include/start_slave.inc
---let $wait_condition= SELECT COUNT(*) = 5 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
@@ -249,11 +249,11 @@ SET GLOBAL gtid_slave_pos="";
RESET MASTER;
TRUNCATE TABLE t1;
INSERT INTO t1 VALUES (10); # Will be GTID 0-1-2
+--source include/save_master_gtid.inc
--connection server_2
--source include/start_slave.inc
---let $wait_condition= SELECT COUNT(*) = 1 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1;
--let $value= query_get_value(SHOW SLAVE STATUS, "Using_Gtid", 1)
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test
index 925095c852b..1f0532f9922 100644
--- a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test
+++ b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test
@@ -39,6 +39,7 @@ FLUSH LOGS;
INSERT INTO t1 VALUES (2);
FLUSH LOGS;
INSERT INTO t1 VALUES (3);
+--source include/save_master_gtid.inc
--source include/show_binary_logs.inc
# Let the slave mysqld server start again.
@@ -50,8 +51,7 @@ EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
---let $wait_condition= SELECT COUNT(*) = 3 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
@@ -88,10 +88,10 @@ SHOW BINLOG EVENTS IN 'master-bin.000005' LIMIT 1,1;
--source include/show_binary_logs.inc
INSERT INTO t1 VALUES(5);
+--source include/save_master_gtid.inc
--connection server_2
---let $wait_condition= SELECT COUNT(*) = 5 FROM t1
---source include/wait_condition.inc
+--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
--echo *** Test that @@gtid_slave_pos and @@gtid_current_pos are correctly loaded even if slave threads have not started. ***