| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Verify that --replica-skip-errors works correctly. The error messages |
| 4 |
# specified by --replica-skip-errors on slave should be ignored. If |
| 5 |
# such errors occur, they should not be reported and not cause the |
| 6 |
# slave to stop. |
| 7 |
# |
| 8 |
# ==== Method ==== |
| 9 |
# |
| 10 |
# We run the slave with --replica-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 |
| 18 |
# the slave. |
| 19 |
# |
| 20 |
# ==== Related bugs ==== |
| 21 |
# |
| 22 |
# BUG#28839: Errors in strict mode silently stop SQL thread if --replica-skip-errors exists |
| 23 |
# bug in this test: BUG#30594: rpl.rpl_skip_error is nondeterministic: |
| 24 |
# BUG#39393: replica-skip-errors does not work when using ROW based replication |
| 25 |
|
| 26 |
--source include/not_group_replication_plugin.inc |
| 27 |
source include/master-slave.inc; |
| 28 |
|
| 29 |
--echo ==== Test Without sql_mode=strict_trans_tables ==== |
| 30 |
|
| 31 |
--echo [on master] |
| 32 |
create table t1 (n int not null primary key); |
| 33 |
|
| 34 |
--echo [on slave] |
| 35 |
--source include/sync_slave_sql_with_master.inc |
| 36 |
insert into t1 values (1); |
| 37 |
|
| 38 |
--echo [on master] |
| 39 |
connection master; |
| 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); |
| 44 |
|
| 45 |
--source include/sync_slave_sql_with_master.inc |
| 46 |
--echo [on slave] |
| 47 |
select * from t1 order by n; |
| 48 |
|
| 49 |
--echo ==== Test With sql_mode=strict_trans_tables ==== |
| 50 |
insert into t1 values (7),(8); |
| 51 |
--echo [on master] |
| 52 |
connection master; |
| 53 |
set sql_mode=strict_trans_tables; |
| 54 |
insert into t1 values (7), (8), (9); |
| 55 |
--echo [on slave] |
| 56 |
--source include/sync_slave_sql_with_master.inc |
| 57 |
select * from t1 order by n; |
| 58 |
source include/check_slave_is_running.inc; |
| 59 |
|
| 60 |
--echo ==== Clean Up ==== |
| 61 |
connection master; |
| 62 |
drop table t1; |
| 63 |
--source include/sync_slave_sql_with_master.inc |
| 64 |
# End of 4.1 tests |
| 65 |
|
| 66 |
# |
| 67 |
# #28839 Errors in strict mode silently stop SQL thread if --replica-skip-errors exists |
| 68 |
# |
| 69 |
connection master; |
| 70 |
create table t1(a int primary key); |
| 71 |
insert into t1 values (1),(2); |
| 72 |
SET SQL_LOG_BIN=0; |
| 73 |
delete from t1; |
| 74 |
SET SQL_LOG_BIN=1; |
| 75 |
set sql_mode=strict_trans_tables; |
| 76 |
insert into t1 values (1), (2), (3); |
| 77 |
|
| 78 |
--echo [on slave] |
| 79 |
--source include/sync_slave_sql_with_master.inc |
| 80 |
select * from t1; |
| 81 |
source include/check_slave_is_running.inc; |
| 82 |
|
| 83 |
|
| 84 |
--echo ==== Clean Up ==== |
| 85 |
|
| 86 |
connection master; |
| 87 |
drop table t1; |
| 88 |
--source include/sync_slave_sql_with_master.inc |
| 89 |
# End of 5.0 tests |
| 90 |
|
| 91 |
# |
| 92 |
# BUG#39393: replica-skip-errors does not work when using ROW based replication |
| 93 |
# |
| 94 |
--echo ==== Using Innodb ==== |
| 95 |
|
| 96 |
connection master; |
| 97 |
|
| 98 |
SET SQL_LOG_BIN=0; |
| 99 |
CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB; |
| 100 |
SHOW CREATE TABLE t1; |
| 101 |
SET SQL_LOG_BIN=1; |
| 102 |
|
| 103 |
connection slave; |
| 104 |
|
| 105 |
call mtr.add_suppression("Replica SQL.*Could not execute .*te_rows event on table test.t.; Duplicate entry.* Error_code: 1062"); |
| 106 |
|
| 107 |
CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB; |
| 108 |
SHOW CREATE TABLE t1; |
| 109 |
|
| 110 |
connection master; |
| 111 |
|
| 112 |
INSERT INTO t1 VALUES(1, 1); |
| 113 |
INSERT INTO t1 VALUES(2, 1); |
| 114 |
INSERT INTO t1 VALUES(3, 1); |
| 115 |
INSERT INTO t1 VALUES(4, 1); |
| 116 |
|
| 117 |
SET SQL_LOG_BIN=0; |
| 118 |
DELETE FROM t1 WHERE id = 4; |
| 119 |
SET SQL_LOG_BIN=1; |
| 120 |
UPDATE t1 SET id= id + 3, data = 2; |
| 121 |
|
| 122 |
--source include/sync_slave_sql_with_master.inc |
| 123 |
|
| 124 |
let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); |
| 125 |
echo $error; |
| 126 |
|
| 127 |
--echo **** We cannot execute a select as there are differences in the |
| 128 |
--echo **** behavior between STMT and RBR. |
| 129 |
|
| 130 |
--echo ==== Clean Up ==== |
| 131 |
|
| 132 |
connection master; |
| 133 |
|
| 134 |
DROP TABLE t1; |
| 135 |
|
| 136 |
--source include/sync_slave_sql_with_master.inc |
| 137 |
--source include/rpl_end.inc |