| 1 |
include/master-slave.inc |
| 2 |
[connection master] |
| 3 |
==== Initialize ==== |
| 4 |
connection master; |
| 5 |
CREATE TABLE t1(a INT PRIMARY KEY); |
| 6 |
connection slave; |
| 7 |
==== Test: SQL thread sees 'INSERT' of existing key ==== |
| 8 |
---- Prepare slave so that it will get duplicate key error ---- |
| 9 |
INSERT INTO t1 VALUES (1); |
| 10 |
---- Insert rows on master ---- |
| 11 |
connection master; |
| 12 |
INSERT INTO t1 VALUES (1); |
| 13 |
SELECT * FROM t1; |
| 14 |
a |
| 15 |
1 |
| 16 |
connection slave; |
| 17 |
---- Wait until slave stops with an error ---- |
| 18 |
include/wait_for_slave_sql_error.inc [errno=1062] |
| 19 |
Last_SQL_Error (expected "duplicate key" error) |
| 20 |
Error 'Duplicate entry '1' for key 'PRIMARY'' on query. Default database: 'test'. Query: 'INSERT INTO t1 VALUES (1)' |
| 21 |
call mtr.add_suppression("Slave SQL.*Duplicate entry .1. for key .PRIMARY.* error.* 1062"); |
| 22 |
SELECT * FROM t1; |
| 23 |
a |
| 24 |
1 |
| 25 |
---- Resolve the conflict on the slave and restart SQL thread ---- |
| 26 |
DELETE FROM t1 WHERE a = 1; |
| 27 |
START SLAVE SQL_THREAD; |
| 28 |
include/wait_for_slave_sql_to_start.inc |
| 29 |
---- Sync slave and verify that there is no error ---- |
| 30 |
Last_SQL_Error = '' (expected no error) |
| 31 |
SELECT * FROM t1; |
| 32 |
a |
| 33 |
1 |
| 34 |
==== Test: SQL thread sees 'DELETE' of non-existing row ==== |
| 35 |
---- On master, insert two rows, the second with binlogging off ---- |
| 36 |
connection master; |
| 37 |
DELETE FROM t1; |
| 38 |
INSERT INTO t1 VALUES (1); |
| 39 |
connection slave; |
| 40 |
DELETE FROM t1 WHERE a = 1; |
| 41 |
---- On master, remove the row that does not exist on slave ---- |
| 42 |
connection master; |
| 43 |
DELETE FROM t1 WHERE a = 1; |
| 44 |
SELECT * FROM t1; |
| 45 |
a |
| 46 |
connection slave; |
| 47 |
---- Sync slave and verify that there is no error ---- |
| 48 |
Last_SQL_Error = (expected no error) |
| 49 |
SELECT * FROM t1; |
| 50 |
a |
| 51 |
==== Clean up ==== |
| 52 |
connection master; |
| 53 |
DROP TABLE t1; |
| 54 |
connection slave; |
| 55 |
include/rpl_end.inc |