Skip to content

Commit

Permalink
Misc trx_sys scalability fixes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sergey Vojtovich committed Jan 20, 2018
1 parent 64048ba commit 90bf556
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 43 deletions.
5 changes: 0 additions & 5 deletions storage/innobase/include/read0read.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ class MVCC {
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:

/**
Expand Down
20 changes: 12 additions & 8 deletions storage/innobase/include/read0types.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@ class ReadView {
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
/**
@param rhs view to compare with
Expand Down Expand Up @@ -278,14 +290,6 @@ class ReadView {
m_trx_ids too and adjust the m_up_limit_id *, if required */
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;

private:
Expand Down
14 changes: 0 additions & 14 deletions storage/innobase/read/read0read.cc
Original file line number Diff line number Diff line change
Expand Up @@ -769,17 +769,3 @@ MVCC::view_close(ReadView*& view, bool own_mutex)
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);
}
24 changes: 8 additions & 16 deletions storage/innobase/trx/trx0trx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1169,21 +1169,16 @@ trx_start_low(
if (!trx->read_only
&& (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
updates a temporary table */

mutex_enter(&trx_sys.mutex);

trx->id = trx_sys.get_new_trx_id();

trx_sys.rw_trx_ids.push_back(trx->id);

trx->rsegs.m_redo.rseg = trx_assign_rseg_low();
ut_ad(trx->rsegs.m_redo.rseg != 0
|| srv_read_only_mode
|| 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);
trx_sys.rw_trx_hash.insert(trx);

Expand Down Expand Up @@ -1541,15 +1536,13 @@ trx_erase_lists(
{
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);
trx_sys.mvcc.view_close(trx->read_view, true);
} else {

mutex_enter(&trx_sys.mutex);
if (trx->read_view != NULL) {
trx_sys.mvcc.view_close(trx->read_view, true);
}
}

if (serialised) {
Expand Down Expand Up @@ -2759,12 +2752,11 @@ trx_set_rw_mode(

mutex_enter(&trx_sys.mutex);
trx->id = trx_sys.get_new_trx_id();

trx_sys.rw_trx_ids.push_back(trx->id);

/* So that we can see our own changes. */
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);
trx_sys.rw_trx_hash.insert(trx);
Expand Down

0 comments on commit 90bf556

Please sign in to comment.