#At file:///home/marko/innobase/dev/mysql2a/5.6-innodb/ based on revid:marko.makela@stripped37nibd18jwja
3454 Marko Mäkelä 2011-01-24
Non-functional change, cleaning up after WL#5458.
Remove the trx_get_on_id() wrapper, because it is inherently unsafe.
Rename trx_get_on_id_low() to trx_get_on_id(). Adjust callers.
modified:
storage/innobase/include/trx0sys.h
storage/innobase/include/trx0sys.ic
storage/innobase/row/row0vers.c
storage/innobase/trx/trx0trx.c
=== modified file 'storage/innobase/include/trx0sys.h'
--- a/storage/innobase/include/trx0sys.h revid:marko.makela@strippedl37nibd18jwja
+++ b/storage/innobase/include/trx0sys.h revid:marko.makela@strippedgt
@@ -261,15 +261,10 @@ trx_read_trx_id(
const byte* ptr); /*!< in: pointer to memory from where to read */
/****************************************************************//**
Looks for the trx handle with the given id in trx_list.
-@return the trx handle or NULL if not found */
-UNIV_INLINE
-trx_t*
-trx_get_on_id_low(
-/*==============*/
- trx_id_t trx_id);/*!< in: trx id to search for */
-/****************************************************************//**
-Looks for the trx handle with the given id in trx_list.
-@return the trx handle or NULL if not found */
+The caller must be holding trx_sys->lock.
+@return the trx handle or NULL if not found;
+the pointer must not be dereferenced unless lock_sys->mutex was
+acquired before calling this function and is still being held */
UNIV_INLINE
trx_t*
trx_get_on_id(
=== modified file 'storage/innobase/include/trx0sys.ic'
--- a/storage/innobase/include/trx0sys.ic revid:marko.makela@stripped4102828-1o7l37nibd18jwja
+++ b/storage/innobase/include/trx0sys.ic revid:marko.makela@stripped51eevrekov0bgt
@@ -246,13 +246,15 @@ trx_read_trx_id(
}
/****************************************************************//**
-Looks for the trx handle with the given id in trx_list. Because the list
-is ordered on trx id in descending order, we try and speed things up a bit
-@return the trx handle or NULL if not found */
+Looks for the trx handle with the given id in trx_list.
+The caller must be holding trx_sys->lock.
+@return the trx handle or NULL if not found;
+the pointer must not be dereferenced unless lock_sys->mutex was
+acquired before calling this function and is still being held */
UNIV_INLINE
trx_t*
-trx_get_on_id_low(
-/*==============*/
+trx_get_on_id(
+/*==========*/
trx_id_t trx_id) /*!< in: trx id to search for */
{
trx_t* trx;
@@ -311,27 +313,7 @@ trx_get_on_id_low(
}
/****************************************************************//**
-Looks for the trx handle with the given id in trx_list.
-@return the trx handle or NULL if not found */
-UNIV_INLINE
-trx_t*
-trx_get_on_id(
-/*==========*/
- trx_id_t trx_id) /*!< in: trx id to search for */
-{
- trx_t* trx;
-
- rw_lock_s_lock(&trx_sys->lock);
-
- trx = trx_get_on_id_low(trx_id);
-
- rw_lock_s_unlock(&trx_sys->lock);
-
- return(trx);
-}
-
-/****************************************************************//**
-Returns the minumum trx id in trx list. This is the smallest id for which
+Returns the minimum trx id in trx list. This is the smallest id for which
the trx can possibly be active. (But, you must look at the trx->state
to find out if the minimum trx id transaction itself is active, or already
committed.). The caller must be holding the trx_sys_t::lock in shared mode.
@@ -412,7 +394,7 @@ trx_is_active_low(
*corrupt = TRUE;
}
} else {
- trx = trx_get_on_id_low(trx_id);
+ trx = trx_get_on_id(trx_id);
if (trx != NULL
&& trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY)) {
=== modified file 'storage/innobase/row/row0vers.c'
--- a/storage/innobase/row/row0vers.c revid:marko.makela@stripped1o7l37nibd18jwja
+++ b/storage/innobase/row/row0vers.c revid:marko.makela@strippedgt
@@ -681,7 +681,7 @@ row_vers_build_for_semi_consistent_read(
}
rw_lock_s_lock(&trx_sys->lock);
- version_trx = trx_get_on_id_low(version_trx_id);
+ version_trx = trx_get_on_id(version_trx_id);
/* version_trx->state cannot change from or to
NOT_STARTED while we are holding the trx_sys->lock.
It may change from ACTIVE to PREPARED or COMMITTED. */
=== modified file 'storage/innobase/trx/trx0trx.c'
--- a/storage/innobase/trx/trx0trx.c revid:marko.makela@stripped18jwja
+++ b/storage/innobase/trx/trx0trx.c revid:marko.makela@stripped
@@ -573,7 +573,9 @@ trx_lists_init_at_db_start(void)
ibool trx_created;
/* Check the trx_sys->trx_list first. */
+ rw_lock_s_lock(&trx_sys->lock);
trx = trx_get_on_id(undo->trx_id);
+ rw_lock_s_unlock(&trx_sys->lock);
if (trx == NULL) {
trx = trx_allocate_for_background();
Attachment: [text/bzr-bundle] bzr/marko.makela@oracle.com-20110124113909-su51eevrekov0bgt.bundle
| Thread |
|---|
| • bzr commit into mysql-trunk-innodb branch (marko.makela:3454) WL#5458 | marko.makela | 24 Jan |