From a0c79bcf0062adc2489f0b0bed98b05d4db8f476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 30 Mar 2017 08:46:12 +0300 Subject: [PATCH] Rename InnoDB transaction undo logging predicates. trx::has_logged_persistent(): Renamed from trx_is_redo_rseg_updated(). Determines if a transaction has generated any persistent undo log. trx::has_logged(): Renamed from trx_is_rseg_updated(). Determines if a transaction has generated any undo log. --- storage/innobase/handler/ha_innodb.cc | 12 +++++------- storage/innobase/handler/handler0alter.cc | 2 +- storage/innobase/include/trx0trx.h | 21 +++++++++++++-------- storage/innobase/include/trx0trx.ic | 23 ----------------------- storage/innobase/trx/trx0roll.cc | 6 +++--- storage/innobase/trx/trx0trx.cc | 8 ++++---- 6 files changed, 26 insertions(+), 46 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 869864e303c..3dc22fe58d8 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5017,8 +5017,6 @@ innobase_rollback_trx( /*==================*/ trx_t* trx) /*!< in: transaction */ { - dberr_t error = DB_SUCCESS; - DBUG_ENTER("innobase_rollback_trx"); DBUG_PRINT("trans", ("aborting transaction")); @@ -5037,13 +5035,13 @@ innobase_rollback_trx( lock_unlock_table_autoinc(trx); } - if (trx_is_rseg_updated(trx)) { - error = trx_rollback_for_mysql(trx); - } else { + if (!trx->has_logged()) { trx->will_lock = 0; + DBUG_RETURN(0); } - DBUG_RETURN(convert_error_code_to_mysql(error, 0, trx->mysql_thd)); + DBUG_RETURN(convert_error_code_to_mysql(trx_rollback_for_mysql(trx), + 0, trx->mysql_thd)); } @@ -5397,7 +5395,7 @@ innobase_close_connection( in the 1st and 3rd case. */ if (trx_is_started(trx)) { if (trx_state_eq(trx, TRX_STATE_PREPARED)) { - if (trx_is_redo_rseg_updated(trx)) { + if (trx->has_logged_persistent()) { trx_disconnect_prepared(trx); } else { trx_rollback_for_mysql(trx); diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index fd61db9725d..27fa7e84aa3 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -8610,7 +8610,7 @@ ha_innobase::commit_inplace_alter_table( trx_rollback_for_mysql(trx); } else { ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE)); - ut_ad(trx_is_rseg_updated(trx)); + ut_ad(trx->has_logged()); if (mtr.get_log()->size() > 0) { ut_ad(*mtr.get_log()->front()->begin() diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 2b42d15731d..7da3bfb5459 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -579,13 +579,6 @@ Kill all transactions that are blocking this transaction from acquiring locks. void trx_kill_blocking(trx_t* trx); -/** -Check if redo/noredo rseg is modified for insert/update. -@param[in] trx Transaction to check */ -UNIV_INLINE -bool -trx_is_rseg_updated(const trx_t* trx); - /** Transactions that aren't started by the MySQL server don't set the trx_t::mysql_thd field. For such transactions we set the lock @@ -645,7 +638,7 @@ Check transaction state */ #define assert_trx_is_free(t) do { \ ut_ad(trx_state_eq((t), TRX_STATE_NOT_STARTED) \ || trx_state_eq((t), TRX_STATE_FORCED_ROLLBACK)); \ - ut_ad(!trx_is_rseg_updated(trx)); \ + ut_ad(!trx->has_logged()); \ ut_ad(!MVCC::is_view_active((t)->read_view)); \ ut_ad((t)->lock.wait_thr == NULL); \ ut_ad(UT_LIST_GET_LEN((t)->lock.trx_locks) == 0); \ @@ -1290,6 +1283,18 @@ struct trx_t { #endif /* WITH_WSREP */ ulint magic_n; + + /** @return whether any persistent undo log has been generated */ + bool has_logged_persistent() const + { + return(rsegs.m_redo.insert_undo || rsegs.m_redo.update_undo); + } + + /** @return whether any undo log has been generated */ + bool has_logged() const + { + return(has_logged_persistent() || rsegs.m_noredo.undo); + } }; /** diff --git a/storage/innobase/include/trx0trx.ic b/storage/innobase/include/trx0trx.ic index e5fdcec919a..6fa00c5333f 100644 --- a/storage/innobase/include/trx0trx.ic +++ b/storage/innobase/include/trx0trx.ic @@ -213,29 +213,6 @@ ok: trx->dict_operation = op; } -/********************************************************************//** -Check if redo rseg is modified for insert/update. */ -UNIV_INLINE -bool -trx_is_redo_rseg_updated( -/*=====================*/ - const trx_t* trx) /*!< in: transaction */ -{ - return(trx->rsegs.m_redo.insert_undo != 0 - || trx->rsegs.m_redo.update_undo != 0); -} - -/********************************************************************//** -Check if redo/noredo rseg is modified for insert/update. */ -UNIV_INLINE -bool -trx_is_rseg_updated( -/*================*/ - const trx_t* trx) /*!< in: transaction */ -{ - return(trx_is_redo_rseg_updated(trx) || trx->rsegs.m_noredo.undo); -} - /** Increase the reference count. If the transaction is in state TRX_STATE_COMMITTED_IN_MEMORY then the transaction is considered diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index 1a997330a9e..ec723375fe9 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -102,7 +102,7 @@ trx_rollback_to_savepoint_low( trx->error_state = DB_SUCCESS; - if (trx_is_rseg_updated(trx)) { + if (trx->has_logged()) { ut_ad(trx->rsegs.m_redo.rseg != 0 || trx->rsegs.m_noredo.rseg != 0); @@ -213,7 +213,7 @@ trx_rollback_low( case TRX_STATE_PREPARED: ut_ad(!trx_is_autocommit_non_locking(trx)); - if (trx_is_redo_rseg_updated(trx)) { + if (trx->has_logged_persistent()) { /* Change the undo log state back from TRX_UNDO_PREPARED to TRX_UNDO_ACTIVE so that if the system gets killed, @@ -243,7 +243,7 @@ trx_rollback_low( if (trx->mysql_thd == NULL) { /* We could be executing XA ROLLBACK after XA PREPARE and a server restart. */ - } else if (!trx_is_redo_rseg_updated(trx)) { + } else if (!trx->has_logged_persistent()) { /* innobase_close_connection() may roll back a transaction that did not generate any persistent undo log. The DEBUG_SYNC diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 418721bba76..b687f8e8990 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -2028,7 +2028,7 @@ trx_commit_low( assert_trx_nonlocking_or_in_list(trx); ut_ad(!trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY)); ut_ad(!mtr || mtr->is_active()); - ut_ad(!mtr == !(trx_is_rseg_updated(trx))); + ut_ad(!mtr == !trx->has_logged()); /* undo_no is non-zero if we're doing the final commit. */ if (trx->fts_trx != NULL && trx->undo_no != 0) { @@ -2081,7 +2081,7 @@ trx_commit_low( mtr_commit(mtr); DBUG_EXECUTE_IF("ib_crash_during_trx_commit_in_mem", - if (trx_is_rseg_updated(trx)) { + if (trx->has_logged()) { log_make_checkpoint_at(LSN_MAX, TRUE); DBUG_SUICIDE(); }); @@ -2099,7 +2099,7 @@ trx_commit_low( thd->debug_sync_control defined any longer. However the stack is possible only with a prepared trx not updating any data. */ - if (trx->mysql_thd != NULL && trx_is_redo_rseg_updated(trx)) { + if (trx->mysql_thd != NULL && trx->has_logged_persistent()) { DEBUG_SYNC_C("before_trx_state_committed_in_memory"); } #endif @@ -2120,7 +2120,7 @@ trx_commit( DBUG_EXECUTE_IF("ib_trx_commit_crash_before_trx_commit_start", DBUG_SUICIDE();); - if (trx_is_rseg_updated(trx)) { + if (trx->has_logged()) { mtr = &local_mtr; mtr_start_sync(mtr); } else {