Commit af566d8a authored by Sergey Vojtovich's avatar Sergey Vojtovich

Reduce number of trx_sys.mutex references

trx->state change must be guarded by trx->mutex.
Moved mutex locking to MVCC::view_close().
parent dcc09afa
......@@ -16066,11 +16066,8 @@ ha_innobase::external_lock(
innobase_commit(ht, thd, TRUE);
}
} else if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
&& trx->read_view.is_open()) {
mutex_enter(&trx_sys.mutex);
} else if (trx->isolation_level <= TRX_ISO_READ_COMMITTED) {
trx_sys.mvcc.view_close(trx->read_view);
mutex_exit(&trx_sys.mutex);
}
}
......@@ -16731,14 +16728,11 @@ ha_innobase::store_lock(
trx->isolation_level = innobase_map_isolation_level(
(enum_tx_isolation) thd_tx_isolation(thd));
if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
&& trx->read_view.is_open()) {
if (trx->isolation_level <= TRX_ISO_READ_COMMITTED) {
/* At low transaction isolation levels we let
each consistent read set its own snapshot */
mutex_enter(&trx_sys.mutex);
trx_sys.mvcc.view_close(trx->read_view);
mutex_enter(&trx_sys.mutex);
}
}
......
......@@ -55,13 +55,7 @@ class MVCC
Close a view created by the above function.
@param view view allocated by view_open.
*/
void view_close(ReadView &view)
{
view.close();
view.set_registered(false);
UT_LIST_REMOVE(m_views, &view);
ut_ad(validate());
}
void view_close(ReadView &view);
/**
......
......@@ -335,6 +335,21 @@ void MVCC::view_open(trx_t* trx)
mutex_exit(&trx_sys.mutex);
}
void MVCC::view_close(ReadView &view)
{
view.close();
if (view.is_registered())
{
mutex_enter(&trx_sys.mutex);
view.set_registered(false);
UT_LIST_REMOVE(m_views, &view);
ut_ad(validate());
mutex_exit(&trx_sys.mutex);
}
}
/**
Copy state from another view.
@param other view to copy from */
......
......@@ -511,11 +511,7 @@ trx_free(trx_t*& trx)
trx->mod_tables.clear();
ut_ad(!trx->read_view.is_open());
if (trx->read_view.is_registered()) {
mutex_enter(&trx_sys.mutex);
trx_sys.mvcc.view_close(trx->read_view);
mutex_exit(&trx_sys.mutex);
}
/* trx locking state should have been reset before returning trx
to pool */
......@@ -677,6 +673,8 @@ trx_disconnect_from_mysql(
trx_t* trx,
bool prepared)
{
trx_sys.mvcc.view_close(trx->read_view);
mutex_enter(&trx_sys.mutex);
ut_ad(trx->in_mysql_trx_list);
......@@ -684,10 +682,6 @@ trx_disconnect_from_mysql(
UT_LIST_REMOVE(trx_sys.mysql_trx_list, trx);
if (trx->read_view.is_open()) {
trx_sys.mvcc.view_close(trx->read_view);
}
if (prepared) {
ut_ad(trx_state_eq(trx, TRX_STATE_PREPARED));
......@@ -2388,12 +2382,10 @@ trx_prepare(
DBUG_EXECUTE_IF("ib_trx_crash_during_xa_prepare_step", DBUG_SUICIDE(););
/*--------------------------------------*/
ut_a(trx->state == TRX_STATE_ACTIVE);
mutex_enter(&trx_sys.mutex);
trx_mutex_enter(trx);
trx->state = TRX_STATE_PREPARED;
mutex_exit(&trx_sys.mutex);
/*--------------------------------------*/
trx_mutex_exit(trx);
if (lsn) {
/* Depending on the my.cnf options, we may now write the log
......
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