Commit db5bb785 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Allocate trx_sys.mvcc at link time

trx_sys.mvcc was allocated dynamically for no good reason.
parent f8882cce
...@@ -16226,7 +16226,7 @@ ha_innobase::external_lock( ...@@ -16226,7 +16226,7 @@ ha_innobase::external_lock(
} else if (trx->isolation_level <= TRX_ISO_READ_COMMITTED } else if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
&& MVCC::is_view_active(trx->read_view)) { && MVCC::is_view_active(trx->read_view)) {
mutex_enter(&trx_sys.mutex); mutex_enter(&trx_sys.mutex);
trx_sys.mvcc->view_close(trx->read_view, true); trx_sys.mvcc.view_close(trx->read_view, true);
mutex_exit(&trx_sys.mutex); mutex_exit(&trx_sys.mutex);
} }
} }
...@@ -16894,7 +16894,7 @@ ha_innobase::store_lock( ...@@ -16894,7 +16894,7 @@ ha_innobase::store_lock(
/* At low transaction isolation levels we let /* At low transaction isolation levels we let
each consistent read set its own snapshot */ each consistent read set its own snapshot */
mutex_enter(&trx_sys.mutex); mutex_enter(&trx_sys.mutex);
trx_sys.mvcc->view_close(trx->read_view, true); trx_sys.mvcc.view_close(trx->read_view, true);
mutex_enter(&trx_sys.mutex); mutex_enter(&trx_sys.mutex);
} }
} }
......
...@@ -30,18 +30,16 @@ Created 2/16/1997 Heikki Tuuri ...@@ -30,18 +30,16 @@ Created 2/16/1997 Heikki Tuuri
#include "read0types.h" #include "read0types.h"
#include <algorithm>
/** The MVCC read view manager */ /** The MVCC read view manager */
class MVCC { class MVCC {
public: public:
/** Constructor /** Constructor
@param size Number of views to pre-allocate */ @param size Number of views to pre-allocate */
explicit MVCC(ulint size); void create(ulint size);
/** Destructor. /** Destructor.
Free all the views in the m_free list */ Free all the views in the m_free list */
~MVCC(); void close();
/** /**
Allocate and create a view. Allocate and create a view.
...@@ -106,11 +104,6 @@ class MVCC { ...@@ -106,11 +104,6 @@ class MVCC {
@return oldest view if found or NULL */ @return oldest view if found or NULL */
inline ReadView* get_oldest_view() const; inline ReadView* get_oldest_view() const;
private:
// Prevent copying
MVCC(const MVCC&);
MVCC& operator=(const MVCC&);
private: private:
typedef UT_LIST_BASE_NODE_T(ReadView) view_list_t; typedef UT_LIST_BASE_NODE_T(ReadView) view_list_t;
......
...@@ -47,10 +47,6 @@ Created 3/26/1996 Heikki Tuuri ...@@ -47,10 +47,6 @@ Created 3/26/1996 Heikki Tuuri
typedef UT_LIST_BASE_NODE_T(trx_t) trx_ut_list_t; typedef UT_LIST_BASE_NODE_T(trx_t) trx_ut_list_t;
// Forward declaration
class MVCC;
class ReadView;
/** Checks if a page address is the trx sys header page. /** Checks if a page address is the trx sys header page.
@param[in] page_id page id @param[in] page_id page id
@return true if trx sys header page */ @return true if trx sys header page */
...@@ -825,6 +821,7 @@ struct trx_sys_t { ...@@ -825,6 +821,7 @@ struct trx_sys_t {
MY_ALIGNED(CACHE_LINE_SIZE) trx_id_t m_max_trx_id; MY_ALIGNED(CACHE_LINE_SIZE) trx_id_t m_max_trx_id;
bool m_initialised;
public: public:
MY_ALIGNED(CACHE_LINE_SIZE) MY_ALIGNED(CACHE_LINE_SIZE)
...@@ -832,7 +829,8 @@ struct trx_sys_t { ...@@ -832,7 +829,8 @@ struct trx_sys_t {
this structure except when noted this structure except when noted
otherwise */ otherwise */
MVCC* mvcc; /*!< Multi version concurrency control MY_ALIGNED(CACHE_LINE_SIZE)
MVCC mvcc; /*!< Multi version concurrency control
manager */ manager */
trx_ut_list_t serialisation_list; trx_ut_list_t serialisation_list;
/*!< Ordered on trx_t::no of all the /*!< Ordered on trx_t::no of all the
...@@ -908,7 +906,8 @@ struct trx_sys_t { ...@@ -908,7 +906,8 @@ struct trx_sys_t {
initialisation to create(). initialisation to create().
*/ */
trx_sys_t(): rw_trx_ids(ut_allocator<trx_id_t>(mem_key_trx_sys_t_rw_trx_ids)) trx_sys_t(): m_initialised(false),
rw_trx_ids(ut_allocator<trx_id_t>(mem_key_trx_sys_t_rw_trx_ids))
{} {}
...@@ -977,6 +976,9 @@ struct trx_sys_t { ...@@ -977,6 +976,9 @@ struct trx_sys_t {
} }
bool is_initialised() { return m_initialised; }
/** Create the instance */ /** Create the instance */
void create(); void create();
......
...@@ -339,7 +339,7 @@ ReadView::~ReadView() ...@@ -339,7 +339,7 @@ ReadView::~ReadView()
/** Constructor /** Constructor
@param size Number of views to pre-allocate */ @param size Number of views to pre-allocate */
MVCC::MVCC(ulint size) void MVCC::create(ulint size)
{ {
UT_LIST_INIT(m_free, &ReadView::m_view_list); UT_LIST_INIT(m_free, &ReadView::m_view_list);
UT_LIST_INIT(m_views, &ReadView::m_view_list); UT_LIST_INIT(m_views, &ReadView::m_view_list);
...@@ -351,7 +351,7 @@ MVCC::MVCC(ulint size) ...@@ -351,7 +351,7 @@ MVCC::MVCC(ulint size)
} }
} }
MVCC::~MVCC() void MVCC::close()
{ {
for (ReadView* view = UT_LIST_GET_FIRST(m_free); for (ReadView* view = UT_LIST_GET_FIRST(m_free);
view != NULL; view != NULL;
......
...@@ -5888,7 +5888,7 @@ row_search_check_if_query_cache_permitted( ...@@ -5888,7 +5888,7 @@ row_search_check_if_query_cache_permitted(
&& !srv_read_only_mode && !srv_read_only_mode
&& !MVCC::is_view_active(trx->read_view)) { && !MVCC::is_view_active(trx->read_view)) {
trx_sys.mvcc->view_open(trx->read_view, trx); trx_sys.mvcc.view_open(trx->read_view, trx);
} }
} }
......
...@@ -1367,7 +1367,7 @@ srv_printf_innodb_monitor( ...@@ -1367,7 +1367,7 @@ srv_printf_innodb_monitor(
/* This is a dirty read, without holding trx_sys.mutex. */ /* This is a dirty read, without holding trx_sys.mutex. */
fprintf(file, ULINTPF " read views open inside InnoDB\n", fprintf(file, ULINTPF " read views open inside InnoDB\n",
trx_sys.mvcc->size()); trx_sys.mvcc.size());
n_reserved = fil_space_get_n_reserved_extents(0); n_reserved = fil_space_get_n_reserved_extents(0);
if (n_reserved > 0) { if (n_reserved > 0) {
......
...@@ -2835,7 +2835,7 @@ innodb_shutdown() ...@@ -2835,7 +2835,7 @@ innodb_shutdown()
ut_ad(dict_stats_event || !srv_was_started || srv_read_only_mode); ut_ad(dict_stats_event || !srv_was_started || srv_read_only_mode);
ut_ad(dict_sys || !srv_was_started); ut_ad(dict_sys || !srv_was_started);
ut_ad(trx_sys.mvcc || !srv_was_started); ut_ad(trx_sys.is_initialised() || !srv_was_started);
ut_ad(buf_dblwr || !srv_was_started || srv_read_only_mode ut_ad(buf_dblwr || !srv_was_started || srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO); || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);
ut_ad(lock_sys || !srv_was_started); ut_ad(lock_sys || !srv_was_started);
......
...@@ -1600,7 +1600,7 @@ trx_purge( ...@@ -1600,7 +1600,7 @@ trx_purge(
ut_a(purge_sys->n_submitted == purge_sys->n_completed); ut_a(purge_sys->n_submitted == purge_sys->n_completed);
rw_lock_x_lock(&purge_sys->latch); rw_lock_x_lock(&purge_sys->latch);
trx_sys.mvcc->clone_oldest_view(&purge_sys->view); trx_sys.mvcc.clone_oldest_view(&purge_sys->view);
rw_lock_x_unlock(&purge_sys->latch); rw_lock_x_unlock(&purge_sys->latch);
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
......
...@@ -445,7 +445,7 @@ trx_sys_init_at_db_start() ...@@ -445,7 +445,7 @@ trx_sys_init_at_db_start()
trx_dummy_sess = sess_open(); trx_dummy_sess = sess_open();
trx_lists_init_at_db_start(); trx_lists_init_at_db_start();
trx_sys.mvcc->clone_oldest_view(&purge_sys->view); trx_sys.mvcc.clone_oldest_view(&purge_sys->view);
} }
/** Create the instance */ /** Create the instance */
...@@ -453,13 +453,14 @@ void ...@@ -453,13 +453,14 @@ void
trx_sys_t::create() trx_sys_t::create()
{ {
ut_ad(this == &trx_sys); ut_ad(this == &trx_sys);
ut_ad(!mvcc); ut_ad(!is_initialised());
m_initialised = true;
mutex_create(LATCH_ID_TRX_SYS, &mutex); mutex_create(LATCH_ID_TRX_SYS, &mutex);
UT_LIST_INIT(serialisation_list, &trx_t::no_list); UT_LIST_INIT(serialisation_list, &trx_t::no_list);
UT_LIST_INIT(mysql_trx_list, &trx_t::mysql_trx_list); UT_LIST_INIT(mysql_trx_list, &trx_t::mysql_trx_list);
mvcc = UT_NEW_NOKEY(MVCC(1024)); mvcc.create(1024);
rw_trx_hash.init(); rw_trx_hash.init();
} }
...@@ -562,11 +563,11 @@ void ...@@ -562,11 +563,11 @@ void
trx_sys_t::close() trx_sys_t::close()
{ {
ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS); ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS);
if (!mvcc) { if (!is_initialised()) {
return; return;
} }
if (ulint size = mvcc->size()) { if (ulint size = mvcc.size()) {
ib::error() << "All read views were not closed before" ib::error() << "All read views were not closed before"
" shutdown: " << size << " read views open"; " shutdown: " << size << " read views open";
} }
...@@ -590,13 +591,14 @@ trx_sys_t::close() ...@@ -590,13 +591,14 @@ trx_sys_t::close()
} }
} }
UT_DELETE(mvcc); mvcc.close();
ut_a(UT_LIST_GET_LEN(mysql_trx_list) == 0); ut_a(UT_LIST_GET_LEN(mysql_trx_list) == 0);
ut_a(UT_LIST_GET_LEN(serialisation_list) == 0); ut_a(UT_LIST_GET_LEN(serialisation_list) == 0);
/* We used placement new to create this mutex. Call the destructor. */ /* We used placement new to create this mutex. Call the destructor. */
mutex_free(&mutex); mutex_free(&mutex);
m_initialised = false;
} }
......
...@@ -678,7 +678,7 @@ trx_disconnect_from_mysql( ...@@ -678,7 +678,7 @@ trx_disconnect_from_mysql(
UT_LIST_REMOVE(trx_sys.mysql_trx_list, trx); UT_LIST_REMOVE(trx_sys.mysql_trx_list, trx);
if (trx->read_view != NULL) { if (trx->read_view != NULL) {
trx_sys.mvcc->view_close(trx->read_view, true); trx_sys.mvcc.view_close(trx->read_view, true);
} }
if (prepared) { if (prepared) {
...@@ -1558,7 +1558,7 @@ trx_erase_lists( ...@@ -1558,7 +1558,7 @@ trx_erase_lists(
mutex_enter(&trx_sys.mutex); mutex_enter(&trx_sys.mutex);
if (trx->read_view != NULL) { if (trx->read_view != NULL) {
trx_sys.mvcc->view_close(trx->read_view, true); trx_sys.mvcc.view_close(trx->read_view, true);
} }
} }
...@@ -1615,7 +1615,7 @@ trx_commit_in_memory( ...@@ -1615,7 +1615,7 @@ trx_commit_in_memory(
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE)); ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE));
if (trx->read_view != NULL) { if (trx->read_view != NULL) {
trx_sys.mvcc->view_close(trx->read_view, false); trx_sys.mvcc.view_close(trx->read_view, false);
} }
MONITOR_INC(MONITOR_TRX_NL_RO_COMMIT); MONITOR_INC(MONITOR_TRX_NL_RO_COMMIT);
...@@ -1647,7 +1647,7 @@ trx_commit_in_memory( ...@@ -1647,7 +1647,7 @@ trx_commit_in_memory(
if (trx->read_only || trx->rsegs.m_redo.rseg == NULL) { if (trx->read_only || trx->rsegs.m_redo.rseg == NULL) {
MONITOR_INC(MONITOR_TRX_RO_COMMIT); MONITOR_INC(MONITOR_TRX_RO_COMMIT);
if (trx->read_view != NULL) { if (trx->read_view != NULL) {
trx_sys.mvcc->view_close( trx_sys.mvcc.view_close(
trx->read_view, false); trx->read_view, false);
} }
} else { } else {
...@@ -1911,7 +1911,7 @@ trx_assign_read_view( ...@@ -1911,7 +1911,7 @@ trx_assign_read_view(
return(NULL); return(NULL);
} else if (!MVCC::is_view_active(trx->read_view)) { } else if (!MVCC::is_view_active(trx->read_view)) {
trx_sys.mvcc->view_open(trx->read_view, trx); trx_sys.mvcc.view_open(trx->read_view, trx);
} }
return(trx->read_view); return(trx->read_view);
......
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