Debian Codegraph @

mysql-test/suite/rpl/t/rpl_gtid_strict.test

raw
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
8 ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
9 SET sql_log_bin= 0;
10 call mtr.add_suppression("Error writing file .*errno: 1950");
11
12 SET sql_log_bin= 1;
13
14 SET @old_gtid_strict_mode= @@GLOBAL.gtid_strict_mode;
15 SET GLOBAL gtid_strict_mode= 1;
16 --connection server_2
17 --source include/stop_slave.inc
18 SET @old_gtid_strict_mode= @@GLOBAL.gtid_strict_mode;
19 SET GLOBAL gtid_strict_mode=1;
20 CHANGE MASTER TO master_use_gtid=slave_pos;
21 --source include/start_slave.inc
22
23 --connection server_1
24 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
25 INSERT INTO t1 VALUES (1);
26
27 --source include/show_binlog_events.inc
28
29 SET server_id= 3;
30 --error ER_GTID_STRICT_OUT_OF_ORDER
31 SET gtid_seq_no= 3;
32 SET @old_dbug = @@session.debug_dbug;
33 SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check";
34 SET gtid_seq_no= 3;
35 SET SESSION debug_dbug=@old_dbug;
36 --error ER_GTID_STRICT_OUT_OF_ORDER
37 INSERT INTO t1 VALUES (2);
38
39 --error ER_GTID_STRICT_OUT_OF_ORDER
40 SET gtid_seq_no= 2;
41 SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check";
42 SET gtid_seq_no= 2;
43 SET SESSION debug_dbug=@old_dbug;
44 --error ER_GTID_STRICT_OUT_OF_ORDER
45 INSERT INTO t1 VALUES (3);
46 SET server_id= 1;
47 SET gtid_seq_no= 4;
48 INSERT INTO t1 VALUES (4);
49 SELECT * FROM t1 ORDER BY 1;
50 --source include/show_binlog_events.inc
51
52 --echo *** Test non-transactional GTID error (cannot be rolled back). ***
53 SET server_id= 3;
54 --error ER_GTID_STRICT_OUT_OF_ORDER
55 SET gtid_seq_no= 1;
56 SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check";
57 SET gtid_seq_no= 1;
58 SET SESSION debug_dbug=@old_dbug;
59 --error ER_GTID_STRICT_OUT_OF_ORDER
60 CREATE 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.
63 SET sql_log_bin= 0;
64 DROP TABLE t2;
65 SET sql_log_bin= 1;
66 CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM;
67
68 --error ER_GTID_STRICT_OUT_OF_ORDER
69 SET gtid_seq_no= 1;
70 SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check";
71 SET gtid_seq_no= 1;
72 SET SESSION debug_dbug=@old_dbug;
73 --error ER_GTID_STRICT_OUT_OF_ORDER
74 INSERT INTO t2 VALUES (1);
75 # The value is still inserted, cannot be rolled back.
76 SET server_id= 1;
77 SET gtid_seq_no= 6;
78 INSERT INTO t2 VALUES (2);
79 SELECT * 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
89 SELECT * FROM t1 ORDER BY a;
90 SELECT * FROM t2 ORDER BY a;
91 SET sql_log_bin= 0;
92 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");
93 call mtr.add_suppression("The binlog on the master is missing the GTID [-0-9]+ requested by the slave");
94 SET sql_log_bin= 1;
95
96 # Create some out-of-order stuff on slave.
97 INSERT INTO t1 VALUES (5);
98
99 --connection server_1
100 INSERT 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
106 STOP SLAVE IO_THREAD;
107 SET GLOBAL gtid_strict_mode=0;
108 --source include/start_slave.inc
109 --sync_with_master
110 SET GLOBAL gtid_strict_mode=1;
111 SELECT * FROM t1 ORDER BY a;
112
113 INSERT INTO t1 VALUES (7);
114 --connection server_1
115 CREATE 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
123 STOP SLAVE IO_THREAD;
124 SET GLOBAL gtid_strict_mode=0;
125 --source include/start_slave.inc
126 --sync_with_master
127 SET GLOBAL gtid_strict_mode=1;
128 --query_vertical SHOW CREATE TABLE t3
129
130 INSERT INTO t1 VALUES (8);
131 --connection server_1
132 INSERT 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
138 SELECT * FROM t2 ORDER BY a;
139 STOP SLAVE IO_THREAD;
140 SET GLOBAL gtid_strict_mode=0;
141 --source include/start_slave.inc
142 --sync_with_master
143 SET GLOBAL gtid_strict_mode=1;
144 SELECT * 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
152 INSERT INTO t1 VALUES (10);
153 SET gtid_seq_no= 100;
154 INSERT INTO t1 VALUES (11);
155 INSERT INTO t1 VALUES (12);
156 --save_master_pos
157
158 --connection server_2
159 SET GLOBAL gtid_slave_pos= "0-1-50";
160 START SLAVE;
161 --let $slave_io_errno=1236
162 --source include/wait_for_slave_io_error.inc
163 STOP SLAVE SQL_THREAD;
164 SET GLOBAL gtid_strict_mode= 0;
165 --source include/start_slave.inc
166 --sync_with_master
167
168 SELECT * FROM t1 ORDER BY a;
169 SET GLOBAL gtid_strict_mode= 1;
170
171
172 # Clean up.
173 --connection server_1
174 DROP TABLE t1, t2, t3;
175 SET GLOBAL gtid_strict_mode= @old_gtid_strict_mode;
176 --connection server_2
177 SET GLOBAL gtid_strict_mode= @old_gtid_strict_mode;
178
179 --source include/rpl_end.inc