diff --git a/mysql-8.0.32/storage/innobase/include/trx0trx.h b/mysql-8.0.32/storage/innobase/include/trx0trx.h index 8190ea4..5bf5e8c 100644 --- a/mysql-8.0.32/storage/innobase/include/trx0trx.h +++ b/mysql-8.0.32/storage/innobase/include/trx0trx.h @@ -909,6 +909,7 @@ struct trx_t { change, and must flush */ bool in_truncate; /* This trx is doing truncation */ + bool recover_scanned; /* Fields protected by the srv_conc_mutex. */ bool declared_to_be_inside_innodb; /*!< this is true if we have declared diff --git a/mysql-8.0.32/storage/innobase/trx/trx0trx.cc b/mysql-8.0.32/storage/innobase/trx/trx0trx.cc index 29a5a9b..d350018 100644 --- a/mysql-8.0.32/storage/innobase/trx/trx0trx.cc +++ b/mysql-8.0.32/storage/innobase/trx/trx0trx.cc @@ -197,6 +197,8 @@ static void trx_init(trx_t *trx) { trx->internal = false; trx->in_truncate = false; + + trx->recover_scanned = false; #ifdef UNIV_DEBUG trx->is_dd_trx = false; trx->in_rollback = false; @@ -3165,7 +3167,7 @@ int trx_recover_for_mysql( trx_sys_mutex_enter(); - for (const trx_t *trx : trx_sys->rw_trx_list) { + for (trx_t *trx : trx_sys->rw_trx_list) { assert_trx_in_rw_list(trx); /* The state of a read-write transaction cannot change @@ -3173,6 +3175,11 @@ int trx_recover_for_mysql( trx_sys->mutex. It may change to PREPARED, but not if trx->is_recovered. */ if (trx_state_eq(trx, TRX_STATE_PREPARED)) { + + if (trx->recover_scanned) { + continue; + } + if (get_info_about_prepared_transaction(&txn_list[count], trx, mem_root)) break; @@ -3188,6 +3195,7 @@ int trx_recover_for_mysql( << "Transaction contains changes to " << trx->undo_no << " rows"; count++; + trx->recover_scanned = true; if (count == len) { break;