| 1 |
# |
| 2 |
# Test the case where a duplicate key error happens in the middle of an SR transaction |
| 3 |
# |
| 4 |
|
| 5 |
--source include/galera_cluster.inc |
| 6 |
|
| 7 |
CREATE TABLE t1 (f1 BLOB) ENGINE=InnoDB; |
| 8 |
CREATE UNIQUE INDEX i1 ON t1 (f1(512)); |
| 9 |
|
| 10 |
SET AUTOCOMMIT=OFF; |
| 11 |
START TRANSACTION; |
| 12 |
SET SESSION wsrep_trx_fragment_size = 1024; |
| 13 |
|
| 14 |
INSERT INTO t1 VALUES (REPEAT('a', 512)); |
| 15 |
INSERT INTO t1 VALUES (REPEAT('b', 512)); |
| 16 |
INSERT INTO t1 VALUES (REPEAT('c', 512)); |
| 17 |
INSERT INTO t1 VALUES (REPEAT('d', 512)); |
| 18 |
INSERT INTO t1 VALUES (REPEAT('e', 512)); |
| 19 |
INSERT INTO t1 VALUES (REPEAT('f', 512)); |
| 20 |
|
| 21 |
--connection node_2 |
| 22 |
--let $wait_condition = SELECT COUNT(*) > 0 FROM mysql.wsrep_streaming_log; |
| 23 |
|
| 24 |
--connection node_1 |
| 25 |
# Deadlock error instead of dupkey since the transaction is SR, |
| 26 |
# and the statement has already replicated a fragment (which |
| 27 |
# makes statement rollback unsafe). |
| 28 |
--error ER_LOCK_DEADLOCK |
| 29 |
INSERT INTO t1 VALUES (REPEAT('g', 1024)),(REPEAT('c', 512)); |
| 30 |
|
| 31 |
# Confirm that the wsrep_schema table is now empty, as it was a full transaction rollback |
| 32 |
|
| 33 |
--connection node_1 |
| 34 |
SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log; |
| 35 |
--connection node_2 |
| 36 |
SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log; |
| 37 |
|
| 38 |
# Confirm that the transaction can be restarted on either node |
| 39 |
|
| 40 |
--connection node_1 |
| 41 |
SET innodb_snapshot_isolation=OFF; |
| 42 |
INSERT INTO t1 VALUES (REPEAT('d', 512)); |
| 43 |
INSERT INTO t1 VALUES (REPEAT('e', 512)); |
| 44 |
INSERT INTO t1 VALUES (REPEAT('f', 512)); |
| 45 |
COMMIT; |
| 46 |
|
| 47 |
--connection node_2 |
| 48 |
SET AUTOCOMMIT=OFF; |
| 49 |
START TRANSACTION; |
| 50 |
INSERT INTO t1 VALUES (REPEAT('a', 512)); |
| 51 |
INSERT INTO t1 VALUES (REPEAT('b', 512)); |
| 52 |
INSERT INTO t1 VALUES (REPEAT('c', 512)); |
| 53 |
COMMIT; |
| 54 |
|
| 55 |
--connection node_1 |
| 56 |
SELECT COUNT(*) = 6 FROM t1; |
| 57 |
|
| 58 |
--connection node_2 |
| 59 |
SELECT COUNT(*) = 6 FROM t1; |
| 60 |
|
| 61 |
DROP TABLE t1; |