Skip to content

Commit 288db5f

Browse files
committed
MDEV-24981 LOAD INDEX may cause rollback of prepared XA transaction
XAER_RMFAIL means the admin statement was not allowed, it's not a per-table message, so must fail the whole statement. And must not rollback, obviously, it's not allowed after prepare. Also, remove duplicate XAER_RMFAIL in open_tables(), check_has_uncommitted_xa() already issues it.
1 parent d6cb725 commit 288db5f

File tree

4 files changed

+40
-11
lines changed

4 files changed

+40
-11
lines changed

mysql-test/main/xa.result

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction");
2-
drop table if exists t1, t2;
32
create table t1 (a int) engine=innodb;
43
xa start 'test1';
54
insert t1 values (10);
@@ -595,6 +594,26 @@ formatID gtrid_length bqual_length data
595594
xa rollback '4';
596595
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
597596
set @@global.read_only=@sav_read_only;
598-
#
599597
# End of 10.5 tests
600598
#
599+
# MDEV-24981 LOAD INDEX may cause rollback of prepared XA transaction
600+
#
601+
create table t1 (f1 integer primary key) engine=innodb;
602+
show create table t1;
603+
Table Create Table
604+
t1 CREATE TABLE `t1` (
605+
`f1` int(11) NOT NULL,
606+
PRIMARY KEY (`f1`)
607+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
608+
xa start 'a';
609+
insert into t1 values (1);
610+
xa end 'a';
611+
xa prepare 'a';
612+
load index into cache t1 key(primary);
613+
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
614+
xa commit 'a';
615+
select count(*) from t1;
616+
count(*)
617+
1
618+
drop table t1;
619+
# End of 10.11 tests

mysql-test/main/xa.test

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# WL#1756
33
#
4-
-- source include/have_innodb.inc
4+
--source include/have_innodb.inc
55
--source include/not_embedded.inc
66

77
# Save the initial number of concurrent sessions
@@ -12,10 +12,6 @@ call mtr.add_suppression("Deadlock found when trying to get lock; try restarting
1212
call mtr.add_suppression("InnoDB: Transaction was aborted due to ");
1313
--enable_query_log
1414

15-
16-
--disable_warnings
17-
drop table if exists t1, t2;
18-
--enable_warnings
1915
create table t1 (a int) engine=innodb;
2016
xa start 'test1';
2117
insert t1 values (10);
@@ -752,7 +748,21 @@ xa rollback '4';
752748

753749
set @@global.read_only=@sav_read_only;
754750

751+
--echo # End of 10.5 tests
755752

756753
--echo #
757-
--echo # End of 10.5 tests
754+
--echo # MDEV-24981 LOAD INDEX may cause rollback of prepared XA transaction
758755
--echo #
756+
create table t1 (f1 integer primary key) engine=innodb;
757+
show create table t1;
758+
xa start 'a';
759+
insert into t1 values (1);
760+
xa end 'a';
761+
xa prepare 'a';
762+
--error ER_XAER_RMFAIL
763+
load index into cache t1 key(primary);
764+
xa commit 'a';
765+
select count(*) from t1;
766+
drop table t1;
767+
768+
--echo # End of 10.11 tests

sql/sql_admin.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
565565
Disable_wsrep_on_guard wsrep_on_guard(thd, disable_wsrep_on);
566566
#endif /* WITH_WSREP */
567567

568+
if (thd->transaction->xid_state.check_has_uncommitted_xa())
569+
DBUG_RETURN(TRUE);
570+
568571
fill_check_table_metadata_fields(thd, &field_list);
569572

570573
if (protocol->send_result_set_metadata(&field_list,

sql/sql_base.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4598,10 +4598,7 @@ bool open_tables(THD *thd, const DDL_options_st &options,
45984598
if (!table->schema_table)
45994599
{
46004600
if (thd->transaction->xid_state.check_has_uncommitted_xa())
4601-
{
4602-
thd->transaction->xid_state.er_xaer_rmfail();
46034601
DBUG_RETURN(true);
4604-
}
46054602
else
46064603
break;
46074604
}

0 commit comments

Comments
 (0)