| 1 |
include/master-slave.inc |
| 2 |
[connection master] |
| 3 |
connection slave; |
| 4 |
call mtr.add_suppression("Slave: Can\'t find record in \'t1\' error.* .*"); |
| 5 |
call mtr.add_suppression("Can't find record in 't.'"); |
| 6 |
connection slave; |
| 7 |
SET @old_slave_exec_mode= @@global.slave_exec_mode; |
| 8 |
######## Run with slave_exec_mode=STRICT ######## |
| 9 |
SET @@global.slave_exec_mode = 'STRICT'; |
| 10 |
==== Initialize ==== |
| 11 |
connection master; |
| 12 |
CREATE TABLE t1(a INT PRIMARY KEY); |
| 13 |
connection slave; |
| 14 |
==== Test: SQL thread sees 'INSERT' of existing key ==== |
| 15 |
---- Prepare slave so that it will get duplicate key error ---- |
| 16 |
INSERT INTO t1 VALUES (1); |
| 17 |
---- Insert rows on master ---- |
| 18 |
connection master; |
| 19 |
INSERT INTO t1 VALUES (1); |
| 20 |
SELECT * FROM t1; |
| 21 |
a |
| 22 |
1 |
| 23 |
connection slave; |
| 24 |
---- Wait until slave stops with an error ---- |
| 25 |
include/wait_for_slave_sql_error.inc [errno=1062] |
| 26 |
Last_SQL_Error (expected "duplicate key" error) |
| 27 |
Could not execute Write_rows_v1 event on table test.t1; Duplicate entry '1' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log master-bin.000001, end_log_pos END_LOG_POS |
| 28 |
call mtr.add_suppression("Slave SQL.*Duplicate entry .1. for key .PRIMARY.* error.* 1062"); |
| 29 |
SELECT * FROM t1; |
| 30 |
a |
| 31 |
1 |
| 32 |
---- Resolve the conflict on the slave and restart SQL thread ---- |
| 33 |
DELETE FROM t1 WHERE a = 1; |
| 34 |
START SLAVE SQL_THREAD; |
| 35 |
include/wait_for_slave_sql_to_start.inc |
| 36 |
---- Sync slave and verify that there is no error ---- |
| 37 |
Last_SQL_Error = '' (expected no error) |
| 38 |
SELECT * FROM t1; |
| 39 |
a |
| 40 |
1 |
| 41 |
==== Test: SQL thread sees 'DELETE' of non-existing row ==== |
| 42 |
---- On master, insert two rows, the second with binlogging off ---- |
| 43 |
connection master; |
| 44 |
DELETE FROM t1; |
| 45 |
INSERT INTO t1 VALUES (1); |
| 46 |
connection slave; |
| 47 |
DELETE FROM t1 WHERE a = 1; |
| 48 |
---- On master, remove the row that does not exist on slave ---- |
| 49 |
connection master; |
| 50 |
DELETE FROM t1 WHERE a = 1; |
| 51 |
SELECT * FROM t1; |
| 52 |
a |
| 53 |
connection slave; |
| 54 |
---- Wait until slave stops with an error ---- |
| 55 |
call mtr.add_suppression("Slave SQL.*Can.t find record in .t1., error.* 1032"); |
| 56 |
include/wait_for_slave_sql_error.inc [errno=1032] |
| 57 |
Last_SQL_Error (expected "duplicate key" error) |
| 58 |
Could not execute Delete_rows_v1 event on table test.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log master-bin.000001, end_log_pos END_LOG_POS |
| 59 |
SELECT * FROM t1; |
| 60 |
a |
| 61 |
---- Resolve the conflict on the slave and restart SQL thread ---- |
| 62 |
INSERT INTO t1 VALUES (1); |
| 63 |
START SLAVE SQL_THREAD; |
| 64 |
include/wait_for_slave_sql_to_start.inc |
| 65 |
---- Sync slave and verify that there is no error ---- |
| 66 |
Last_SQL_Error = (expected no error) |
| 67 |
SELECT * FROM t1; |
| 68 |
a |
| 69 |
==== Clean up ==== |
| 70 |
connection master; |
| 71 |
DROP TABLE t1; |
| 72 |
connection slave; |
| 73 |
include/rpl_reset.inc |
| 74 |
######## Run with slave_exec_mode=IDEMPOTENT ######## |
| 75 |
set @@global.slave_exec_mode= 'IDEMPOTENT'; |
| 76 |
==== Initialize ==== |
| 77 |
connection master; |
| 78 |
CREATE TABLE t1(a INT PRIMARY KEY); |
| 79 |
connection slave; |
| 80 |
==== Test: SQL thread sees 'INSERT' of existing key ==== |
| 81 |
---- Prepare slave so that it will get duplicate key error ---- |
| 82 |
INSERT INTO t1 VALUES (1); |
| 83 |
---- Insert rows on master ---- |
| 84 |
connection master; |
| 85 |
INSERT INTO t1 VALUES (1); |
| 86 |
SELECT * FROM t1; |
| 87 |
a |
| 88 |
1 |
| 89 |
connection slave; |
| 90 |
---- Sync slave and verify that there is no error ---- |
| 91 |
Last_SQL_Error = '' (expected no error) |
| 92 |
SELECT * FROM t1; |
| 93 |
a |
| 94 |
1 |
| 95 |
==== Test: SQL thread sees 'DELETE' of non-existing row ==== |
| 96 |
---- On master, insert two rows, the second with binlogging off ---- |
| 97 |
connection master; |
| 98 |
DELETE FROM t1; |
| 99 |
INSERT INTO t1 VALUES (1); |
| 100 |
connection slave; |
| 101 |
DELETE FROM t1 WHERE a = 1; |
| 102 |
---- On master, remove the row that does not exist on slave ---- |
| 103 |
connection master; |
| 104 |
DELETE FROM t1 WHERE a = 1; |
| 105 |
SELECT * FROM t1; |
| 106 |
a |
| 107 |
connection slave; |
| 108 |
---- Sync slave and verify that there is no error ---- |
| 109 |
Last_SQL_Error = (expected no error) |
| 110 |
SELECT * FROM t1; |
| 111 |
a |
| 112 |
==== Clean up ==== |
| 113 |
connection master; |
| 114 |
DROP TABLE t1; |
| 115 |
connection slave; |
| 116 |
SET @@global.slave_exec_mode= @old_slave_exec_mode; |
| 117 |
include/rpl_end.inc |