summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera_sr/r
diff options
context:
space:
mode:
authorDaniele Sciascia <daniele.sciascia@galeracluster.com>2020-03-21 08:17:28 +0100
committerGitHub <noreply@github.com>2020-03-21 09:17:28 +0200
commit9394cc89143e4fce3126a96ac1c8a91a66d71dea (patch)
treed21d24e28e3c28ac25815e4509b146f5e9774d97 /mysql-test/suite/galera_sr/r
parentbd3c8f47cd16b4795dd073bbd30decd804c76969 (diff)
downloadmariadb-git-9394cc89143e4fce3126a96ac1c8a91a66d71dea.tar.gz
MDEV-21675: Data inconsistency after multirow insert rollback (#1474)
* Remove dead code * MDEV-21675 Data inconsistency after multirow insert rollback This patch fixes data inconsistencies that happen after rollback of multirow inserts, with binlog disabled. For example, statements such as `INSERT INTO t1 VALUES (1,'a'),(1,'b')` that fail with duplicate key error. In such cases the whole statement is rolled back. However, with wsrep_emulate_binlog in effect, the IO_CACHE would not be truncated, and the pending rows events would be replicated to the rest of the cluster. In the above example, it would result in row (1,'a') being replicated, whereas locally the statement is rolled back entirely. Making the cluster inconsistent. The patch changes the code so that prior to statement rollback, pending rows event are removed and the stmt cache reset. That patch also introduces MTR tests that excercise multirow insert statements for regular, and streaming replication.
Diffstat (limited to 'mysql-test/suite/galera_sr/r')
-rw-r--r--mysql-test/suite/galera_sr/r/galera_sr_multirow_rollback.result127
1 files changed, 127 insertions, 0 deletions
diff --git a/mysql-test/suite/galera_sr/r/galera_sr_multirow_rollback.result b/mysql-test/suite/galera_sr/r/galera_sr_multirow_rollback.result
new file mode 100644
index 00000000000..1795d16bbfa
--- /dev/null
+++ b/mysql-test/suite/galera_sr/r/galera_sr_multirow_rollback.result
@@ -0,0 +1,127 @@
+connection node_2;
+connection node_1;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY DEFAULT 0, f2 char(12));
+connection node_1;
+SET SESSION wsrep_trx_fragment_size = 1;
+START TRANSACTION;
+INSERT INTO t1 (f2) VALUES ('a'), ('b');
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+COMMIT;
+SELECT COUNT(*) AS expect_0 FROM t1;
+expect_0
+0
+connection node_2;
+SELECT COUNT(*) AS expect_0 FROM t1;
+expect_0
+0
+DROP TABLE t1;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY DEFAULT 0, f2 char(12));
+connection node_1;
+SET SESSION wsrep_trx_fragment_size = 1000;
+START TRANSACTION;
+INSERT INTO t1 (f2) VALUES ('a'), ('b');
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+COMMIT;
+SELECT COUNT(*) AS expect_0 FROM t1;
+expect_0
+0
+connection node_2;
+SELECT COUNT(*) AS expect_0 FROM t1;
+expect_0
+0
+DROP TABLE t1;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY DEFAULT 0, f2 char(12));
+connection node_1;
+SET SESSION wsrep_trx_fragment_size = 1000;
+START TRANSACTION;
+INSERT INTO t1 VALUES (1, 'a');
+INSERT INTO t1 VALUES (2, 'b');
+INSERT INTO t1 (f2) VALUES ('c'), ('d');
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+COMMIT;
+expect (1,'a'), (2, 'b')
+SELECT * FROM t1;
+f1 f2
+1 a
+2 b
+connection node_2;
+expect (1,'a'), (2, 'b')
+SELECT * FROM t1;
+f1 f2
+1 a
+2 b
+DROP TABLE t1;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY DEFAULT 0, f2 char(12));
+connection node_1;
+SET SESSION wsrep_trx_fragment_size = 1;
+INSERT INTO t1 (f2) VALUES ('a'), ('b');
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+SELECT COUNT(*) AS expect_0 FROM t1;
+expect_0
+0
+connection node_2;
+SELECT COUNT(*) AS expect_0 FROM t1;
+expect_0
+0
+connection node_1;
+SET SESSION wsrep_trx_fragment_size = 1000;
+INSERT INTO t1 (f2) VALUES ('a'), ('b');
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+SELECT COUNT(*) AS expect_0 FROM t1;
+expect_0
+0
+connection node_2;
+SELECT COUNT(*) AS expect_0 FROM t1;
+expect_0
+0
+DROP TABLE t1;
+connection node_1;
+CREATE TABLE p(id int primary key, j int) ENGINE=InnoDB;
+CREATE TABLE c(id int primary key, fk1 int) ENGINE=InnoDB;
+ALTER TABLE c ADD FOREIGN KEY (fk1) references p(id);
+INSERT INTO p VALUES(1, 0);
+SET SESSION wsrep_trx_fragment_size=1;
+START TRANSACTION;
+INSERT INTO c VALUES (3,1);
+INSERT INTO c VALUES (1,1), (2,2);
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+COMMIT;
+SELECT * FROM p;
+id j
+1 0
+SELECT * FROM c;
+id fk1
+connection node_2;
+SELECT * FROM p;
+id j
+1 0
+SELECT * FROM c;
+id fk1
+DROP TABLE c;
+DROP TABLE p;
+connection node_1;
+CREATE TABLE p(id int primary key, j int) ENGINE=InnoDB;
+CREATE TABLE c(id int primary key, fk1 int) ENGINE=InnoDB;
+ALTER TABLE c ADD FOREIGN KEY (fk1) references p(id);
+INSERT INTO p VALUES(1, 0);
+SET SESSION wsrep_trx_fragment_size=1000;
+START TRANSACTION;
+INSERT INTO c VALUES (3,1);
+INSERT INTO c VALUES (1,1), (2,2);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`c`, CONSTRAINT `c_ibfk_1` FOREIGN KEY (`fk1`) REFERENCES `p` (`id`))
+COMMIT;
+SELECT * FROM p;
+id j
+1 0
+SELECT * FROM c;
+id fk1
+3 1
+connection node_2;
+SELECT * FROM p;
+id j
+1 0
+SELECT * FROM c;
+id fk1
+3 1
+DROP TABLE c;
+DROP TABLE p;