summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-10-01 17:49:01 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-10-01 17:49:01 +0300
commit2e6d7fe83a10ecc0d6e6d1dd709fce09f6e92d3c (patch)
tree3f315635fe9ab37899cafe4ad3f08ad0aaeeb4a9
parentd0539bbcc17535e8793d196c40442dba4f8cca29 (diff)
downloadmariadb-git-10.5-MDEV-21452-old.tar.gz
MDEV-21452: Clean up LatchDebug, remove OSMutex and other cruft10.5-MDEV-21452-old
-rw-r--r--storage/innobase/CMakeLists.txt1
-rw-r--r--storage/innobase/handler/ha_innodb.cc5
-rw-r--r--storage/innobase/include/srv0mon.h1
-rw-r--r--storage/innobase/include/sync0policy.h296
-rw-r--r--storage/innobase/include/sync0sync.h7
-rw-r--r--storage/innobase/include/sync0types.h289
-rw-r--r--storage/innobase/sync/sync0debug.cc65
-rw-r--r--storage/innobase/sync/sync0sync.cc22
8 files changed, 41 insertions, 645 deletions
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt
index 62284869120..a712ab26de1 100644
--- a/storage/innobase/CMakeLists.txt
+++ b/storage/innobase/CMakeLists.txt
@@ -238,7 +238,6 @@ SET(INNOBASE_SOURCES
include/sync0arr.h
include/sync0arr.ic
include/sync0debug.h
- include/sync0policy.h
include/sync0rw.h
include/sync0rw.ic
include/sync0sync.h
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 8881c5c0627..9ebf869f1a8 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -522,7 +522,6 @@ static PSI_mutex_info all_innodb_mutexes[] = {
PSI_KEY(ibuf_mutex),
PSI_KEY(ibuf_pessimistic_insert_mutex),
PSI_KEY(log_sys_mutex),
- PSI_KEY(mutex_list_mutex),
PSI_KEY(page_zip_stat_per_index_mutex),
PSI_KEY(purge_sys_pq_mutex),
PSI_KEY(recv_sys_mutex),
@@ -532,7 +531,6 @@ static PSI_mutex_info all_innodb_mutexes[] = {
PSI_KEY(rw_lock_debug_mutex),
# endif /* UNIV_DEBUG */
PSI_KEY(rw_lock_list_mutex),
- PSI_KEY(rw_lock_mutex),
PSI_KEY(srv_innodb_monitor_mutex),
PSI_KEY(srv_misc_tmpfile_mutex),
PSI_KEY(srv_monitor_file_mutex),
@@ -543,9 +541,6 @@ static PSI_mutex_info all_innodb_mutexes[] = {
PSI_KEY(lock_wait_mutex),
PSI_KEY(trx_mutex),
PSI_KEY(srv_threads_mutex),
-# ifndef PFS_SKIP_EVENT_MUTEX
- PSI_KEY(event_mutex),
-# endif /* PFS_SKIP_EVENT_MUTEX */
PSI_KEY(rtr_active_mutex),
PSI_KEY(rtr_match_mutex),
PSI_KEY(rtr_path_mutex),
diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h
index 5e99a2fd7a0..a160c69bb72 100644
--- a/storage/innobase/include/srv0mon.h
+++ b/storage/innobase/include/srv0mon.h
@@ -38,7 +38,6 @@ Created 12/15/2009 Jimmy Yang
#include <stdint.h>
#include "my_atomic.h"
-#include "my_atomic_wrapper.h"
/** Possible status values for "mon_status" in "struct monitor_value" */
enum monitor_running_status {
diff --git a/storage/innobase/include/sync0policy.h b/storage/innobase/include/sync0policy.h
deleted file mode 100644
index 68397827891..00000000000
--- a/storage/innobase/include/sync0policy.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/*****************************************************************************
-
-Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2018, MariaDB Corporation.
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free Software
-Foundation; version 2 of the License.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
-
-*****************************************************************************/
-
-/******************************************************************//**
-@file include/sync0policy.h
-Policies for mutexes.
-
-Created 2012-08-21 Sunny Bains.
-***********************************************************************/
-
-#ifndef sync0policy_h
-#define sync0policy_h
-
-#include "ut0rnd.h"
-#include "os0thread.h"
-#include "srv0mon.h"
-#include "sync0debug.h"
-
-#ifdef UNIV_DEBUG
-
-template <typename Mutex> class MutexDebug: public latch_t
-{
- /** Mutex to check for lock order violation */
- const Mutex *m_mutex;
- /** Filename from where enter was called */
- const char *m_filename;
- /** Line mumber in filename */
- unsigned m_line;
- /** Thread ID of the thread that owns the mutex */
- os_thread_id_t m_thread_id;
- /** Mutex protecting the above members */
- mutable OSMutex m_debug_mutex;
-
-
- void set(const Mutex *mutex, const char *filename, unsigned line,
- os_thread_id_t thread_id)
- {
- m_debug_mutex.enter();
- m_mutex= mutex;
- m_filename= filename;
- m_line= line;
- m_thread_id= thread_id;
- m_debug_mutex.exit();
- }
-
-
- const MutexDebug get() const
- {
- MutexDebug ret;
- m_debug_mutex.enter();
- ret.m_mutex= m_mutex;
- ret.m_filename= m_filename;
- ret.m_line= m_line;
- ret.m_thread_id= m_thread_id;
- m_debug_mutex.exit();
- return ret;
- }
-
-
- /**
- Called either when mutex is locked or destroyed. Thus members are protected
- from concurrent modification.
- */
- void assert_clean_context()
- {
- ut_ad(!m_mutex);
- ut_ad(!m_filename);
- ut_ad(!m_line);
- ut_ad(m_thread_id == os_thread_id_t(ULINT_UNDEFINED));
- }
-
-
-public:
- /**
- Called when the mutex is "created". Note: Not from the constructor
- but when the mutex is initialised.
- @param[in] id Mutex ID
- */
- void init(latch_id_t id)
- {
- ut_ad(id != LATCH_ID_NONE);
- m_id= id;
- m_debug_mutex.init();
- set(0, 0, 0, os_thread_id_t(ULINT_UNDEFINED));
- }
-
-
- /** Mutex is being destroyed. */
- void destroy()
- {
- assert_clean_context();
- m_debug_mutex.destroy();
- }
-
-
- /**
- Called when an attempt is made to lock the mutex
- @param[in] mutex Mutex instance to be locked
- @param[in] filename Filename from where it was called
- @param[in] line Line number from where it was called
- */
- void enter(const Mutex &mutex, const char *filename, unsigned line)
- {
- MutexDebug context;
- ut_ad(!is_owned());
- context.init(m_id);
- context.set(&mutex, filename, line, os_thread_get_curr_id());
- /* Check for latch order violation. */
- sync_check_lock_validate(&context);
- context.set(0, 0, 0, os_thread_id_t(ULINT_UNDEFINED));
- context.destroy();
- }
-
-
- /**
- Called when the mutex is locked
- @param[in] mutex Mutex instance that was locked
- @param[in] filename Filename from where it was called
- @param[in] line Line number from where it was called
- */
- void locked(const Mutex &mutex, const char *filename, unsigned line)
- {
- assert_clean_context();
- set(&mutex, filename, line, os_thread_get_curr_id());
- sync_check_lock_granted(this);
- }
-
-
- /**
- Called when the mutex is released
- @param[in] mutex Mutex that was released
- */
- void release(const Mutex &mutex)
- {
- ut_ad(is_owned());
- set(0, 0, 0, os_thread_id_t(ULINT_UNDEFINED));
- sync_check_unlock(this);
- }
-
-
- /** @return true if thread owns the mutex */
- bool is_owned() const
- {
- return os_thread_eq(get_thread_id(), os_thread_get_curr_id());
- }
-
-
- /** @return the name of the file from the mutex was acquired */
- const char* get_enter_filename() const { return get().m_filename; }
-
-
- /** @return the name of the file from the mutex was acquired */
- unsigned get_enter_line() const { return get().m_line; }
-
-
- /** @return id of the thread that was trying to acquire the mutex */
- os_thread_id_t get_thread_id() const { return get().m_thread_id; }
-
-
- /**
- Print information about the latch
- @return the string representation
- */
- virtual std::string to_string() const
- {
- std::ostringstream msg;
- const MutexDebug ctx= get();
-
- msg << m_mutex->policy().to_string();
- if (ctx.m_mutex)
- msg << " addr: " << ctx.m_mutex << " acquired: "
- << sync_basename(ctx.get_enter_filename()) << ":"
- << ctx.get_enter_line();
- else
- msg << "Not locked";
-
- return(msg.str());
- }
-};
-#endif /* UNIV_DEBUG */
-
-/** Collect the metrics per mutex instance, no aggregation. */
-template <typename Mutex>
-struct GenericPolicy
-{
-public:
- /** Called when the mutex is "created". Note: Not from the constructor
- but when the mutex is initialised.
- @param[in] id Mutex ID
- @param[in] filename File where mutex was created
- @param[in] line Line in filename */
- void init(
- const Mutex&,
- latch_id_t id,
- const char* filename,
- uint32_t line)
- UNIV_NOTHROW
- {
- m_id = id;
-
- latch_meta_t& meta = sync_latch_get_meta(id);
-
- ut_ad(meta.get_id() == id);
-
- meta.get_counter()->single_register(&m_count);
-
- m_filename = filename;
- m_line = line;
- }
-
- /** Called when the mutex is destroyed. */
- void destroy()
- UNIV_NOTHROW
- {
- latch_meta_t& meta = sync_latch_get_meta(m_id);
-
- meta.get_counter()->single_deregister(&m_count);
- }
-
- /** Called after a successful mutex acquire.
- @param[in] n_spins Number of times the thread did
- spins while trying to acquire the mutex
- @param[in] n_waits Number of times the thread waited
- in some type of OS queue */
- void add(
- uint32_t n_spins,
- uint32_t n_waits)
- UNIV_NOTHROW
- {
- /* Currently global on/off. Keeps things simple and fast */
-
- if (!m_count.m_enabled) {
-
- return;
- }
-
- m_count.m_spins += n_spins;
- m_count.m_waits += n_waits;
-
- ++m_count.m_calls;
- }
-
- /** Print the information about the latch
- @return the string representation */
- std::string print() const
- UNIV_NOTHROW;
-
- /** @return the latch ID */
- latch_id_t get_id() const
- UNIV_NOTHROW
- {
- return(m_id);
- }
-
-
- /** @return the string representation */
- std::string to_string() const
- {
- return sync_mutex_to_string(get_id(),
- std::string(m_filename)
- .append(":")
- .append(std::to_string(m_line)));
- }
-
-#ifdef UNIV_DEBUG
- MutexDebug<Mutex> context;
-#endif
-
-private:
- const char *m_filename;
- uint32_t m_line;
-
- /** The user visible counters, registered with the meta-data. */
- latch_meta_t::CounterType::Count m_count;
-
- /** Latch meta data ID */
- latch_id_t m_id;
-};
-
-#endif /* sync0policy_h */
diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h
index cd54f98dad9..8acef69816c 100644
--- a/storage/innobase/include/sync0sync.h
+++ b/storage/innobase/include/sync0sync.h
@@ -43,9 +43,6 @@ Created 9/5/1995 Heikki Tuuri
instrumentation due to their large number of instances. */
# define PFS_SKIP_BUFFER_MUTEX_RWLOCK
-/* By default, event->mutex will also be excluded from instrumentation */
-# define PFS_SKIP_EVENT_MUTEX
-
#endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */
#ifdef UNIV_PFS_MUTEX
@@ -64,7 +61,6 @@ extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
extern mysql_pfs_key_t log_sys_mutex_key;
extern mysql_pfs_key_t log_cmdq_mutex_key;
extern mysql_pfs_key_t log_flush_order_mutex_key;
-extern mysql_pfs_key_t mutex_list_mutex_key;
extern mysql_pfs_key_t recalc_pool_mutex_key;
extern mysql_pfs_key_t purge_sys_pq_mutex_key;
extern mysql_pfs_key_t recv_sys_mutex_key;
@@ -76,7 +72,6 @@ extern mysql_pfs_key_t page_zip_stat_per_index_mutex_key;
extern mysql_pfs_key_t rw_lock_debug_mutex_key;
# endif /* UNIV_DEBUG */
extern mysql_pfs_key_t rw_lock_list_mutex_key;
-extern mysql_pfs_key_t rw_lock_mutex_key;
extern mysql_pfs_key_t srv_innodb_monitor_mutex_key;
extern mysql_pfs_key_t srv_misc_tmpfile_mutex_key;
extern mysql_pfs_key_t srv_monitor_file_mutex_key;
@@ -87,8 +82,6 @@ extern mysql_pfs_key_t trx_pool_manager_mutex_key;
extern mysql_pfs_key_t lock_mutex_key;
extern mysql_pfs_key_t lock_wait_mutex_key;
extern mysql_pfs_key_t srv_threads_mutex_key;
-extern mysql_pfs_key_t event_mutex_key;
-extern mysql_pfs_key_t event_manager_mutex_key;
extern mysql_pfs_key_t sync_array_mutex_key;
extern mysql_pfs_key_t thread_mutex_key;
extern mysql_pfs_key_t row_drop_list_mutex_key;
diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h
index 712153569ef..8698aeff7e0 100644
--- a/storage/innobase/include/sync0types.h
+++ b/storage/innobase/include/sync0types.h
@@ -24,33 +24,12 @@ Global types for sync
Created 9/5/1995 Heikki Tuuri
*******************************************************/
-#ifndef sync0types_h
-#define sync0types_h
-
+#pragma once
+#include "my_atomic_wrapper.h"
#include <vector>
#include "ut0new.h"
-#ifdef _WIN32
-/** Native mutex */
-typedef CRITICAL_SECTION sys_mutex_t;
-#else
-/** Native mutex */
-typedef pthread_mutex_t sys_mutex_t;
-#endif /* _WIN32 */
-
-/** Mutex states. */
-enum mutex_state_t {
- /** Mutex is free */
- MUTEX_STATE_UNLOCKED = 0,
-
- /** Mutex is acquired by some thread. */
- MUTEX_STATE_LOCKED = 1,
-
- /** Mutex is contended and there are threads waiting on the lock. */
- MUTEX_STATE_WAITERS = 2
-};
-
/*
LATCHING ORDER WITHIN THE DATABASE
==================================
@@ -184,8 +163,6 @@ enum latch_level_t {
RW_LOCK_X,
RW_LOCK_NOT_LOCKED,
- SYNC_MONITOR_MUTEX,
-
SYNC_ANY_LATCH,
SYNC_BUF_PAGE_HASH,
@@ -236,151 +213,20 @@ enum latch_level_t {
up its meta-data. See sync0debug.c. */
enum latch_id_t {
LATCH_ID_NONE = 0,
- LATCH_ID_FILE_FORMAT_MAX,
- LATCH_ID_LIST,
- LATCH_ID_MUTEX_LIST,
- LATCH_ID_RW_LOCK_MUTEX,
- LATCH_ID_SRV_SYS,
- LATCH_ID_EVENT_MANAGER,
- LATCH_ID_EVENT_MUTEX,
LATCH_ID_BTR_SEARCH,
LATCH_ID_BUF_BLOCK_LOCK,
LATCH_ID_BUF_BLOCK_DEBUG,
LATCH_ID_DICT_OPERATION,
- LATCH_ID_CHECKPOINT,
LATCH_ID_FIL_SPACE,
LATCH_ID_TRX_I_S_CACHE,
LATCH_ID_TRX_PURGE,
LATCH_ID_IBUF_INDEX_TREE,
LATCH_ID_INDEX_TREE,
LATCH_ID_DICT_TABLE_STATS,
- LATCH_ID_HASH_TABLE_RW_LOCK,
- LATCH_ID_BUF_CHUNK_MAP_LATCH,
- LATCH_ID_SYNC_DEBUG_MUTEX,
- LATCH_ID_TEST_MUTEX,
- LATCH_ID_MAX = LATCH_ID_TEST_MUTEX
-};
-
-#ifndef UNIV_INNOCHECKSUM
-/** OS mutex, without any policy. It is a thin wrapper around the
-system mutexes. The interface is different from the policy mutexes,
-to ensure that it is called directly and not confused with the
-policy mutexes. */
-struct OSMutex {
-
- /** Constructor */
- OSMutex()
- UNIV_NOTHROW
- {
- ut_d(m_freed = true);
- }
-
- /** Create the mutex by calling the system functions. */
- void init()
- UNIV_NOTHROW
- {
- ut_ad(m_freed);
-
-#ifdef _WIN32
- InitializeCriticalSection((LPCRITICAL_SECTION) &m_mutex);
-#else
- {
- int ret = pthread_mutex_init(&m_mutex, NULL);
- ut_a(ret == 0);
- }
-#endif /* _WIN32 */
-
- ut_d(m_freed = false);
- }
-
- /** Destructor */
- ~OSMutex() { }
-
- /** Destroy the mutex */
- void destroy()
- UNIV_NOTHROW
- {
- ut_ad(!m_freed);
-#ifdef _WIN32
- DeleteCriticalSection((LPCRITICAL_SECTION) &m_mutex);
-#else
- int ret;
-
- ret = pthread_mutex_destroy(&m_mutex);
-
- if (ret != 0) {
-
- ib::error()
- << "Return value " << ret << " when calling "
- << "pthread_mutex_destroy().";
- }
-#endif /* _WIN32 */
- ut_d(m_freed = true);
- }
-
- /** Release the mutex. */
- void exit()
- UNIV_NOTHROW
- {
- ut_ad(!m_freed);
-#ifdef _WIN32
- LeaveCriticalSection(&m_mutex);
-#else
- int ret = pthread_mutex_unlock(&m_mutex);
- ut_a(ret == 0);
-#endif /* _WIN32 */
- }
-
- /** Acquire the mutex. */
- void enter()
- UNIV_NOTHROW
- {
- ut_ad(!m_freed);
-#ifdef _WIN32
- EnterCriticalSection((LPCRITICAL_SECTION) &m_mutex);
-#else
- int ret = pthread_mutex_lock(&m_mutex);
- ut_a(ret == 0);
-#endif /* _WIN32 */
- }
-
- /** @return true if locking succeeded */
- bool try_lock()
- UNIV_NOTHROW
- {
- ut_ad(!m_freed);
-#ifdef _WIN32
- return(TryEnterCriticalSection(&m_mutex) != 0);
-#else
- return(pthread_mutex_trylock(&m_mutex) == 0);
-#endif /* _WIN32 */
- }
-
- /** Required for os_event_t */
- operator sys_mutex_t*()
- UNIV_NOTHROW
- {
- return(&m_mutex);
- }
-
-private:
-#ifdef DBUG_ASSERT_EXISTS
- /** true if the mutex has been freed/destroyed. */
- bool m_freed;
-#endif /* DBUG_ASSERT_EXISTS */
-
- sys_mutex_t m_mutex;
+ LATCH_ID_MAX = LATCH_ID_DICT_TABLE_STATS
};
#ifdef UNIV_PFS_MUTEX
-/** Latch element.
-Used for mutexes which have PFS keys defined under UNIV_PFS_MUTEX.
-@param[in] id Latch id
-@param[in] level Latch level
-@param[in] key PFS key */
-# define LATCH_ADD_MUTEX(id, level, key) latch_meta[LATCH_ID_ ## id] =\
- UT_NEW_NOKEY(latch_meta_t(LATCH_ID_ ## id, #id, level, #level, key))
-
#ifdef UNIV_PFS_RWLOCK
/** Latch element.
Used for rwlocks which have PFS keys defined under UNIV_PFS_RWLOCK.
@@ -396,8 +242,6 @@ Used for rwlocks which have PFS keys defined under UNIV_PFS_RWLOCK.
#endif /* UNIV_PFS_RWLOCK */
#else
-# define LATCH_ADD_MUTEX(id, level, key) latch_meta[LATCH_ID_ ## id] =\
- UT_NEW_NOKEY(latch_meta_t(LATCH_ID_ ## id, #id, level, #level))
# define LATCH_ADD_RWLOCK(id, level, key) latch_meta[LATCH_ID_ ## id] =\
UT_NEW_NOKEY(latch_meta_t(LATCH_ID_ ## id, #id, level, #level))
#endif /* UNIV_PFS_MUTEX */
@@ -444,28 +288,14 @@ public:
};
/** Constructor */
- LatchCounter()
- UNIV_NOTHROW
- :
- m_active(false)
- {
- m_mutex.init();
- }
+ LatchCounter() { mysql_mutex_init(0, &m_mutex, nullptr); }
/** Destructor */
~LatchCounter()
UNIV_NOTHROW
{
- m_mutex.destroy();
-
- for (Counters::iterator it = m_counters.begin();
- it != m_counters.end();
- ++it) {
-
- Count* count = *it;
-
- UT_DELETE(count);
- }
+ mysql_mutex_destroy(&m_mutex);
+ for (Count *count : m_counters) UT_DELETE(count);
}
/** Reset all counters to zero. It is not protected by any
@@ -475,25 +305,16 @@ public:
void reset()
UNIV_NOTHROW
{
- m_mutex.enter();
-
- Counters::iterator end = m_counters.end();
-
- for (Counters::iterator it = m_counters.begin();
- it != end;
- ++it) {
-
- (*it)->reset();
- }
-
- m_mutex.exit();
+ mysql_mutex_lock(&m_mutex);
+ for (Count *count : m_counters) count->reset();
+ mysql_mutex_unlock(&m_mutex);
}
/** @return the aggregate counter */
Count* sum_register()
UNIV_NOTHROW
{
- m_mutex.enter();
+ mysql_mutex_lock(&m_mutex);
Count* count;
@@ -505,7 +326,7 @@ public:
count = m_counters[0];
}
- m_mutex.exit();
+ mysql_mutex_unlock(&m_mutex);
return(count);
}
@@ -514,11 +335,9 @@ public:
void single_register(Count* count)
UNIV_NOTHROW
{
- m_mutex.enter();
-
+ mysql_mutex_lock(&m_mutex);
m_counters.push_back(count);
-
- m_mutex.exit();
+ mysql_mutex_unlock(&m_mutex);
}
/** Deregister a single instance counter
@@ -526,15 +345,13 @@ public:
void single_deregister(Count* count)
UNIV_NOTHROW
{
- m_mutex.enter();
-
+ mysql_mutex_lock(&m_mutex);
m_counters.erase(
std::remove(
m_counters.begin(),
m_counters.end(), count),
m_counters.end());
-
- m_mutex.exit();
+ mysql_mutex_unlock(&m_mutex);
}
/** Iterate over the counters */
@@ -542,80 +359,43 @@ public:
void iterate(Callback& callback) const
UNIV_NOTHROW
{
- Counters::const_iterator end = m_counters.end();
-
- for (Counters::const_iterator it = m_counters.begin();
- it != end;
- ++it) {
-
- callback(*it);
- }
+ for (Count *count : m_counters) callback(count);
}
/** Disable the monitoring */
void enable()
UNIV_NOTHROW
{
- m_mutex.enter();
-
- Counters::const_iterator end = m_counters.end();
-
- for (Counters::const_iterator it = m_counters.begin();
- it != end;
- ++it) {
-
- (*it)->m_enabled = true;
- }
-
+ mysql_mutex_lock(&m_mutex);
+ for (Count *count : m_counters) count->m_enabled = true;
m_active = true;
-
- m_mutex.exit();
+ mysql_mutex_unlock(&m_mutex);
}
/** Disable the monitoring */
void disable()
UNIV_NOTHROW
{
- m_mutex.enter();
-
- Counters::const_iterator end = m_counters.end();
-
- for (Counters::const_iterator it = m_counters.begin();
- it != end;
- ++it) {
-
- (*it)->m_enabled = false;
- }
-
+ mysql_mutex_lock(&m_mutex);
+ for (Count *count : m_counters) count->m_enabled = false;
m_active = false;
-
- m_mutex.exit();
+ mysql_mutex_unlock(&m_mutex);
}
/** @return if monitoring is active */
- bool is_enabled() const
- UNIV_NOTHROW
- {
- return(m_active);
- }
+ bool is_enabled() const { return m_active; }
-private:
- /* Disable copying */
- LatchCounter(const LatchCounter&);
- LatchCounter& operator=(const LatchCounter&);
-
-private:
- typedef OSMutex Mutex;
- typedef std::vector<Count*> Counters;
+ LatchCounter(const LatchCounter&) = delete;
+ LatchCounter& operator=(const LatchCounter&) = delete;
/** Mutex protecting m_counters */
- Mutex m_mutex;
+ mysql_mutex_t m_mutex;
/** Counters for the latches */
- Counters m_counters;
+ std::vector<Count*> m_counters;
/** if true then we collect the data */
- bool m_active;
+ Atomic_relaxed<bool> m_active= false;
};
/** Latch meta data */
@@ -811,16 +591,6 @@ sync_latch_get_pfs_key(latch_id_t id)
}
#endif
-/** String representation of the filename and line number where the
-latch was created
-@param[in] id Latch ID
-@param[in] created Filename and line number where it was crated
-@return the string representation */
-std::string
-sync_mutex_to_string(
- latch_id_t id,
- const std::string& created);
-
/** Get the latch name from a sync level
@param[in] level Latch level to lookup
@return 0 if not found. */
@@ -974,8 +744,6 @@ enum rw_lock_flag_t {
#endif /* UNIV_DBEUG */
-#endif /* UNIV_INNOCHECKSUM */
-
/** Simple non-atomic counter aligned to CACHE_LINE_SIZE
@tparam Type the integer type of the counter */
template <typename Type>
@@ -998,4 +766,3 @@ private:
/** The counter */
Type m_counter;
};
-#endif /* sync0types_h */
diff --git a/storage/innobase/sync/sync0debug.cc b/storage/innobase/sync/sync0debug.cc
index ed49ceac263..4ae80bb5671 100644
--- a/storage/innobase/sync/sync0debug.cc
+++ b/storage/innobase/sync/sync0debug.cc
@@ -95,11 +95,6 @@ typedef std::vector<Latched, ut_allocator<Latched> > Latches;
/** The deadlock detector. */
struct LatchDebug {
-
- /** Debug mutex for control structures, should not be tracked
- by this module. */
- typedef OSMutex Mutex;
-
/** Comparator for the ThreadMap. */
struct os_thread_id_less
: public std::binary_function<
@@ -130,11 +125,7 @@ struct LatchDebug {
UNIV_NOTHROW;
/** Destructor */
- ~LatchDebug()
- UNIV_NOTHROW
- {
- m_mutex.destroy();
- }
+ ~LatchDebug() { mysql_mutex_destroy(&m_mutex); }
/** Create a new instance if one doesn't exist else return
the existing one.
@@ -352,11 +343,10 @@ struct LatchDebug {
s_instance = UT_NEW_NOKEY(LatchDebug());
}
-private:
- /** Disable copying */
- LatchDebug(const LatchDebug&);
- LatchDebug& operator=(const LatchDebug&);
+ LatchDebug(const LatchDebug&) = delete;
+ LatchDebug& operator=(const LatchDebug&) = delete;
+private:
/** Adds a latch and its level in the thread level array. Allocates
the memory for the array if called first time for this OS thread.
Makes the checks against other latch levels stored in the array
@@ -375,7 +365,6 @@ private:
void print_latches(const Latches* latches) const
UNIV_NOTHROW;
-private:
/** Comparator for the Levels . */
struct latch_level_less
: public std::binary_function<
@@ -401,7 +390,7 @@ private:
Levels;
/** Mutex protecting the deadlock detector data structures. */
- Mutex m_mutex;
+ mysql_mutex_t m_mutex;
/** Thread specific data. Protected by m_mutex. */
ThreadMap m_threads;
@@ -431,7 +420,7 @@ do { \
/** Setup the mapping from level ID to level name mapping */
LatchDebug::LatchDebug()
{
- m_mutex.init();
+ mysql_mutex_init(0, &m_mutex, nullptr);
LEVEL_MAP_INSERT(SYNC_UNKNOWN);
LEVEL_MAP_INSERT(RW_LOCK_SX);
@@ -439,7 +428,6 @@ LatchDebug::LatchDebug()
LEVEL_MAP_INSERT(RW_LOCK_S);
LEVEL_MAP_INSERT(RW_LOCK_X);
LEVEL_MAP_INSERT(RW_LOCK_NOT_LOCKED);
- LEVEL_MAP_INSERT(SYNC_MONITOR_MUTEX);
LEVEL_MAP_INSERT(SYNC_ANY_LATCH);
LEVEL_MAP_INSERT(SYNC_BUF_PAGE_HASH);
LEVEL_MAP_INSERT(SYNC_SEARCH_SYS);
@@ -584,7 +572,7 @@ Latches*
LatchDebug::thread_latches(bool add)
UNIV_NOTHROW
{
- m_mutex.enter();
+ mysql_mutex_lock(&m_mutex);
os_thread_id_t thread_id = os_thread_get_curr_id();
ThreadMap::iterator lb = m_threads.lower_bound(thread_id);
@@ -594,16 +582,13 @@ LatchDebug::thread_latches(bool add)
Latches* latches = lb->second;
- m_mutex.exit();
+ mysql_mutex_unlock(&m_mutex);
return(latches);
} else if (!add) {
-
- m_mutex.exit();
-
+ mysql_mutex_unlock(&m_mutex);
return(NULL);
-
} else {
typedef ThreadMap::value_type value_type;
@@ -614,8 +599,7 @@ LatchDebug::thread_latches(bool add)
latches->reserve(32);
m_threads.insert(lb, value_type(thread_id, latches));
-
- m_mutex.exit();
+ mysql_mutex_unlock(&m_mutex);
return(latches);
}
@@ -698,7 +682,6 @@ LatchDebug::check_order(
/* Fall through */
- case SYNC_MONITOR_MUTEX:
case SYNC_SEARCH_SYS:
case SYNC_PURGE_LATCH:
case SYNC_DICT_OPERATION:
@@ -875,17 +858,12 @@ LatchDebug::unlock(const latch_t* latch)
This could be expensive. */
if (latches->empty()) {
-
- m_mutex.enter();
-
- os_thread_id_t thread_id;
-
+ os_thread_id_t thread_id;
thread_id = os_thread_get_curr_id();
+ mysql_mutex_lock(&m_mutex);
m_threads.erase(thread_id);
-
- m_mutex.exit();
-
+ mysql_mutex_unlock(&m_mutex);
UT_DELETE(latches);
}
@@ -1114,20 +1092,6 @@ sync_latch_meta_init()
/* The latches should be ordered on latch_id_t. So that we can
index directly into the vector to update and fetch meta-data. */
- LATCH_ADD_MUTEX(MUTEX_LIST, SYNC_NO_ORDER_CHECK, mutex_list_mutex_key);
-
- LATCH_ADD_MUTEX(RW_LOCK_MUTEX, SYNC_NO_ORDER_CHECK, rw_lock_mutex_key);
-
-#ifndef PFS_SKIP_EVENT_MUTEX
- LATCH_ADD_MUTEX(EVENT_MANAGER, SYNC_NO_ORDER_CHECK,
- event_manager_mutex_key);
-#else
- LATCH_ADD_MUTEX(EVENT_MANAGER, SYNC_NO_ORDER_CHECK,
- PFS_NOT_INSTRUMENTED);
-#endif /* !PFS_SKIP_EVENT_MUTEX */
-
- LATCH_ADD_MUTEX(EVENT_MUTEX, SYNC_NO_ORDER_CHECK, event_mutex_key);
-
// Add the RW locks
LATCH_ADD_RWLOCK(BTR_SEARCH, SYNC_SEARCH_SYS, btr_search_latch_key);
@@ -1157,9 +1121,6 @@ sync_latch_meta_init()
LATCH_ADD_RWLOCK(DICT_TABLE_STATS, SYNC_INDEX_TREE,
dict_table_stats_key);
- LATCH_ADD_MUTEX(SYNC_DEBUG_MUTEX, SYNC_NO_ORDER_CHECK,
- PFS_NOT_INSTRUMENTED);
-
latch_id_t id = LATCH_ID_NONE;
/* The array should be ordered on latch ID.We need to
diff --git a/storage/innobase/sync/sync0sync.cc b/storage/innobase/sync/sync0sync.cc
index 5f32d7adf45..9aa35832c9b 100644
--- a/storage/innobase/sync/sync0sync.cc
+++ b/storage/innobase/sync/sync0sync.cc
@@ -51,7 +51,6 @@ mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
mysql_pfs_key_t log_sys_mutex_key;
mysql_pfs_key_t log_cmdq_mutex_key;
mysql_pfs_key_t log_flush_order_mutex_key;
-mysql_pfs_key_t mutex_list_mutex_key;
mysql_pfs_key_t recalc_pool_mutex_key;
mysql_pfs_key_t purge_sys_pq_mutex_key;
mysql_pfs_key_t recv_sys_mutex_key;
@@ -65,7 +64,6 @@ mysql_pfs_key_t rtr_active_mutex_key;
mysql_pfs_key_t rtr_match_mutex_key;
mysql_pfs_key_t rtr_path_mutex_key;
mysql_pfs_key_t rw_lock_list_mutex_key;
-mysql_pfs_key_t rw_lock_mutex_key;
mysql_pfs_key_t srv_innodb_monitor_mutex_key;
mysql_pfs_key_t srv_misc_tmpfile_mutex_key;
mysql_pfs_key_t srv_monitor_file_mutex_key;
@@ -77,8 +75,6 @@ mysql_pfs_key_t lock_mutex_key;
mysql_pfs_key_t lock_wait_mutex_key;
mysql_pfs_key_t trx_sys_mutex_key;
mysql_pfs_key_t srv_threads_mutex_key;
-mysql_pfs_key_t event_mutex_key;
-mysql_pfs_key_t event_manager_mutex_key;
mysql_pfs_key_t sync_array_mutex_key;
mysql_pfs_key_t thread_mutex_key;
mysql_pfs_key_t row_drop_list_mutex_key;
@@ -174,21 +170,3 @@ sync_basename(const char* filename)
return(ptr);
}
-
-/** String representation of the filename and line number where the
-latch was created
-@param[in] id Latch ID
-@param[in] created Filename and line number where it was crated
-@return the string representation */
-std::string
-sync_mutex_to_string(
- latch_id_t id,
- const std::string& created)
-{
- std::ostringstream msg;
-
- msg << "Mutex " << sync_latch_get_name(id) << " "
- << "created " << created;
-
- return(msg.str());
-}