Skip to content

Commit

Permalink
MDEV-30653 : With wsrep_mode=REPLICATE_ARIA only part of mixed-engine…
Browse files Browse the repository at this point in the history
… transactions is replicated

For both MyISAM and Aria Galera replication is experimental.
Problem was that both MyISAM and Aria do not support
2PC that is required if more than one storage engine
participates transaction. For Galera we return error if
transaction contains DML for MyISAM or Aria even if
user has requested replication for them.
  • Loading branch information
janlindstrom committed Aug 5, 2024
1 parent 79ba84a commit 5150106
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 96 deletions.
176 changes: 176 additions & 0 deletions mysql-test/suite/galera/r/MDEV-30653.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
connection node_2;
connection node_1;
connection node_1;
create table t1 (id serial not null primary key, val int) engine=innodb;
create table t2 (id serial not null primary key, val int) engine=aria;
insert into t1 values(1, 23);
insert into t2 values(2, 42);
begin;
update t1 set val=24 where id=1;
update t2 set val=41 where id=2;
commit;
ERROR HY000: Transactional commit not supported by involved engine(s)
SELECT * FROM t1;
id val
1 23
SELECT * FROM t2;
id val
2 41
connection node_2;
SELECT * FROM t1;
id val
1 23
SELECT * FROM t2;
id val
DROP TABLE t1, t2;
connection node_1;
SET GLOBAL wsrep_mode='REPLICATE_ARIA';
create table t1 (id serial not null primary key, val int) engine=innodb;
create table t2 (id serial not null primary key, val int) engine=aria;
insert into t1 values(1, 23);
insert into t2 values(2, 42);
begin;
update t1 set val=24 where id=1;
update t2 set val=41 where id=2;
ERROR HY000: Galera does not support transactions containing engines not supporting 2 phase commit
commit;
SELECT * FROM t1;
id val
1 24
SELECT * FROM t2;
id val
2 42
connection node_2;
SELECT * FROM t1;
id val
1 24
SELECT * FROM t2;
id val
2 42
DROP TABLE t1, t2;
connection node_1;
SET GLOBAL wsrep_mode='';
connection node_1;
SET GLOBAL wsrep_mode='REPLICATE_MYISAM';
create table t1 (id serial not null primary key, val int) engine=innodb;
create table t2 (id serial not null primary key, val int) engine=myisam;
insert into t1 values(1, 23);
insert into t2 values(2, 42);
begin;
update t1 set val=24 where id=1;
update t2 set val=41 where id=2;
ERROR HY000: Galera does not support transactions containing engines not supporting 2 phase commit
commit;
SELECT * FROM t1;
id val
1 24
SELECT * FROM t2;
id val
2 42
connection node_2;
SELECT * FROM t1;
id val
1 24
SELECT * FROM t2;
id val
2 42
DROP TABLE t1, t2;
connection node_1;
SET GLOBAL wsrep_mode='REPLICATE_MYISAM,REPLICATE_ARIA';
create table t1 (id serial not null primary key, val int) engine=innodb;
create table t2 (id serial not null primary key, val int) engine=myisam;
create table t3 (id serial not null primary key, val int) engine=aria;
insert into t1 values(1, 23);
insert into t2 values(2, 42);
insert into t3 values(3, 23);
begin;
update t1 set val=24 where id=1;
update t2 set val=41 where id=2;
ERROR HY000: Galera does not support transactions containing engines not supporting 2 phase commit
update t3 set val=24 where id=3;
ERROR HY000: Galera does not support transactions containing engines not supporting 2 phase commit
commit;
SELECT * FROM t1;
id val
1 24
SELECT * FROM t2;
id val
2 42
SELECT * FROM t3;
id val
3 23
connection node_2;
SELECT * FROM t1;
id val
1 24
SELECT * FROM t2;
id val
2 42
SELECT * FROM t3;
id val
3 23
DROP TABLE t1,t2,t3;
connection node_1;
SET GLOBAL wsrep_mode='REPLICATE_MYISAM,REPLICATE_ARIA';
create table t1 (id serial not null primary key, val int) engine=innodb;
create table t2 (id serial not null primary key, val int) engine=myisam;
create table t3 (id serial not null primary key, val int) engine=aria;
insert into t1 values(1, 23);
insert into t2 values(2, 42);
insert into t3 values(3, 23);
begin;
update t2 set val=411 where id=2;
ERROR HY000: Galera does not support transactions containing engines not supporting 2 phase commit
update t3 set val=500 where id=3;
ERROR HY000: Galera does not support transactions containing engines not supporting 2 phase commit
update t1 set val=241 where id=1;
commit;
SELECT * FROM t1;
id val
1 241
SELECT * FROM t2;
id val
2 42
SELECT * FROM t3;
id val
3 23
connection node_2;
SELECT * FROM t1;
id val
1 241
SELECT * FROM t2;
id val
2 42
SELECT * FROM t3;
id val
3 23
DROP TABLE t1, t2, t3;
connection node_1;
create table t1 (id serial not null primary key, val int) engine=myisam;
create table t2 (id serial not null primary key, val int) engine=aria;
insert into t1 values(1, 23);
insert into t2 values(2, 42);
begin;
update t1 set val=411 where id=2;
ERROR HY000: Galera does not support transactions containing engines not supporting 2 phase commit
commit;
begin;
update t2 set val=411 where id=2;
ERROR HY000: Galera does not support transactions containing engines not supporting 2 phase commit
commit;
SELECT * FROM t1;
id val
1 23
SELECT * FROM t2;
id val
2 42
connection node_2;
SELECT * FROM t1;
id val
1 23
SELECT * FROM t2;
id val
2 42
DROP TABLE t1, t2;
connection node_1;
SET GLOBAL wsrep_mode='';
22 changes: 4 additions & 18 deletions mysql-test/suite/galera/r/galera_var_replicate_aria_on.result
Original file line number Diff line number Diff line change
Expand Up @@ -103,33 +103,19 @@ connection node_1;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (2);
ERROR HY000: Galera does not support transactions containing engines not supporting 2 phase commit
INSERT INTO t2 VALUES (2);
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
connection node_2;
SELECT COUNT(*) AS EXPECT_2 FROM t1;
EXPECT_2
2
SELECT COUNT(*) AS EXPECT_1 FROM t1;
EXPECT_1
1
SELECT COUNT(*) AS EXPECT_1 FROM t2;
EXPECT_1
1
connection node_1;
DROP TABLE t1,t2;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=Aria;
CREATE TABLE t2 (f2 INTEGER PRIMARY KEY) ENGINE=InnoDB;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
connection node_2;
INSERT INTO t1 VALUES (1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
connection node_1;
COMMIT;
ERROR HY000: Transactional commit not supported by involved engine(s)
DROP TABLE t1,t2;
connection node_1;
CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE=INNODB;
INSERT INTO t1 VALUES(1);
SELECT * FROM t1;
Expand Down
28 changes: 8 additions & 20 deletions mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,32 @@ CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
ERROR HY000: Galera does not support transactions containing engines not supporting 2 phase commit
INSERT INTO t2 VALUES (1);
COMMIT;
connection node_2;
SELECT COUNT(*) AS EXPECT_1 FROM t1;
EXPECT_1
1
SELECT COUNT(*) AS EXPECT_0 FROM t1;
EXPECT_0
0
SELECT COUNT(*) AS EXPECT_1 FROM t2;
EXPECT_1
1
connection node_1;
START TRANSACTION;
INSERT INTO t1 VALUES (2);
ERROR HY000: Galera does not support transactions containing engines not supporting 2 phase commit
INSERT INTO t2 VALUES (2);
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
connection node_2;
SELECT COUNT(*) AS EXPECT_2 FROM t1;
EXPECT_2
2
SELECT COUNT(*) AS EXPECT_0 FROM t1;
EXPECT_0
0
SELECT COUNT(*) AS EXPECT_1 FROM t2;
EXPECT_1
1
DROP TABLE t1;
DROP TABLE t2;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=MyISAM;
CREATE TABLE t2 (f2 INTEGER PRIMARY KEY) ENGINE=InnoDB;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
connection node_2;
INSERT INTO t1 VALUES (1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
connection node_1;
COMMIT;
DROP TABLE t1, t2;
connection node_1;
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, b INT) ENGINE=MyISAM;
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10);
PREPARE upd from 'update t1 set b = 100 where id = 5';
Expand Down
Loading

0 comments on commit 5150106

Please sign in to comment.