1 include/master-slave.inc
3 call mtr.add_suppression("Can.t find record in .t[12].* Error_code: 1032");
4 call mtr.add_suppression("Cannot delete or update a parent row: a foreign key constraint fails .* Error_code: 1451");
5 call mtr.add_suppression("Cannot add or update a child row: a foreign key constraint fails .* Error_code: 1452");
6 call mtr.add_suppression("Slave SQL.*Could not execute Write_rows event on table test.* Duplicate entry .1. for key .PRIMARY.* Error_code: 1062");
7 SET @old_slave_exec_mode= @@global.slave_exec_mode;
8 CREATE TABLE t1 (a INT PRIMARY KEY);
9 CREATE TABLE t2 (a INT);
10 INSERT INTO t1 VALUES (-1),(-2),(-3);
11 INSERT INTO t2 VALUES (-1),(-2),(-3);
12 DELETE FROM t1 WHERE a = -2;
13 DELETE FROM t2 WHERE a = -2;
14 DELETE FROM t1 WHERE a = -2;
15 DELETE FROM t2 WHERE a = -2;
16 SELECT * FROM t1 ORDER BY a;
20 SELECT * FROM t2 ORDER BY a;
24 SELECT * FROM t1 ORDER BY a;
28 SELECT * FROM t2 ORDER BY a;
32 include/check_slave_no_error.inc
33 INSERT IGNORE INTO t1 VALUES (-2);
34 INSERT IGNORE INTO t1 VALUES (-2);
35 SELECT * FROM t1 ORDER BY a;
40 SELECT * FROM t1 ORDER BY a;
45 include/check_slave_no_error.inc
46 UPDATE t1 SET a = 1 WHERE a = -1;
47 UPDATE t2 SET a = 1 WHERE a = -1;
48 UPDATE t1 SET a = 1 WHERE a = -1;
49 UPDATE t2 SET a = 1 WHERE a = -1;
50 SELECT * FROM t1 ORDER BY a;
55 SELECT * FROM t2 ORDER BY a;
59 SELECT * FROM t1 ORDER BY a;
64 SELECT * FROM t2 ORDER BY a;
68 include/check_slave_no_error.inc
70 select @@global.slave_exec_mode /* must be IDEMPOTENT */;
71 @@global.slave_exec_mode
73 create table ti1 (b int primary key) engine = innodb;
74 create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
76 set foreign_key_checks=1 /* ensure the check */;
77 insert into ti1 values (1),(2),(3);
78 insert into ti2 set a=2, b=2;
79 select * from ti1 order by b /* must be (1),(2),(3) */;
84 insert into ti2 set a=1, b=1;
85 select * from ti2 order by b /* must be (1,1) (2,2) */;
89 set @save_binlog_format= @@session.binlog_format;
90 set @@session.binlog_format= row;
91 delete from ti1 where b=1;
92 select * from ti1 order by b /* must be (2),(3) */;
96 select * from ti1 order by b /* must stays as were on master (1),(2),(3) */;
101 delete from ti1 where b=3;
102 insert into ti2 set a=3, b=3;
103 select * from ti2 order by b /* must be (1,1),(2,2) - not inserted */;
107 set global slave_exec_mode='IDEMPOTENT';
108 set global slave_exec_mode='STRICT';
109 set global slave_exec_mode='IDEMPOTENT,STRICT';
110 ERROR HY000: Ambiguous slave modes combination.
111 select @@global.slave_exec_mode /* must be STRICT */;
112 @@global.slave_exec_mode
114 *** foreign keys errors as above now forces to stop
115 set foreign_key_checks=0;
117 create table ti1 (b int primary key) engine = innodb;
118 create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
120 set foreign_key_checks=1 /* ensure the check */;
121 insert into ti1 values (1),(2),(3);
122 insert into ti2 set a=2, b=2;
123 select * from ti1 order by b /* must be (1),(2),(3) */;
128 *** conspire future problem
129 insert into ti2 set a=1, b=1;
130 select * from ti2 order by b /* must be (1,1) (2,2) */;
134 delete from ti1 where b=1 /* offending delete event */;
135 select * from ti1 order by b /* must be (2),(3) */;
139 *** slave must stop (Trying to delete a referenced foreing key)
140 include/wait_for_slave_sql_error.inc [errno=1451]
141 select * from ti1 order by b /* must be (1),(2),(3) - not deleted */;
146 set foreign_key_checks= 0;
147 delete from ti2 where b=1;
148 set foreign_key_checks= 1;
149 set global slave_exec_mode='IDEMPOTENT';
150 start slave sql_thread;
151 set global slave_exec_mode='STRICT';
152 *** conspire the following insert failure
153 *** conspire future problem
154 delete from ti1 where b=3;
155 insert into ti2 set a=3, b=3 /* offending write event */;
156 *** slave must stop (Trying to insert an invalid foreign key)
157 include/wait_for_slave_sql_error.inc [errno=1452]
158 select * from ti2 order by b /* must be (2,2) */;
161 set foreign_key_checks= 0;
162 insert into ti1 set b=3;
163 set foreign_key_checks= 1;
164 set global slave_exec_mode='IDEMPOTENT';
165 start slave sql_thread;
166 set global slave_exec_mode='STRICT';
167 select * from ti2 order by b /* must be (2,2),(3,3) */;
173 insert into ti1 set b=1;
174 insert into ti1 set b=1 /* offending write event */;
175 *** slave must stop (Trying to insert a dupliacte key)
176 include/wait_for_slave_sql_error.inc [errno=1062]
177 set foreign_key_checks= 0;
178 delete from ti1 where b=1;
179 set foreign_key_checks= 1;
180 set global slave_exec_mode='IDEMPOTENT';
181 start slave sql_thread;
182 set global slave_exec_mode='STRICT';
183 CREATE TABLE t1 (a INT PRIMARY KEY);
184 CREATE TABLE t2 (a INT);
185 INSERT INTO t1 VALUES (-1),(-2),(-3);
186 INSERT INTO t2 VALUES (-1),(-2),(-3);
187 DELETE FROM t1 WHERE a = -2;
188 DELETE FROM t2 WHERE a = -2;
189 DELETE FROM t1 WHERE a = -2;
190 *** slave must stop (Key was not found)
191 include/wait_for_slave_sql_error.inc [errno=1032]
192 set global slave_exec_mode='IDEMPOTENT';
193 start slave sql_thread;
194 set global slave_exec_mode='STRICT';
195 DELETE FROM t2 WHERE a = -2;
196 *** slave must stop (Key was not found)
197 include/wait_for_slave_sql_error.inc [errno=1032]
198 set global slave_exec_mode='IDEMPOTENT';
199 start slave sql_thread;
200 set global slave_exec_mode='STRICT';
201 UPDATE t1 SET a = 1 WHERE a = -1;
202 UPDATE t2 SET a = 1 WHERE a = -1;
203 UPDATE t1 SET a = 1 WHERE a = -1;
204 *** slave must stop (Key was not found)
205 include/wait_for_slave_sql_error.inc [errno=1032]
206 set global slave_exec_mode='IDEMPOTENT';
207 start slave sql_thread;
208 set global slave_exec_mode='STRICT';
209 UPDATE t2 SET a = 1 WHERE a = -1;
210 *** slave must stop (Key was not found)
211 include/wait_for_slave_sql_error.inc [errno=1032]
212 set global slave_exec_mode='IDEMPOTENT';
213 start slave sql_thread;
214 SET @@global.slave_exec_mode= @old_slave_exec_mode;
215 set @@session.binlog_format= @save_binlog_format;
216 drop table t1,t2,ti2,ti1;