Commit 25af2a18 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-15326/MDEV-16136 dead code removal

Revert part of fa2a74e0.

trx_reference(): Remove, and merge the relevant part to the only caller
trx_rw_is_active(). If the statements trx = NULL; were ever executed,
the function would have dereferenced a NULL pointer and crashed in
trx_mutex_exit(trx). Hence, those statements must have been unreachable,
and they can be replaced with debug assertions.

trx_rw_is_active(): Avoid unnecessary acquisition and release of trx->mutex
when do_ref_count=false.

lock_trx_release_locks(): Do not reset trx->id=0. Had the statement been
necessary, we would have experienced crashes in trx_reference().
parent e7b71e0d
......@@ -364,8 +364,13 @@ trx_rw_is_active(
trx_t* trx = trx_rw_is_active_low(trx_id, corrupt);
if (trx) {
trx = trx_reference(do_ref_count ? trx_id : 0, trx);
if (trx && do_ref_count) {
trx_mutex_enter(trx);
ut_ad(!trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY));
ut_ad(trx->id == trx_id);
ut_ad(trx->n_ref >= 0);
++trx->n_ref;
trx_mutex_exit(trx);
}
trx_sys_mutex_exit();
......
......@@ -1270,32 +1270,6 @@ struct commit_node_t{
mutex_exit(&t->mutex); \
} while (0)
/**
Increase the reference count. If the transaction is in state
TRX_STATE_COMMITTED_IN_MEMORY then the transaction is considered
committed and the reference count is not incremented.
@param id the transaction ID; 0 if not to increment the reference count
@param trx Transaction that is being referenced
@return trx
@retval NULL if the transaction is no longer active */
inline trx_t* trx_reference(trx_id_t id, trx_t* trx)
{
trx_mutex_enter(trx);
if (trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY)) {
trx = NULL;
} else if (!id) {
} else if (trx->id != id) {
trx = NULL;
} else {
ut_ad(trx->n_ref >= 0);
++trx->n_ref;
}
trx_mutex_exit(trx);
return(trx);
}
#include "trx0trx.ic"
#endif
......@@ -6647,8 +6647,6 @@ lock_trx_release_locks(
the is_recovered flag. */
trx->is_recovered = false;
/* Ensure that trx_reference() will not find this transaction. */
trx->id = 0;
trx_mutex_exit(trx);
......
......@@ -557,6 +557,7 @@ trx_free_prepared(
transaction was never committed and therefore lock_trx_release()
was not called. */
trx->lock.table_locks.clear();
trx->id = 0;
trx_free(trx);
}
......@@ -1660,10 +1661,8 @@ trx_commit_in_memory(
trx_erase_lists(trx, serialised);
}
/* trx->id will be cleared in lock_trx_release_locks(trx). */
ut_ad(trx->read_only || !trx->rsegs.m_redo.rseg || trx->id);
lock_trx_release_locks(trx);
ut_ad(trx->id == 0);
ut_ad(trx->read_only || !trx->rsegs.m_redo.rseg || trx->id);
/* Remove the transaction from the list of active
transactions now that it no longer holds any user locks. */
......@@ -1682,6 +1681,8 @@ trx_commit_in_memory(
} else {
MONITOR_INC(MONITOR_TRX_RW_COMMIT);
}
trx->id = 0;
}
ut_ad(!trx->rsegs.m_redo.update_undo);
......
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