diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index d9ee5980548..67c7f415a93 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -20326,9 +20326,12 @@ static xa_status_code innobase_commit_by_xid( trx_t *trx = trx_get_trx_by_xid(xid); if (trx != nullptr) { - TrxInInnoDB trx_in_innodb(trx); + { + TrxInInnoDB trx_in_innodb(trx); + + innobase_commit_low(trx); + } - innobase_commit_low(trx); ut_ad(trx->mysql_thd == nullptr); /* use cases are: disconnected xa, slave xa, recovery */ trx_deregister_from_2pc(trx); @@ -20354,9 +20357,13 @@ static xa_status_code innobase_rollback_by_xid( trx_t *trx = trx_get_trx_by_xid(xid); if (trx != nullptr) { - TrxInInnoDB trx_in_innodb(trx); + int ret; + + { + TrxInInnoDB trx_in_innodb(trx); - int ret = innobase_rollback_trx(trx); + ret = innobase_rollback_trx(trx); + } trx_deregister_from_2pc(trx); ut_ad(!trx->will_lock); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 98525d9302f..b3fed5d9c40 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -257,6 +257,9 @@ struct TrxFactory { trx->dict_operation_lock_mode = 0; + trx->in_innodb = 0; + trx->in_depth = 0; + trx->xid = ut::new_withkey(UT_NEW_THIS_FILE_PSI_KEY); trx->detailed_error = reinterpret_cast( @@ -492,6 +495,10 @@ static void trx_free(trx_t *&trx) { ut_ad(trx->read_view == nullptr); ut_ad(trx->is_dd_trx == false); + trx->in_innodb &= ~TRX_FORCE_ROLLBACK_DISABLE; + ut_a(trx->in_innodb == 0); + ut_a(trx->in_depth == 0); + /* trx locking state should have been reset before returning trx to pool */ ut_ad(trx->will_lock == 0);