diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index a7428e3..b90ce0e 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -40,6 +40,7 @@ Created 3/26/1996 Heikki Tuuri #include "page0types.h" #include "ut0mutex.h" #include "trx0trx.h" +#include typedef UT_LIST_BASE_NODE_T(trx_t) trx_ut_list_t; @@ -475,6 +476,9 @@ struct trx_sys_t { volatile because it can be accessed without holding any mutex during AC-NL-RO view creation. */ + std::atomic low_active_id; + /*!< The smallest transaction id that may + still in active state. */ trx_ut_list_t serialisation_list; /*!< Ordered on trx_t::no of all the currenrtly active RW transactions */ diff --git a/storage/innobase/include/trx0sys.ic b/storage/innobase/include/trx0sys.ic index dc5b95e..94d89aa 100644 --- a/storage/innobase/include/trx0sys.ic +++ b/storage/innobase/include/trx0sys.ic @@ -362,6 +362,12 @@ trx_rw_is_active( { trx_t* trx; + /* Fast checking. */ + if (trx_sys->low_active_id.load() > trx_id) { + ut_ad(!trx_rw_is_active_low(trx_id, corrupt)); + return(NULL); + } + trx_sys_mutex_enter(); trx = trx_rw_is_active_low(trx_id, corrupt); diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 07fc8ef..eb82cc6 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -443,6 +443,8 @@ trx_sys_create(void) trx_sys->mvcc = UT_NEW_NOKEY(MVCC(1024)); + trx_sys->low_active_id = 0; + new(&trx_sys->rw_trx_ids) trx_ids_t(ut_allocator( mem_key_trx_sys_t_rw_trx_ids)); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index e9c3b61..75dfd91 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1911,6 +1911,11 @@ trx_erase_lists( trx_sys->rw_trx_set.erase(TrxTrack(trx->id)); + trx_id_t low_id = trx_sys->rw_trx_ids.empty() + ? trx_sys->max_trx_id : *(trx_sys->rw_trx_ids.begin()); + + trx_sys->low_active_id.store(low_id); + trx_sys_mutex_exit(); }