1--source include/have_debug.inc
2--source include/have_innodb.inc
3--source include/have_binlog_format_statement.inc
4--let $rpl_topology=1->2
5--source include/rpl_init.inc
6
7--connection server_1
8ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
9SET sql_log_bin= 0;
10call mtr.add_suppression("Error writing file .*errno: 1950");
11
12SET sql_log_bin= 1;
13
14SET @old_gtid_strict_mode= @@GLOBAL.gtid_strict_mode;
15SET GLOBAL gtid_strict_mode= 1;
16--connection server_2
17--source include/stop_slave.inc
18SET @old_gtid_strict_mode= @@GLOBAL.gtid_strict_mode;
19SET GLOBAL gtid_strict_mode=1;
20CHANGE MASTER TO master_use_gtid=slave_pos;
21--source include/start_slave.inc
22
23--connection server_1
24CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
25INSERT INTO t1 VALUES (1);
26
27--source include/show_binlog_events.inc
28
29SET server_id= 3;
30--error ER_GTID_STRICT_OUT_OF_ORDER
31SET gtid_seq_no= 3;
32SET @old_dbug = @@session.debug_dbug;
33SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check";
34SET gtid_seq_no= 3;
35SET SESSION debug_dbug=@old_dbug;
36--error ER_GTID_STRICT_OUT_OF_ORDER
37INSERT INTO t1 VALUES (2);
38
39--error ER_GTID_STRICT_OUT_OF_ORDER
40SET gtid_seq_no= 2;
41SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check";
42SET gtid_seq_no= 2;
43SET SESSION debug_dbug=@old_dbug;
44--error ER_GTID_STRICT_OUT_OF_ORDER
45INSERT INTO t1 VALUES (3);
46SET server_id= 1;
47SET gtid_seq_no= 4;
48INSERT INTO t1 VALUES (4);
49SELECT * FROM t1 ORDER BY 1;
50--source include/show_binlog_events.inc
51
52--echo *** Test non-transactional GTID error (cannot be rolled back). ***
53SET server_id= 3;
54--error ER_GTID_STRICT_OUT_OF_ORDER
55SET gtid_seq_no= 1;
56SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check";
57SET gtid_seq_no= 1;
58SET SESSION debug_dbug=@old_dbug;
59--error ER_GTID_STRICT_OUT_OF_ORDER
60CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM;
61# The table is still created, DDL cannot be rolled back.
62# Fix it up for replication.
63SET sql_log_bin= 0;
64DROP TABLE t2;
65SET sql_log_bin= 1;
66CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM;
67
68--error ER_GTID_STRICT_OUT_OF_ORDER
69SET gtid_seq_no= 1;
70SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check";
71SET gtid_seq_no= 1;
72SET SESSION debug_dbug=@old_dbug;
73--error ER_GTID_STRICT_OUT_OF_ORDER
74INSERT INTO t2 VALUES (1);
75# The value is still inserted, cannot be rolled back.
76SET server_id= 1;
77SET gtid_seq_no= 6;
78INSERT INTO t2 VALUES (2);
79SELECT * FROM t2 ORDER BY a;
80--source include/show_binlog_events.inc
81
82
83--echo *** Test that slave stops if it tries to apply a GTID that would create out-of-order binlog GTID sequence numbers. ***
84
85--save_master_pos
86--connection server_2
87--sync_with_master
88
89SELECT * FROM t1 ORDER BY a;
90SELECT * FROM t2 ORDER BY a;
91SET sql_log_bin= 0;
92call mtr.add_suppression("An attempt was made to binlog GTID .* which would create an out-of-order sequence number with existing GTID .*, and gtid strict mode is enabled");
93call mtr.add_suppression("The binlog on the master is missing the GTID [-0-9]+ requested by the slave");
94SET sql_log_bin= 1;
95
96# Create some out-of-order stuff on slave.
97INSERT INTO t1 VALUES (5);
98
99--connection server_1
100INSERT INTO t1 VALUES (6);
101--save_master_pos
102
103--connection server_2
104--let $slave_sql_errno=1950
105--source include/wait_for_slave_sql_error.inc
106STOP SLAVE IO_THREAD;
107SET GLOBAL gtid_strict_mode=0;
108--source include/start_slave.inc
109--sync_with_master
110SET GLOBAL gtid_strict_mode=1;
111SELECT * FROM t1 ORDER BY a;
112
113INSERT INTO t1 VALUES (7);
114--connection server_1
115CREATE TABLE t3 (a INT PRIMARY KEY);
116--save_master_pos
117
118--connection server_2
119--let $slave_sql_errno=1950
120--source include/wait_for_slave_sql_error.inc
121--error ER_NO_SUCH_TABLE
122--query_vertical SHOW CREATE TABLE t3
123STOP SLAVE IO_THREAD;
124SET GLOBAL gtid_strict_mode=0;
125--source include/start_slave.inc
126--sync_with_master
127SET GLOBAL gtid_strict_mode=1;
128--query_vertical SHOW CREATE TABLE t3
129
130INSERT INTO t1 VALUES (8);
131--connection server_1
132INSERT INTO t2 VALUES (3);
133--save_master_pos
134
135--connection server_2
136--let $slave_sql_errno=1950
137--source include/wait_for_slave_sql_error.inc
138SELECT * FROM t2 ORDER BY a;
139STOP SLAVE IO_THREAD;
140SET GLOBAL gtid_strict_mode=0;
141--source include/start_slave.inc
142--sync_with_master
143SET GLOBAL gtid_strict_mode=1;
144SELECT * FROM t2 ORDER BY a;
145
146
147--echo *** Check slave requests starting from a hole on the master. ***
148--connection server_2
149--source include/stop_slave.inc
150
151--connection server_1
152INSERT INTO t1 VALUES (10);
153SET gtid_seq_no= 100;
154INSERT INTO t1 VALUES (11);
155INSERT INTO t1 VALUES (12);
156--save_master_pos
157
158--connection server_2
159SET GLOBAL gtid_slave_pos= "0-1-50";
160START SLAVE;
161--let $slave_io_errno=1236
162--source include/wait_for_slave_io_error.inc
163STOP SLAVE SQL_THREAD;
164SET GLOBAL gtid_strict_mode= 0;
165--source include/start_slave.inc
166--sync_with_master
167
168SELECT * FROM t1 ORDER BY a;
169SET GLOBAL gtid_strict_mode= 1;
170
171
172# Clean up.
173--connection server_1
174DROP TABLE t1, t2, t3;
175SET GLOBAL gtid_strict_mode= @old_gtid_strict_mode;
176--connection server_2
177SET GLOBAL gtid_strict_mode= @old_gtid_strict_mode;
178
179--source include/rpl_end.inc
180