Commit a0c79bcf authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent d1374c5b
...@@ -5017,8 +5017,6 @@ innobase_rollback_trx( ...@@ -5017,8 +5017,6 @@ innobase_rollback_trx(
/*==================*/ /*==================*/
trx_t* trx) /*!< in: transaction */ trx_t* trx) /*!< in: transaction */
{ {
dberr_t error = DB_SUCCESS;
DBUG_ENTER("innobase_rollback_trx"); DBUG_ENTER("innobase_rollback_trx");
DBUG_PRINT("trans", ("aborting transaction")); DBUG_PRINT("trans", ("aborting transaction"));
...@@ -5037,13 +5035,13 @@ innobase_rollback_trx( ...@@ -5037,13 +5035,13 @@ innobase_rollback_trx(
lock_unlock_table_autoinc(trx); lock_unlock_table_autoinc(trx);
} }
if (trx_is_rseg_updated(trx)) { if (!trx->has_logged()) {
error = trx_rollback_for_mysql(trx);
} else {
trx->will_lock = 0; 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( ...@@ -5397,7 +5395,7 @@ innobase_close_connection(
in the 1st and 3rd case. */ in the 1st and 3rd case. */
if (trx_is_started(trx)) { if (trx_is_started(trx)) {
if (trx_state_eq(trx, TRX_STATE_PREPARED)) { if (trx_state_eq(trx, TRX_STATE_PREPARED)) {
if (trx_is_redo_rseg_updated(trx)) { if (trx->has_logged_persistent()) {
trx_disconnect_prepared(trx); trx_disconnect_prepared(trx);
} else { } else {
trx_rollback_for_mysql(trx); trx_rollback_for_mysql(trx);
......
...@@ -8610,7 +8610,7 @@ ha_innobase::commit_inplace_alter_table( ...@@ -8610,7 +8610,7 @@ ha_innobase::commit_inplace_alter_table(
trx_rollback_for_mysql(trx); trx_rollback_for_mysql(trx);
} else { } else {
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE)); 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) { if (mtr.get_log()->size() > 0) {
ut_ad(*mtr.get_log()->front()->begin() ut_ad(*mtr.get_log()->front()->begin()
......
...@@ -579,13 +579,6 @@ Kill all transactions that are blocking this transaction from acquiring locks. ...@@ -579,13 +579,6 @@ Kill all transactions that are blocking this transaction from acquiring locks.
void void
trx_kill_blocking(trx_t* trx); 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 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 the trx_t::mysql_thd field. For such transactions we set the lock
...@@ -645,7 +638,7 @@ Check transaction state */ ...@@ -645,7 +638,7 @@ Check transaction state */
#define assert_trx_is_free(t) do { \ #define assert_trx_is_free(t) do { \
ut_ad(trx_state_eq((t), TRX_STATE_NOT_STARTED) \ ut_ad(trx_state_eq((t), TRX_STATE_NOT_STARTED) \
|| trx_state_eq((t), TRX_STATE_FORCED_ROLLBACK)); \ || 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(!MVCC::is_view_active((t)->read_view)); \
ut_ad((t)->lock.wait_thr == NULL); \ ut_ad((t)->lock.wait_thr == NULL); \
ut_ad(UT_LIST_GET_LEN((t)->lock.trx_locks) == 0); \ ut_ad(UT_LIST_GET_LEN((t)->lock.trx_locks) == 0); \
...@@ -1290,6 +1283,18 @@ struct trx_t { ...@@ -1290,6 +1283,18 @@ struct trx_t {
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
ulint magic_n; 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);
}
}; };
/** /**
......
...@@ -213,29 +213,6 @@ ok: ...@@ -213,29 +213,6 @@ ok:
trx->dict_operation = op; 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 Increase the reference count. If the transaction is in state
TRX_STATE_COMMITTED_IN_MEMORY then the transaction is considered TRX_STATE_COMMITTED_IN_MEMORY then the transaction is considered
......
...@@ -102,7 +102,7 @@ trx_rollback_to_savepoint_low( ...@@ -102,7 +102,7 @@ trx_rollback_to_savepoint_low(
trx->error_state = DB_SUCCESS; trx->error_state = DB_SUCCESS;
if (trx_is_rseg_updated(trx)) { if (trx->has_logged()) {
ut_ad(trx->rsegs.m_redo.rseg != 0 ut_ad(trx->rsegs.m_redo.rseg != 0
|| trx->rsegs.m_noredo.rseg != 0); || trx->rsegs.m_noredo.rseg != 0);
...@@ -213,7 +213,7 @@ trx_rollback_low( ...@@ -213,7 +213,7 @@ trx_rollback_low(
case TRX_STATE_PREPARED: case TRX_STATE_PREPARED:
ut_ad(!trx_is_autocommit_non_locking(trx)); 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 /* Change the undo log state back from
TRX_UNDO_PREPARED to TRX_UNDO_ACTIVE TRX_UNDO_PREPARED to TRX_UNDO_ACTIVE
so that if the system gets killed, so that if the system gets killed,
...@@ -243,7 +243,7 @@ trx_rollback_low( ...@@ -243,7 +243,7 @@ trx_rollback_low(
if (trx->mysql_thd == NULL) { if (trx->mysql_thd == NULL) {
/* We could be executing XA ROLLBACK after /* We could be executing XA ROLLBACK after
XA PREPARE and a server restart. */ 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 /* innobase_close_connection() may roll back a
transaction that did not generate any transaction that did not generate any
persistent undo log. The DEBUG_SYNC persistent undo log. The DEBUG_SYNC
......
...@@ -2028,7 +2028,7 @@ trx_commit_low( ...@@ -2028,7 +2028,7 @@ trx_commit_low(
assert_trx_nonlocking_or_in_list(trx); assert_trx_nonlocking_or_in_list(trx);
ut_ad(!trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY)); ut_ad(!trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY));
ut_ad(!mtr || mtr->is_active()); 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. */ /* undo_no is non-zero if we're doing the final commit. */
if (trx->fts_trx != NULL && trx->undo_no != 0) { if (trx->fts_trx != NULL && trx->undo_no != 0) {
...@@ -2081,7 +2081,7 @@ trx_commit_low( ...@@ -2081,7 +2081,7 @@ trx_commit_low(
mtr_commit(mtr); mtr_commit(mtr);
DBUG_EXECUTE_IF("ib_crash_during_trx_commit_in_mem", 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); log_make_checkpoint_at(LSN_MAX, TRUE);
DBUG_SUICIDE(); DBUG_SUICIDE();
}); });
...@@ -2099,7 +2099,7 @@ trx_commit_low( ...@@ -2099,7 +2099,7 @@ trx_commit_low(
thd->debug_sync_control defined any longer. However the stack thd->debug_sync_control defined any longer. However the stack
is possible only with a prepared trx not updating any data. 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"); DEBUG_SYNC_C("before_trx_state_committed_in_memory");
} }
#endif #endif
...@@ -2120,7 +2120,7 @@ trx_commit( ...@@ -2120,7 +2120,7 @@ trx_commit(
DBUG_EXECUTE_IF("ib_trx_commit_crash_before_trx_commit_start", DBUG_EXECUTE_IF("ib_trx_commit_crash_before_trx_commit_start",
DBUG_SUICIDE();); DBUG_SUICIDE(););
if (trx_is_rseg_updated(trx)) { if (trx->has_logged()) {
mtr = &local_mtr; mtr = &local_mtr;
mtr_start_sync(mtr); mtr_start_sync(mtr);
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment