Skip to content

Commit 210db29

Browse files
denis-protivenskysysprg
authored andcommitted
MDEV-30804 Rollback multi-engine transaction requiring 2PC but committing in one phase
Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
1 parent 75063d1 commit 210db29

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
connection node_2;
2+
connection node_1;
3+
CREATE TABLE t (a INT) ENGINE=Aria;
4+
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
5+
START TRANSACTION;
6+
INSERT INTO t VALUES ('1');
7+
INSERT INTO t1 VALUES ('1');
8+
COMMIT;
9+
ERROR HY000: Transactional commit not supported by involved engine(s)
10+
DROP TABLE t;
11+
DROP TABLE t1;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
!include ../galera_2nodes.cnf
2+
3+
[mysqld.1]
4+
log-bin
5+
6+
[mysqld.2]
7+
log-bin
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Test that transaction requiring two-phase commit and involving
3+
# storage engines not supporting it rolls back with a message.
4+
#
5+
6+
--source include/galera_cluster.inc
7+
--source include/have_innodb.inc
8+
--source include/have_aria.inc
9+
10+
CREATE TABLE t (a INT) ENGINE=Aria;
11+
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
12+
13+
START TRANSACTION;
14+
INSERT INTO t VALUES ('1');
15+
INSERT INTO t1 VALUES ('1');
16+
17+
--error ER_ERROR_DURING_COMMIT
18+
COMMIT;
19+
20+
DROP TABLE t;
21+
DROP TABLE t1;

sql/handler.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,19 @@ int ha_commit_trans(THD *thd, bool all)
17331733
ordering is normally done. Commit ordering must be done here.
17341734
*/
17351735
if (run_wsrep_hooks)
1736-
error= wsrep_before_commit(thd, all);
1736+
{
1737+
// This commit involves more than one storage engine and requires
1738+
// two phases, but some engines don't support it.
1739+
// Issue a message to the client and roll back the transaction.
1740+
if (trans->no_2pc && rw_ha_count > 1)
1741+
{
1742+
my_message(ER_ERROR_DURING_COMMIT, "Transactional commit not supported "
1743+
"by involved engine(s)", MYF(0));
1744+
error= 1;
1745+
}
1746+
else
1747+
error= wsrep_before_commit(thd, all);
1748+
}
17371749
if (error)
17381750
{
17391751
ha_rollback_trans(thd, FALSE);

0 commit comments

Comments
 (0)