diff --git a/mysql-test/main/xa.result b/mysql-test/main/xa.result index f0544fe50dd..cacd484707f 100644 --- a/mysql-test/main/xa.result +++ b/mysql-test/main/xa.result @@ -1,5 +1,4 @@ call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction"); -drop table if exists t1, t2; create table t1 (a int) engine=innodb; xa start 'test1'; insert t1 values (10); @@ -595,6 +594,26 @@ formatID gtrid_length bqual_length data xa rollback '4'; ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back set @@global.read_only=@sav_read_only; -# # End of 10.5 tests # +# MDEV-24981 LOAD INDEX may cause rollback of prepared XA transaction +# +create table t1 (f1 integer primary key) engine=innodb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + PRIMARY KEY (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +xa start 'a'; +insert into t1 values (1); +xa end 'a'; +xa prepare 'a'; +load index into cache t1 key(primary); +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state +xa commit 'a'; +select count(*) from t1; +count(*) +1 +drop table t1; +# End of 10.11 tests diff --git a/mysql-test/main/xa.test b/mysql-test/main/xa.test index c77f11761d8..12ff85476f8 100644 --- a/mysql-test/main/xa.test +++ b/mysql-test/main/xa.test @@ -1,7 +1,7 @@ # # WL#1756 # --- source include/have_innodb.inc +--source include/have_innodb.inc --source include/not_embedded.inc # Save the initial number of concurrent sessions @@ -12,10 +12,6 @@ call mtr.add_suppression("Deadlock found when trying to get lock; try restarting call mtr.add_suppression("InnoDB: Transaction was aborted due to "); --enable_query_log - ---disable_warnings -drop table if exists t1, t2; ---enable_warnings create table t1 (a int) engine=innodb; xa start 'test1'; insert t1 values (10); @@ -752,7 +748,21 @@ xa rollback '4'; set @@global.read_only=@sav_read_only; +--echo # End of 10.5 tests --echo # ---echo # End of 10.5 tests +--echo # MDEV-24981 LOAD INDEX may cause rollback of prepared XA transaction --echo # +create table t1 (f1 integer primary key) engine=innodb; +show create table t1; +xa start 'a'; +insert into t1 values (1); +xa end 'a'; +xa prepare 'a'; +--error ER_XAER_RMFAIL +load index into cache t1 key(primary); +xa commit 'a'; +select count(*) from t1; +drop table t1; + +--echo # End of 10.11 tests diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 3b6a73f95c5..bb318355422 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -565,6 +565,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, Disable_wsrep_on_guard wsrep_on_guard(thd, disable_wsrep_on); #endif /* WITH_WSREP */ + if (thd->transaction->xid_state.check_has_uncommitted_xa()) + DBUG_RETURN(TRUE); + fill_check_table_metadata_fields(thd, &field_list); if (protocol->send_result_set_metadata(&field_list, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index dcf2c35365b..ad514b73742 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4598,10 +4598,7 @@ bool open_tables(THD *thd, const DDL_options_st &options, if (!table->schema_table) { if (thd->transaction->xid_state.check_has_uncommitted_xa()) - { - thd->transaction->xid_state.er_xaer_rmfail(); DBUG_RETURN(true); - } else break; }