3
# Verify that --slave-skip-errors works correctly. The error messages
4
# specified by --slave-skip-errors on slave should be ignored. If
5
# such errors occur, they should not be reported and not cause the
10
# We run the slave with --slave-skip-errors=1062 (the code for
11
# duplicate key). Then we have two set of tests. In the first
12
# set, we insert value 1 in a table on the slave, and then, on
13
# master, we insert value 1 in the table. In the second set, we
14
# insert several values on the master, disable the binlog and
15
# delete one of the values and re-enable the binlog. Right after,
16
# we perform an update on the set of values in order to generate
17
# a duplicate key on the slave. The errors should be ignored on
20
# ==== Related bugs ====
22
# BUG#28839: Errors in strict mode silently stop SQL thread if --slave-skip-errors exists
23
# bug in this test: BUG#30594: rpl.rpl_skip_error is nondeterministic:
24
# BUG#39393: slave-skip-errors does not work when using ROW based replication
26
source include/master-slave.inc;
27
source include/have_innodb.inc;
29
--echo ==== Test Without sql_mode=strict_trans_tables ====
32
create table t1 (n int not null primary key);
35
sync_slave_with_master;
36
insert into t1 values (1);
40
# Here we expect (ignored) error, since 1 is already in slave table
41
insert into t1 values (1);
42
# These should work fine
43
insert into t1 values (2),(3);
45
sync_slave_with_master;
47
select * from t1 order by n;
49
--echo ==== Test With sql_mode=strict_trans_tables ====
50
insert into t1 values (7),(8);
53
set sql_mode=strict_trans_tables;
54
insert into t1 values (7), (8), (9);
56
sync_slave_with_master;
57
select * from t1 order by n;
58
source include/show_slave_status2.inc;
60
--echo ==== Clean Up ====
63
sync_slave_with_master;
67
# #28839 Errors in strict mode silently stop SQL thread if --slave-skip-errors exists
70
create table t1(a int primary key);
71
insert into t1 values (1),(2);
75
set sql_mode=strict_trans_tables;
76
insert into t1 values (1), (2), (3);
79
sync_slave_with_master;
81
source include/show_slave_status2.inc;
84
--echo ==== Clean Up ====
88
sync_slave_with_master;
92
# BUG#39393: slave-skip-errors does not work when using ROW based replication
94
--echo ==== Using Innodb ====
99
CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB;
100
SHOW CREATE TABLE t1;
105
CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB;
106
SHOW CREATE TABLE t1;
110
INSERT INTO t1 VALUES(1, 1);
111
INSERT INTO t1 VALUES(2, 1);
112
INSERT INTO t1 VALUES(3, 1);
113
INSERT INTO t1 VALUES(4, 1);
116
DELETE FROM t1 WHERE id = 4;
118
UPDATE t1 SET id= id + 3, data = 2;
120
sync_slave_with_master;
122
let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
125
--echo **** We cannot execute a select as there are differences in the
126
--echo **** behavior between STMT and RBR.
128
--echo ==== Using MyIsam ====
133
CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam;
134
SHOW CREATE TABLE t2;
139
CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam;
140
SHOW CREATE TABLE t2;
144
INSERT INTO t2 VALUES(1, 1);
145
INSERT INTO t2 VALUES(2, 1);
146
INSERT INTO t2 VALUES(3, 1);
147
INSERT INTO t2 VALUES(5, 1);
150
DELETE FROM t2 WHERE id = 5;
152
UPDATE t2 SET id= id + 3, data = 2;
154
sync_slave_with_master;
156
let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
159
--echo **** We cannot execute a select as there are differences in the
160
--echo **** behavior between STMT and RBR.
162
--echo ==== Clean Up ====
169
sync_slave_with_master;