summaryrefslogtreecommitdiff
path: root/mysql-test/suite/rpl/t/rpl_gtid_strict.test
blob: afcb179da7816222c8031acf79e2d768f673d33b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
--source include/have_debug.inc
--source include/have_innodb.inc
--source include/have_binlog_format_statement.inc
--let $rpl_topology=1->2
--source include/rpl_init.inc

--connection server_1
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
SET sql_log_bin= 0;
call mtr.add_suppression("Error writing file .*errno: 1950");

SET sql_log_bin= 1;

SET @old_gtid_strict_mode= @@GLOBAL.gtid_strict_mode;
SET GLOBAL gtid_strict_mode= 1;
--connection server_2
--source include/stop_slave.inc
SET @old_gtid_strict_mode= @@GLOBAL.gtid_strict_mode;
SET GLOBAL gtid_strict_mode=1;
CHANGE MASTER TO master_use_gtid=slave_pos;
--source include/start_slave.inc

--connection server_1
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);

--source include/show_binlog_events.inc

SET server_id= 3;
--error ER_GTID_STRICT_OUT_OF_ORDER
SET gtid_seq_no= 3;
SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check";
SET gtid_seq_no= 3;
SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check";
--error ER_GTID_STRICT_OUT_OF_ORDER
INSERT INTO t1 VALUES (2);

--error ER_GTID_STRICT_OUT_OF_ORDER
SET gtid_seq_no= 2;
SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check";
SET gtid_seq_no= 2;
SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check";
--error ER_GTID_STRICT_OUT_OF_ORDER
INSERT INTO t1 VALUES (3);
SET server_id= 1;
SET gtid_seq_no= 4;
INSERT INTO t1 VALUES (4);
SELECT * FROM t1 ORDER BY 1;
--source include/show_binlog_events.inc

--echo *** Test non-transactional GTID error (cannot be rolled back). ***
SET server_id= 3;
--error ER_GTID_STRICT_OUT_OF_ORDER
SET gtid_seq_no= 1;
SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check";
SET gtid_seq_no= 1;
SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check";
--error ER_GTID_STRICT_OUT_OF_ORDER
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM;
# The table is still created, DDL cannot be rolled back.
# Fix it up for replication.
SET sql_log_bin= 0;
DROP TABLE t2;
SET sql_log_bin= 1;
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM;

--error ER_GTID_STRICT_OUT_OF_ORDER
SET gtid_seq_no= 1;
SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check";
SET gtid_seq_no= 1;
SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check";
--error ER_GTID_STRICT_OUT_OF_ORDER
INSERT INTO t2 VALUES (1);
# The value is still inserted, cannot be rolled back.
SET server_id= 1;
SET gtid_seq_no= 6;
INSERT INTO t2 VALUES (2);
SELECT * FROM t2 ORDER BY a;
--source include/show_binlog_events.inc


--echo *** Test that slave stops if it tries to apply a GTID that would create out-of-order binlog GTID sequence numbers. ***

--save_master_pos
--connection server_2
--sync_with_master

SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
SET sql_log_bin= 0;
call 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");
call mtr.add_suppression("The binlog on the master is missing the GTID [-0-9]+ requested by the slave");
SET sql_log_bin= 1;

# Create some out-of-order stuff on slave.
INSERT INTO t1 VALUES (5);

--connection server_1
INSERT INTO t1 VALUES (6);
--save_master_pos

--connection server_2
--let $slave_sql_errno=1950
--source include/wait_for_slave_sql_error.inc
STOP SLAVE IO_THREAD;
SET GLOBAL gtid_strict_mode=0;
--source include/start_slave.inc
--sync_with_master
SET GLOBAL gtid_strict_mode=1;
SELECT * FROM t1 ORDER BY a;

INSERT INTO t1 VALUES (7);
--connection server_1
CREATE TABLE t3 (a INT PRIMARY KEY);
--save_master_pos

--connection server_2
--let $slave_sql_errno=1950
--source include/wait_for_slave_sql_error.inc
--error ER_NO_SUCH_TABLE
--query_vertical SHOW CREATE TABLE t3
STOP SLAVE IO_THREAD;
SET GLOBAL gtid_strict_mode=0;
--source include/start_slave.inc
--sync_with_master
SET GLOBAL gtid_strict_mode=1;
--query_vertical SHOW CREATE TABLE t3

INSERT INTO t1 VALUES (8);
--connection server_1
INSERT INTO t2 VALUES (3);
--save_master_pos

--connection server_2
--let $slave_sql_errno=1950
--source include/wait_for_slave_sql_error.inc
SELECT * FROM t2 ORDER BY a;
STOP SLAVE IO_THREAD;
SET GLOBAL gtid_strict_mode=0;
--source include/start_slave.inc
--sync_with_master
SET GLOBAL gtid_strict_mode=1;
SELECT * FROM t2 ORDER BY a;


--echo *** Check slave requests starting from a hole on the master. ***
--connection server_2
--source include/stop_slave.inc

--connection server_1
INSERT INTO t1 VALUES (10);
SET gtid_seq_no= 100;
INSERT INTO t1 VALUES (11);
INSERT INTO t1 VALUES (12);
--save_master_pos

--connection server_2
SET GLOBAL gtid_slave_pos= "0-1-50";
START SLAVE;
--let $slave_io_errno=1236
--source include/wait_for_slave_io_error.inc
STOP SLAVE SQL_THREAD;
SET GLOBAL gtid_strict_mode= 0;
--source include/start_slave.inc
--sync_with_master

SELECT * FROM t1 ORDER BY a;
SET GLOBAL gtid_strict_mode= 1;


# Clean up.
--connection server_1
DROP TABLE t1, t2, t3;
SET GLOBAL gtid_strict_mode= @old_gtid_strict_mode;
--connection server_2
SET GLOBAL gtid_strict_mode= @old_gtid_strict_mode;

--source include/rpl_end.inc