Commit 7bb022f3 authored by unknown's avatar unknown

MDEV-4726: Race in mysql-test/suite/rpl/t/rpl_gtid_stop_start.test

Some GTID test cases were using include/wait_condition.inc with a
condition like SELECT COUNT(*)=4 FROM t1 to wait for the slave to
catch up with the master. This causes races and test failures, as the
changes to the tables become visible at the COMMIT of the SQL thread
(or even before in case of MyISAM), but the changes to
@@gtid_slave_pos only become visible a little bit after the COMMIT.

Now that we have MASTER_GTID_WAIT(), just use that to sync up in a
GTID-friendly way, wrapped in nice include/save_master_gtid.inc and
include/sync_with_master_gtid.inc scripts.
parent 4e6606ac
# ==== 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
...@@ -103,9 +103,11 @@ BEGIN; ...@@ -103,9 +103,11 @@ BEGIN;
INSERT INTO t2 VALUES (6, "i6b"); INSERT INTO t2 VALUES (6, "i6b");
INSERT INTO t2 VALUES (7, "i7b"); INSERT INTO t2 VALUES (7, "i7b");
COMMIT; COMMIT;
include/save_master_gtid.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_4, CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_4,
MASTER_USE_GTID=CURRENT_POS; MASTER_USE_GTID=CURRENT_POS;
include/start_slave.inc include/start_slave.inc
include/sync_with_master_gtid.inc
SELECT * FROM t2 ORDER BY a; SELECT * FROM t2 ORDER BY a;
a b a b
1 i1 1 i1
...@@ -116,6 +118,7 @@ a b ...@@ -116,6 +118,7 @@ a b
6 i6b 6 i6b
7 i7b 7 i7b
*** Now change everything back to what it was, to make rpl_end.inc happy *** Now change everything back to what it was, to make rpl_end.inc happy
include/sync_with_master_gtid.inc
include/stop_slave.inc include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_MYPORT; CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_MYPORT;
include/start_slave.inc include/start_slave.inc
...@@ -123,6 +126,7 @@ include/wait_for_slave_to_start.inc ...@@ -123,6 +126,7 @@ include/wait_for_slave_to_start.inc
include/stop_slave.inc include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SLAVE_MYPORT; CHANGE MASTER TO master_host = '127.0.0.1', master_port = SLAVE_MYPORT;
include/start_slave.inc include/start_slave.inc
include/sync_with_master_gtid.inc
include/stop_slave.inc include/stop_slave.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_3; CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_3;
include/start_slave.inc include/start_slave.inc
...@@ -196,6 +200,7 @@ SET GLOBAL gtid_binlog_state = @old_state; ...@@ -196,6 +200,7 @@ SET GLOBAL gtid_binlog_state = @old_state;
CREATE TABLE t1 (a INT PRIMARY KEY); CREATE TABLE t1 (a INT PRIMARY KEY);
SET gtid_seq_no=100; SET gtid_seq_no=100;
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
include/save_master_gtid.inc
include/start_slave.inc include/start_slave.inc
include/sync_with_master_gtid.inc include/sync_with_master_gtid.inc
SELECT * FROM t1; SELECT * FROM t1;
......
...@@ -12,10 +12,14 @@ MASTER_USE_GTID=CURRENT_POS; ...@@ -12,10 +12,14 @@ MASTER_USE_GTID=CURRENT_POS;
INSERT INTO t1 VALUES (2,1); INSERT INTO t1 VALUES (2,1);
INSERT INTO t1 VALUES (3,1); INSERT INTO t1 VALUES (3,1);
include/start_slave.inc include/start_slave.inc
include/save_master_gtid.inc
SET SESSION debug_dbug="+d,crash_dispatch_command_before"; SET SESSION debug_dbug="+d,crash_dispatch_command_before";
SELECT 1; SELECT 1;
Got one of the listed errors Got one of the listed errors
include/sync_with_master_gtid.inc
INSERT INTO t1 VALUES (1000, 3); INSERT INTO t1 VALUES (1000, 3);
include/save_master_gtid.inc
include/sync_with_master_gtid.inc
DROP TABLE t1; DROP TABLE t1;
*** Test crashing the master mysqld and check that binlog state is recovered. *** *** Test crashing the master mysqld and check that binlog state is recovered. ***
include/stop_slave.inc include/stop_slave.inc
...@@ -64,22 +68,32 @@ include/stop_slave.inc ...@@ -64,22 +68,32 @@ include/stop_slave.inc
SET GLOBAL debug_dbug="+d,inject_crash_before_write_rpl_slave_state"; SET GLOBAL debug_dbug="+d,inject_crash_before_write_rpl_slave_state";
START SLAVE; START SLAVE;
INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (4);
include/save_master_gtid.inc
include/sync_with_master_gtid.inc
include/stop_slave.inc include/stop_slave.inc
SET GLOBAL debug_dbug="+d,crash_commit_before"; SET GLOBAL debug_dbug="+d,crash_commit_before";
START SLAVE; START SLAVE;
INSERT INTO t1 VALUES (5); INSERT INTO t1 VALUES (5);
include/save_master_gtid.inc
include/sync_with_master_gtid.inc
include/stop_slave.inc include/stop_slave.inc
SET GLOBAL debug_dbug="+d,crash_commit_after"; SET GLOBAL debug_dbug="+d,crash_commit_after";
START SLAVE; START SLAVE;
INSERT INTO t1 VALUES (6); INSERT INTO t1 VALUES (6);
include/save_master_gtid.inc
include/sync_with_master_gtid.inc
include/stop_slave.inc include/stop_slave.inc
SET GLOBAL debug_dbug="+d,inject_crash_before_flush_rli"; SET GLOBAL debug_dbug="+d,inject_crash_before_flush_rli";
START SLAVE; START SLAVE;
INSERT INTO t1 VALUES (7); INSERT INTO t1 VALUES (7);
include/save_master_gtid.inc
include/sync_with_master_gtid.inc
include/stop_slave.inc include/stop_slave.inc
SET GLOBAL debug_dbug="+d,inject_crash_after_flush_rli"; SET GLOBAL debug_dbug="+d,inject_crash_after_flush_rli";
START SLAVE; START SLAVE;
INSERT INTO t1 VALUES (8); INSERT INTO t1 VALUES (8);
include/save_master_gtid.inc
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a a
1 1
......
...@@ -57,6 +57,7 @@ include/stop_slave.inc ...@@ -57,6 +57,7 @@ include/stop_slave.inc
RESET MASTER; RESET MASTER;
INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (4);
include/save_master_gtid.inc
SET sql_log_bin = 0; SET sql_log_bin = 0;
INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (2);
SET sql_log_bin = 1; SET sql_log_bin = 1;
...@@ -84,6 +85,7 @@ Warning 1948 Specified value for @@gtid_slave_pos contains no value for replicat ...@@ -84,6 +85,7 @@ Warning 1948 Specified value for @@gtid_slave_pos contains no value for replicat
RESET MASTER; RESET MASTER;
SET GLOBAL gtid_slave_pos = "0-1-1"; SET GLOBAL gtid_slave_pos = "0-1-1";
START SLAVE; START SLAVE;
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a a
1 1
...@@ -93,6 +95,7 @@ a ...@@ -93,6 +95,7 @@ a
*** MDEV-4688: Empty value of @@GLOBAL.gtid_slave_pos *** *** MDEV-4688: Empty value of @@GLOBAL.gtid_slave_pos ***
include/stop_slave.inc include/stop_slave.inc
INSERT INTO t1 VALUES (5); INSERT INTO t1 VALUES (5);
include/save_master_gtid.inc
SET @old_dbug= @@GLOBAL.debug_dbug; SET @old_dbug= @@GLOBAL.debug_dbug;
SET GLOBAL debug_dbug="+d,dummy_disable_default_dbug_output"; SET GLOBAL debug_dbug="+d,dummy_disable_default_dbug_output";
SET GLOBAL debug_dbug="+d,gtid_fail_after_record_gtid"; SET GLOBAL debug_dbug="+d,gtid_fail_after_record_gtid";
...@@ -112,6 +115,7 @@ a ...@@ -112,6 +115,7 @@ a
4 4
SET GLOBAL debug_dbug= @old_dbug; SET GLOBAL debug_dbug= @old_dbug;
START SLAVE SQL_THREAD; START SLAVE SQL_THREAD;
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a a
1 1
...@@ -136,6 +140,8 @@ SET GLOBAL gtid_slave_pos = "0-1-3"; ...@@ -136,6 +140,8 @@ SET GLOBAL gtid_slave_pos = "0-1-3";
START SLAVE; START SLAVE;
include/wait_for_slave_to_start.inc include/wait_for_slave_to_start.inc
INSERT INTO t1 VALUES (6); INSERT INTO t1 VALUES (6);
include/save_master_gtid.inc
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a a
1 1
......
...@@ -23,6 +23,7 @@ START SLAVE; ...@@ -23,6 +23,7 @@ START SLAVE;
include/wait_for_slave_to_start.inc include/wait_for_slave_to_start.inc
INSERT INTO t1 VALUES (3, 2); INSERT INTO t1 VALUES (3, 2);
INSERT INTO t1 VALUES (4, 2); INSERT INTO t1 VALUES (4, 2);
include/save_master_gtid.inc
show binlog events from <binlog_start>; show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
...@@ -31,6 +32,7 @@ slave-bin.000001 # Query # # COMMIT ...@@ -31,6 +32,7 @@ slave-bin.000001 # Query # # COMMIT
slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4, 2) slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4, 2)
slave-bin.000001 # Query # # COMMIT slave-bin.000001 # Query # # COMMIT
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a b a b
1 1 1 1
...@@ -41,9 +43,11 @@ include/stop_slave.inc ...@@ -41,9 +43,11 @@ include/stop_slave.inc
RESET SLAVE; RESET SLAVE;
INSERT INTO t1 VALUES (5, 1); INSERT INTO t1 VALUES (5, 1);
INSERT INTO t1 VALUES (6, 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, CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
master_use_gtid = current_pos; master_use_gtid = current_pos;
START SLAVE; START SLAVE;
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a b a b
1 1 1 1
......
...@@ -43,10 +43,12 @@ SET sql_log_bin=1; ...@@ -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 *** *** Test that we give warning when explict @@gtid_slave_pos=xxx that conflicts with what is in our binary log ***
include/stop_slave.inc include/stop_slave.inc
INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(3);
include/save_master_gtid.inc
SET GLOBAL gtid_slave_pos='0-1-3'; SET GLOBAL gtid_slave_pos='0-1-3';
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT, CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_USE_GTID=CURRENT_POS; MASTER_USE_GTID=CURRENT_POS;
include/start_slave.inc include/start_slave.inc
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER by a; SELECT * FROM t1 ORDER by a;
a a
1 1
...@@ -54,6 +56,7 @@ a ...@@ -54,6 +56,7 @@ a
3 3
include/stop_slave.inc include/stop_slave.inc
INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (4);
include/save_master_gtid.inc
INSERT INTO t1 VALUES (10); INSERT INTO t1 VALUES (10);
DELETE FROM t1 WHERE a=10; DELETE FROM t1 WHERE a=10;
SET GLOBAL gtid_slave_pos='0-1-4'; 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 ...@@ -62,6 +65,7 @@ Warning 1947 Specified GTID 0-1-4 conflicts with the binary log which contains a
RESET MASTER; RESET MASTER;
SET GLOBAL gtid_slave_pos='0-1-4'; SET GLOBAL gtid_slave_pos='0-1-4';
START SLAVE; START SLAVE;
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER by a; SELECT * FROM t1 ORDER by a;
a a
1 1
...@@ -125,6 +129,8 @@ STOP SLAVE IO_THREAD; ...@@ -125,6 +129,8 @@ STOP SLAVE IO_THREAD;
CHANGE MASTER TO MASTER_USE_GTID=CURRENT_POS; CHANGE MASTER TO MASTER_USE_GTID=CURRENT_POS;
include/start_slave.inc include/start_slave.inc
INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(3);
include/save_master_gtid.inc
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a a
1 1
...@@ -136,6 +142,8 @@ SET SQL_LOG_BIN=1; ...@@ -136,6 +142,8 @@ SET SQL_LOG_BIN=1;
*** Test reconnecting slave with GTID after purge logs on master. *** *** Test reconnecting slave with GTID after purge logs on master. ***
FLUSH LOGS; FLUSH LOGS;
INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (4);
include/save_master_gtid.inc
include/sync_with_master_gtid.inc
include/stop_slave.inc include/stop_slave.inc
FLUSH LOGS; FLUSH LOGS;
FLUSH LOGS; FLUSH LOGS;
...@@ -144,8 +152,10 @@ show binary logs; ...@@ -144,8 +152,10 @@ show binary logs;
Log_name File_size Log_name File_size
master-bin.000004 # master-bin.000004 #
INSERT INTO t1 VALUES (5); INSERT INTO t1 VALUES (5);
include/save_master_gtid.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT; CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT;
include/start_slave.inc include/start_slave.inc
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a a
1 1
...@@ -160,7 +170,9 @@ SET GLOBAL gtid_slave_pos=""; ...@@ -160,7 +170,9 @@ SET GLOBAL gtid_slave_pos="";
RESET MASTER; RESET MASTER;
TRUNCATE TABLE t1; TRUNCATE TABLE t1;
INSERT INTO t1 VALUES (10); INSERT INTO t1 VALUES (10);
include/save_master_gtid.inc
include/start_slave.inc include/start_slave.inc
include/sync_with_master_gtid.inc
SELECT * FROM t1; SELECT * FROM t1;
a a
10 10
......
...@@ -14,10 +14,12 @@ master-bin.000002 # ...@@ -14,10 +14,12 @@ master-bin.000002 #
INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (2);
FLUSH LOGS; FLUSH LOGS;
INSERT INTO t1 VALUES (3); INSERT INTO t1 VALUES (3);
include/save_master_gtid.inc
show binary logs; show binary logs;
Log_name File_size Log_name File_size
master-bin.000002 # master-bin.000002 #
master-bin.000003 # master-bin.000003 #
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a a
1 1
...@@ -43,6 +45,8 @@ master-bin.000003 # ...@@ -43,6 +45,8 @@ master-bin.000003 #
master-bin.000004 # master-bin.000004 #
master-bin.000005 # master-bin.000005 #
INSERT INTO t1 VALUES(5); INSERT INTO t1 VALUES(5);
include/save_master_gtid.inc
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a a
1 1
......
...@@ -101,15 +101,14 @@ BEGIN; ...@@ -101,15 +101,14 @@ BEGIN;
INSERT INTO t2 VALUES (6, "i6b"); INSERT INTO t2 VALUES (6, "i6b");
INSERT INTO t2 VALUES (7, "i7b"); INSERT INTO t2 VALUES (7, "i7b");
COMMIT; COMMIT;
--source include/save_master_gtid.inc
connection server_3; connection server_3;
--replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4 --replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4, eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
MASTER_USE_GTID=CURRENT_POS; MASTER_USE_GTID=CURRENT_POS;
--source include/start_slave.inc --source include/start_slave.inc
# This time, let's sync up without reference to binlog on D. --source include/sync_with_master_gtid.inc
--let $wait_condition= SELECT COUNT(*) = 7 FROM t2
--source include/wait_condition.inc
SELECT * FROM t2 ORDER BY a; SELECT * FROM t2 ORDER BY a;
--echo *** Now change everything back to what it was, to make rpl_end.inc happy --echo *** Now change everything back to what it was, to make rpl_end.inc happy
...@@ -118,8 +117,7 @@ connection server_2; ...@@ -118,8 +117,7 @@ connection server_2;
# We need to sync up server_2 before switching. If it happened to have reached # 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 # the point 'UPDATE t2 SET b="j1a" WHERE a=5' it will fail to connect to
# server_1, which is (deliberately) missing that transaction. # server_1, which is (deliberately) missing that transaction.
--let $wait_condition= SELECT COUNT(*) = 7 FROM t2 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
--source include/stop_slave.inc --source include/stop_slave.inc
--replace_result $MASTER_MYPORT MASTER_MYPORT --replace_result $MASTER_MYPORT MASTER_MYPORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT; eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT;
...@@ -131,8 +129,7 @@ connection server_3; ...@@ -131,8 +129,7 @@ connection server_3;
--replace_result $SLAVE_MYPORT SLAVE_MYPORT --replace_result $SLAVE_MYPORT SLAVE_MYPORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SLAVE_MYPORT; eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SLAVE_MYPORT;
--source include/start_slave.inc --source include/start_slave.inc
--let $wait_condition= SELECT COUNT(*) = 7 FROM t2 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
connection server_4; connection server_4;
--source include/stop_slave.inc --source include/stop_slave.inc
...@@ -192,7 +189,7 @@ SET GLOBAL gtid_binlog_state = @old_state; ...@@ -192,7 +189,7 @@ SET GLOBAL gtid_binlog_state = @old_state;
CREATE TABLE t1 (a INT PRIMARY KEY); CREATE TABLE t1 (a INT PRIMARY KEY);
SET gtid_seq_no=100; SET gtid_seq_no=100;
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
--let $master_pos= `SELECT @@GLOBAL.gtid_binlog_pos` --source include/save_master_gtid.inc
--connection server_2 --connection server_2
--source include/start_slave.inc --source include/start_slave.inc
......
...@@ -46,6 +46,7 @@ while ($1) ...@@ -46,6 +46,7 @@ while ($1)
dec $1; dec $1;
} }
--enable_query_log --enable_query_log
--source include/save_master_gtid.inc
SET SESSION debug_dbug="+d,crash_dispatch_command_before"; SET SESSION debug_dbug="+d,crash_dispatch_command_before";
--error 2006,2013 --error 2006,2013
...@@ -60,15 +61,14 @@ EOF ...@@ -60,15 +61,14 @@ EOF
--source include/wait_until_connected_again.inc --source include/wait_until_connected_again.inc
--connection server_2 --connection server_2
--let $wait_condition= SELECT COUNT(*) = 200 FROM t1 WHERE b=2 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
--connection server_1 --connection server_1
INSERT INTO t1 VALUES (1000, 3); INSERT INTO t1 VALUES (1000, 3);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--let $wait_condition= SELECT COUNT(*) = 1 FROM t1 WHERE b=3 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
--connection server_1 --connection server_1
DROP TABLE t1; DROP TABLE t1;
...@@ -141,6 +141,7 @@ START SLAVE; ...@@ -141,6 +141,7 @@ START SLAVE;
--connection server_1 --connection server_1
INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (4);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--source include/wait_until_disconnected.inc --source include/wait_until_disconnected.inc
...@@ -152,8 +153,7 @@ EOF ...@@ -152,8 +153,7 @@ EOF
--enable_reconnect --enable_reconnect
--source include/wait_until_connected_again.inc --source include/wait_until_connected_again.inc
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
# Crash the slave just before committing. # Crash the slave just before committing.
--source include/stop_slave.inc --source include/stop_slave.inc
...@@ -165,6 +165,7 @@ START SLAVE; ...@@ -165,6 +165,7 @@ START SLAVE;
--connection server_1 --connection server_1
INSERT INTO t1 VALUES (5); INSERT INTO t1 VALUES (5);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--source include/wait_until_disconnected.inc --source include/wait_until_disconnected.inc
...@@ -176,8 +177,7 @@ EOF ...@@ -176,8 +177,7 @@ EOF
--enable_reconnect --enable_reconnect
--source include/wait_until_connected_again.inc --source include/wait_until_connected_again.inc
--let $wait_condition= SELECT COUNT(*) = 5 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
# Crash the slave just after committing. # Crash the slave just after committing.
--source include/stop_slave.inc --source include/stop_slave.inc
...@@ -189,6 +189,7 @@ START SLAVE; ...@@ -189,6 +189,7 @@ START SLAVE;
--connection server_1 --connection server_1
INSERT INTO t1 VALUES (6); INSERT INTO t1 VALUES (6);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--source include/wait_until_disconnected.inc --source include/wait_until_disconnected.inc
...@@ -200,8 +201,7 @@ EOF ...@@ -200,8 +201,7 @@ EOF
--enable_reconnect --enable_reconnect
--source include/wait_until_connected_again.inc --source include/wait_until_connected_again.inc
--let $wait_condition= SELECT COUNT(*) = 6 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
# Crash the slave just before updating relay-log.info # Crash the slave just before updating relay-log.info
--source include/stop_slave.inc --source include/stop_slave.inc
...@@ -213,6 +213,7 @@ START SLAVE; ...@@ -213,6 +213,7 @@ START SLAVE;
--connection server_1 --connection server_1
INSERT INTO t1 VALUES (7); INSERT INTO t1 VALUES (7);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--source include/wait_until_disconnected.inc --source include/wait_until_disconnected.inc
...@@ -224,8 +225,7 @@ EOF ...@@ -224,8 +225,7 @@ EOF
--enable_reconnect --enable_reconnect
--source include/wait_until_connected_again.inc --source include/wait_until_connected_again.inc
--let $wait_condition= SELECT COUNT(*) = 7 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
# Crash the slave just after updating relay-log.info # Crash the slave just after updating relay-log.info
--source include/stop_slave.inc --source include/stop_slave.inc
...@@ -237,6 +237,7 @@ START SLAVE; ...@@ -237,6 +237,7 @@ START SLAVE;
--connection server_1 --connection server_1
INSERT INTO t1 VALUES (8); INSERT INTO t1 VALUES (8);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--source include/wait_until_disconnected.inc --source include/wait_until_disconnected.inc
...@@ -248,8 +249,7 @@ EOF ...@@ -248,8 +249,7 @@ EOF
--enable_reconnect --enable_reconnect
--source include/wait_until_connected_again.inc --source include/wait_until_connected_again.inc
--let $wait_condition= SELECT COUNT(*) = 8 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
# Check that everything was replicated correctly. # Check that everything was replicated correctly.
......
...@@ -79,6 +79,7 @@ RESET MASTER; ...@@ -79,6 +79,7 @@ RESET MASTER;
INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (2);
# And this will be GTID 0-1-2 # And this will be GTID 0-1-2
INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (4);
--source include/save_master_gtid.inc
--connection slave --connection slave
SET sql_log_bin = 0; SET sql_log_bin = 0;
...@@ -110,8 +111,7 @@ RESET MASTER; ...@@ -110,8 +111,7 @@ RESET MASTER;
SET GLOBAL gtid_slave_pos = "0-1-1"; SET GLOBAL gtid_slave_pos = "0-1-1";
START SLAVE; START SLAVE;
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
--echo *** MDEV-4688: Empty value of @@GLOBAL.gtid_slave_pos *** --echo *** MDEV-4688: Empty value of @@GLOBAL.gtid_slave_pos ***
...@@ -125,6 +125,7 @@ SELECT * FROM t1 ORDER BY a; ...@@ -125,6 +125,7 @@ SELECT * FROM t1 ORDER BY a;
--connection master --connection master
# This will be GTID 0-1-3 # This will be GTID 0-1-3
INSERT INTO t1 VALUES (5); INSERT INTO t1 VALUES (5);
--source include/save_master_gtid.inc
--connection slave --connection slave
SET @old_dbug= @@GLOBAL.debug_dbug; SET @old_dbug= @@GLOBAL.debug_dbug;
...@@ -141,8 +142,7 @@ SELECT @@GLOBAL.gtid_slave_pos; ...@@ -141,8 +142,7 @@ SELECT @@GLOBAL.gtid_slave_pos;
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
SET GLOBAL debug_dbug= @old_dbug; SET GLOBAL debug_dbug= @old_dbug;
START SLAVE SQL_THREAD; START SLAVE SQL_THREAD;
--let $wait_condition= SELECT COUNT(*) = 5 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
...@@ -167,10 +167,10 @@ START SLAVE; ...@@ -167,10 +167,10 @@ START SLAVE;
--connection master --connection master
INSERT INTO t1 VALUES (6); INSERT INTO t1 VALUES (6);
--source include/save_master_gtid.inc
--connection slave --connection slave
--let $wait_condition= SELECT COUNT(*) = 6 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
......
...@@ -32,12 +32,12 @@ START SLAVE; ...@@ -32,12 +32,12 @@ START SLAVE;
--connection server_2 --connection server_2
INSERT INTO t1 VALUES (3, 2); INSERT INTO t1 VALUES (3, 2);
INSERT INTO t1 VALUES (4, 2); INSERT INTO t1 VALUES (4, 2);
--source include/save_master_gtid.inc
--source include/show_binlog_events.inc --source include/show_binlog_events.inc
--connection server_1 --connection server_1
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
...@@ -45,14 +45,14 @@ SELECT * FROM t1 ORDER BY a; ...@@ -45,14 +45,14 @@ SELECT * FROM t1 ORDER BY a;
RESET SLAVE; RESET SLAVE;
INSERT INTO t1 VALUES (5, 1); INSERT INTO t1 VALUES (5, 1);
INSERT INTO t1 VALUES (6, 1); INSERT INTO t1 VALUES (6, 1);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT, eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
master_use_gtid = current_pos; master_use_gtid = current_pos;
START SLAVE; START SLAVE;
--let $wait_condition= SELECT COUNT(*) = 6 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
......
...@@ -67,6 +67,7 @@ SET sql_log_bin=1; ...@@ -67,6 +67,7 @@ SET sql_log_bin=1;
--connection server_1 --connection server_1
INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(3);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
SET GLOBAL gtid_slave_pos='0-1-3'; SET GLOBAL gtid_slave_pos='0-1-3';
...@@ -74,13 +75,13 @@ 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, eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
MASTER_USE_GTID=CURRENT_POS; MASTER_USE_GTID=CURRENT_POS;
--source include/start_slave.inc --source include/start_slave.inc
--let $wait_condition= SELECT COUNT(*) = 3 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1 ORDER by a; SELECT * FROM t1 ORDER by a;
--source include/stop_slave.inc --source include/stop_slave.inc
--connection server_1 --connection server_1
INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (4);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
# Now add some local transactions that conflict with the GTID position # Now add some local transactions that conflict with the GTID position
...@@ -93,8 +94,7 @@ SET GLOBAL gtid_slave_pos='0-1-4'; ...@@ -93,8 +94,7 @@ SET GLOBAL gtid_slave_pos='0-1-4';
RESET MASTER; RESET MASTER;
SET GLOBAL gtid_slave_pos='0-1-4'; SET GLOBAL gtid_slave_pos='0-1-4';
START SLAVE; START SLAVE;
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1 ORDER by a; SELECT * FROM t1 ORDER by a;
--connection server_1 --connection server_1
...@@ -200,10 +200,10 @@ CHANGE MASTER TO MASTER_USE_GTID=CURRENT_POS; ...@@ -200,10 +200,10 @@ CHANGE MASTER TO MASTER_USE_GTID=CURRENT_POS;
--connection server_1 --connection server_1
INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(3);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--let $wait_condition= SELECT COUNT(*) = 3 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
SET SQL_LOG_BIN=0; SET SQL_LOG_BIN=0;
call mtr.add_suppression("Slave: Table 't1' already exists error.* 1050"); call mtr.add_suppression("Slave: Table 't1' already exists error.* 1050");
...@@ -215,10 +215,10 @@ SET SQL_LOG_BIN=1; ...@@ -215,10 +215,10 @@ SET SQL_LOG_BIN=1;
--connection server_1 --connection server_1
FLUSH LOGS; FLUSH LOGS;
INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (4);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
--source include/stop_slave.inc --source include/stop_slave.inc
--connection server_1 --connection server_1
...@@ -228,13 +228,13 @@ FLUSH LOGS; ...@@ -228,13 +228,13 @@ FLUSH LOGS;
--source include/wait_for_purge.inc --source include/wait_for_purge.inc
--source include/show_binary_logs.inc --source include/show_binary_logs.inc
INSERT INTO t1 VALUES (5); INSERT INTO t1 VALUES (5);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT; eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT;
--source include/start_slave.inc --source include/start_slave.inc
--let $wait_condition= SELECT COUNT(*) = 5 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
...@@ -249,11 +249,11 @@ SET GLOBAL gtid_slave_pos=""; ...@@ -249,11 +249,11 @@ SET GLOBAL gtid_slave_pos="";
RESET MASTER; RESET MASTER;
TRUNCATE TABLE t1; TRUNCATE TABLE t1;
INSERT INTO t1 VALUES (10); # Will be GTID 0-1-2 INSERT INTO t1 VALUES (10); # Will be GTID 0-1-2
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--source include/start_slave.inc --source include/start_slave.inc
--let $wait_condition= SELECT COUNT(*) = 1 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1; SELECT * FROM t1;
--let $value= query_get_value(SHOW SLAVE STATUS, "Using_Gtid", 1) --let $value= query_get_value(SHOW SLAVE STATUS, "Using_Gtid", 1)
......
...@@ -39,6 +39,7 @@ FLUSH LOGS; ...@@ -39,6 +39,7 @@ FLUSH LOGS;
INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (2);
FLUSH LOGS; FLUSH LOGS;
INSERT INTO t1 VALUES (3); INSERT INTO t1 VALUES (3);
--source include/save_master_gtid.inc
--source include/show_binary_logs.inc --source include/show_binary_logs.inc
# Let the slave mysqld server start again. # Let the slave mysqld server start again.
...@@ -50,8 +51,7 @@ EOF ...@@ -50,8 +51,7 @@ EOF
--enable_reconnect --enable_reconnect
--source include/wait_until_connected_again.inc --source include/wait_until_connected_again.inc
--let $wait_condition= SELECT COUNT(*) = 3 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
...@@ -88,10 +88,10 @@ SHOW BINLOG EVENTS IN 'master-bin.000005' LIMIT 1,1; ...@@ -88,10 +88,10 @@ SHOW BINLOG EVENTS IN 'master-bin.000005' LIMIT 1,1;
--source include/show_binary_logs.inc --source include/show_binary_logs.inc
INSERT INTO t1 VALUES(5); INSERT INTO t1 VALUES(5);
--source include/save_master_gtid.inc
--connection server_2 --connection server_2
--let $wait_condition= SELECT COUNT(*) = 5 FROM t1 --source include/sync_with_master_gtid.inc
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a; 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. *** --echo *** Test that @@gtid_slave_pos and @@gtid_current_pos are correctly loaded even if slave threads have not started. ***
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment