Commit 90bf5567 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Misc trx_sys scalability fixes

trx_erase_lists(): trx->read_view is owned by current thread and thus
doesn't need trx_sys.mutex protection for reading it's value. Move
trx->read_view check out of mutex

trx_start_low(): moved assertion out of mutex.

Call ReadView::creator_trx_id() directly: allows to inline this one-line
method.
parent 64048baf
...@@ -80,11 +80,6 @@ class MVCC { ...@@ -80,11 +80,6 @@ class MVCC {
return(view != NULL && !(intptr_t(view) & 0x1)); return(view != NULL && !(intptr_t(view) & 0x1));
} }
/**
Set the view creator transaction id. Note: This shouldbe set only
for views created by RW transactions. */
static void set_view_creator_trx_id(ReadView* view, trx_id_t id);
private: private:
/** /**
......
...@@ -239,6 +239,18 @@ class ReadView { ...@@ -239,6 +239,18 @@ class ReadView {
return(m_ids.empty()); return(m_ids.empty());
} }
/**
Set the creator transaction id, existing id must be 0.
Note: This shouldbe set only for views created by RW
transactions. Caller must own trx_sys.mutex. */
void creator_trx_id(trx_id_t id)
{
ut_ad(id > 0);
ut_ad(m_creator_trx_id == 0);
m_creator_trx_id = id;
}
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/** /**
@param rhs view to compare with @param rhs view to compare with
...@@ -278,14 +290,6 @@ class ReadView { ...@@ -278,14 +290,6 @@ class ReadView {
m_trx_ids too and adjust the m_up_limit_id *, if required */ m_trx_ids too and adjust the m_up_limit_id *, if required */
inline void copy_complete(); inline void copy_complete();
/**
Set the creator transaction id, existing id must be 0 */
void creator_trx_id(trx_id_t id)
{
ut_ad(m_creator_trx_id == 0);
m_creator_trx_id = id;
}
friend class MVCC; friend class MVCC;
private: private:
......
...@@ -769,17 +769,3 @@ MVCC::view_close(ReadView*& view, bool own_mutex) ...@@ -769,17 +769,3 @@ MVCC::view_close(ReadView*& view, bool own_mutex)
view = NULL; view = NULL;
} }
} }
/**
Set the view creator transaction id. Note: This shouldbe set only
for views created by RW transactions.
@param view Set the creator trx id for this view
@param id Transaction id to set */
void
MVCC::set_view_creator_trx_id(ReadView* view, trx_id_t id)
{
ut_ad(id > 0);
ut_ad(mutex_own(&trx_sys.mutex));
view->creator_trx_id(id);
}
...@@ -1169,21 +1169,16 @@ trx_start_low( ...@@ -1169,21 +1169,16 @@ trx_start_low(
if (!trx->read_only if (!trx->read_only
&& (trx->mysql_thd == 0 || read_write || trx->ddl)) { && (trx->mysql_thd == 0 || read_write || trx->ddl)) {
trx->rsegs.m_redo.rseg = trx_assign_rseg_low();
/* Temporary rseg is assigned only if the transaction /* Temporary rseg is assigned only if the transaction
updates a temporary table */ updates a temporary table */
trx->rsegs.m_redo.rseg = trx_assign_rseg_low();
mutex_enter(&trx_sys.mutex);
trx->id = trx_sys.get_new_trx_id();
trx_sys.rw_trx_ids.push_back(trx->id);
ut_ad(trx->rsegs.m_redo.rseg != 0 ut_ad(trx->rsegs.m_redo.rseg != 0
|| srv_read_only_mode || srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO); || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);
mutex_enter(&trx_sys.mutex);
trx->id = trx_sys.get_new_trx_id();
trx_sys.rw_trx_ids.push_back(trx->id);
mutex_exit(&trx_sys.mutex); mutex_exit(&trx_sys.mutex);
trx_sys.rw_trx_hash.insert(trx); trx_sys.rw_trx_hash.insert(trx);
...@@ -1541,15 +1536,13 @@ trx_erase_lists( ...@@ -1541,15 +1536,13 @@ trx_erase_lists(
{ {
ut_ad(trx->id > 0); ut_ad(trx->id > 0);
if (trx->read_only || trx->rsegs.m_redo.rseg == NULL) { if (trx->rsegs.m_redo.rseg && trx->read_view) {
ut_ad(!trx->read_only);
mutex_enter(&trx_sys.mutex); mutex_enter(&trx_sys.mutex);
trx_sys.mvcc.view_close(trx->read_view, true);
} else { } else {
mutex_enter(&trx_sys.mutex); mutex_enter(&trx_sys.mutex);
if (trx->read_view != NULL) {
trx_sys.mvcc.view_close(trx->read_view, true);
}
} }
if (serialised) { if (serialised) {
...@@ -2759,12 +2752,11 @@ trx_set_rw_mode( ...@@ -2759,12 +2752,11 @@ trx_set_rw_mode(
mutex_enter(&trx_sys.mutex); mutex_enter(&trx_sys.mutex);
trx->id = trx_sys.get_new_trx_id(); trx->id = trx_sys.get_new_trx_id();
trx_sys.rw_trx_ids.push_back(trx->id); trx_sys.rw_trx_ids.push_back(trx->id);
/* So that we can see our own changes. */ /* So that we can see our own changes. */
if (MVCC::is_view_active(trx->read_view)) { if (MVCC::is_view_active(trx->read_view)) {
MVCC::set_view_creator_trx_id(trx->read_view, trx->id); trx->read_view->creator_trx_id(trx->id);
} }
mutex_exit(&trx_sys.mutex); mutex_exit(&trx_sys.mutex);
trx_sys.rw_trx_hash.insert(trx); trx_sys.rw_trx_hash.insert(trx);
......
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