summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2018-01-28 17:17:11 +0400
committerSergey Vojtovich <svoj@mariadb.org>2018-01-31 15:18:21 +0400
commitaf566d8a63f908c76d43957e790e861d944486b0 (patch)
treefe94451ec6209eb490e296ea8257fc4e6887047f
parentdcc09afa634b0f525d2e8e7d15ef36e5fdd5d270 (diff)
downloadmariadb-git-af566d8a63f908c76d43957e790e861d944486b0.tar.gz
Reduce number of trx_sys.mutex references
trx->state change must be guarded by trx->mutex. Moved mutex locking to MVCC::view_close().
-rw-r--r--storage/innobase/handler/ha_innodb.cc10
-rw-r--r--storage/innobase/include/read0read.h8
-rw-r--r--storage/innobase/read/read0read.cc15
-rw-r--r--storage/innobase/trx/trx0trx.cc18
4 files changed, 23 insertions, 28 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 1afcfc6672d..0687b42fcbc 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -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);
}
}
diff --git a/storage/innobase/include/read0read.h b/storage/innobase/include/read0read.h
index f17e7394337..cd129434560 100644
--- a/storage/innobase/include/read0read.h
+++ b/storage/innobase/include/read0read.h
@@ -55,13 +55,7 @@ public:
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);
/**
diff --git a/storage/innobase/read/read0read.cc b/storage/innobase/read/read0read.cc
index c018ab170d0..b2dea25aa9f 100644
--- a/storage/innobase/read/read0read.cc
+++ b/storage/innobase/read/read0read.cc
@@ -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 */
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 26b857a75f3..056bddb5d73 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -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_sys.mvcc.view_close(trx->read_view);
/* 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