diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-27 15:48:46 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-27 16:38:57 +0300 |
commit | 25af2a183b03f1d50da2466de84559a09a3e182c (patch) | |
tree | 5c6f03a7f93213068c6102150ae6acdf5df60c4a /storage | |
parent | e7b71e0daa49ca9b5becbf2739ed13d7c8c4fcd6 (diff) | |
download | mariadb-git-25af2a183b03f1d50da2466de84559a09a3e182c.tar.gz |
MDEV-15326/MDEV-16136 dead code removal
Revert part of fa2a74e08d00bcf8ddb1d98dba767e9bd1ed802d.
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().
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/include/trx0sys.ic | 9 | ||||
-rw-r--r-- | storage/innobase/include/trx0trx.h | 26 | ||||
-rw-r--r-- | storage/innobase/lock/lock0lock.cc | 2 | ||||
-rw-r--r-- | storage/innobase/trx/trx0trx.cc | 7 |
4 files changed, 11 insertions, 33 deletions
diff --git a/storage/innobase/include/trx0sys.ic b/storage/innobase/include/trx0sys.ic index c552af9ab47..bfd345a27db 100644 --- a/storage/innobase/include/trx0sys.ic +++ b/storage/innobase/include/trx0sys.ic @@ -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(); diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 4ab29e08e0f..62f7f172453 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -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 diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 21171bad2bb..a674a38df2d 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -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); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 196ae5db36e..1f6ed7a48d4 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -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); |