commit 3d05780f5723d8918dc5769016674322e7f26ebd Author: wenfeng.zhang Date: Wed Apr 8 18:08:43 2020 +0800 how to repeat xa_prepare bug diff --git a/mysql-test/t/xa_prepare_bug.test b/mysql-test/t/xa_prepare_bug.test new file mode 100644 index 00000000000..1fbce97c410 --- /dev/null +++ b/mysql-test/t/xa_prepare_bug.test @@ -0,0 +1,12 @@ +create table t1 (c1 int primary key); +insert into t1 values (1); +xa start '1'; +delete from t1 where c1=1; +xa end '1'; +SET SESSION DEBUG='+d,test_xa_prepare_failed'; +--error ER_XA_RBROLLBACK +xa prepare '1'; +select * from t1; +xa recover; +show binlog events; + diff --git a/sql/handler.cc b/sql/handler.cc index 6d576c3fd03..be6dad4046d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1380,6 +1380,11 @@ static int prepare_one_ht(THD *thd, handlerton *ht) { ha_rollback_trans(thd, true); return 1; }); + if (DBUG_EVALUATE_IF("test_xa_prepare_failed", true, false) && + ht->db_type != DB_TYPE_BINLOG) { + ha_rollback_trans(thd, true); + return 1; + } if (ht->prepare(ht, thd, true)) { ha_rollback_trans(thd, true); return 1;