| 1 |
################################################################################ |
| 2 |
# This test verifies the DML errors when replicating in a group |
| 3 |
# |
| 4 |
# Test: |
| 5 |
# 0. The test requires two servers: M1 and M2. |
| 6 |
# 1. With both members ONLINE. Create two tables. Insert data in each table. |
| 7 |
# 2. Now verify that DML(INSERT/UPDATE) operations with duplicate data, error |
| 8 |
# out gracefully. Thus, nothing is inserted/updated in such cases. Verify |
| 9 |
# the data on both the members M1 and M2. |
| 10 |
################################################################################ |
| 11 |
--source include/have_group_replication_plugin.inc |
| 12 |
--source include/group_replication.inc |
| 13 |
|
| 14 |
--echo # Verify the statements can be binlogged correctly when error happens |
| 15 |
|
| 16 |
CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=innodb; |
| 17 |
CREATE TABLE t2(c1 INT PRIMARY KEY) ENGINE=innodb; |
| 18 |
INSERT INTO t1 VALUES(1); |
| 19 |
INSERT INTO t2 VALUES(1); |
| 20 |
|
| 21 |
--echo |
| 22 |
--echo # Nothing is inserted. |
| 23 |
--let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1) |
| 24 |
|
| 25 |
--error 1062 |
| 26 |
INSERT INTO t1 VALUES(1),(2); |
| 27 |
source include/show_binlog_events.inc; |
| 28 |
|
| 29 |
--let $assert_text= No new row inserted in the table |
| 30 |
--let $assert_cond= [SELECT count(*) FROM t1] = 1 |
| 31 |
--source include/assert.inc |
| 32 |
|
| 33 |
--source include/rpl_sync.inc |
| 34 |
--let $diff_tables= server1:test.t1, server2:test.t1 |
| 35 |
--source include/diff_tables.inc |
| 36 |
|
| 37 |
--echo |
| 38 |
--echo # Nothing is inserted. |
| 39 |
|
| 40 |
--connection server1 |
| 41 |
--let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1) |
| 42 |
--error 1062 |
| 43 |
INSERT INTO t1 SELECT 1 UNION SELECT 2; |
| 44 |
--source include/show_binlog_events.inc |
| 45 |
|
| 46 |
# The row count will still be 1 |
| 47 |
--let $assert_text= The row count will still be 1 |
| 48 |
--let $assert_cond= [SELECT count(*) FROM t1] = 1 |
| 49 |
--source include/assert.inc |
| 50 |
|
| 51 |
--echo # 2 rows are inserted. |
| 52 |
INSERT INTO t1 SELECT 3 UNION SELECT 2; |
| 53 |
--source include/rpl_sync.inc |
| 54 |
|
| 55 |
# The row count will be 3 |
| 56 |
--let $assert_text= A row is inserted in the table t1 |
| 57 |
--let $assert_cond= [SELECT count(*) FROM t1] = 3 |
| 58 |
--source include/assert.inc |
| 59 |
|
| 60 |
--source include/diff_tables.inc |
| 61 |
|
| 62 |
--echo |
| 63 |
--echo # Nothing is updated. |
| 64 |
--connection server1 |
| 65 |
--let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1) |
| 66 |
--error 1062 |
| 67 |
UPDATE t1 SET c1=4; |
| 68 |
--source include/rpl_sync.inc |
| 69 |
|
| 70 |
--connection server1 |
| 71 |
--source include/diff_tables.inc |
| 72 |
--source include/show_binlog_events.inc |
| 73 |
|
| 74 |
--echo |
| 75 |
--echo # Nothing is updated. |
| 76 |
--connection server1 |
| 77 |
--error 1062 |
| 78 |
UPDATE t1, t2 SET t1.c1= 5, t2.c1=5; |
| 79 |
--source include/rpl_sync.inc |
| 80 |
|
| 81 |
--connection server1 |
| 82 |
--source include/diff_tables.inc |
| 83 |
--source include/show_binlog_events.inc |
| 84 |
|
| 85 |
DROP TABLE t1, t2; |
| 86 |
--source include/group_replication_end.inc |