MySQL 9.1.0
Source Code Documentation
|
#include "sql/mdl.h"
#include <time.h>
#include <algorithm>
#include <atomic>
#include <functional>
#include "lf.h"
#include "my_dbug.h"
#include "my_macros.h"
#include "my_murmur3.h"
#include "my_sharedlib.h"
#include "my_sys.h"
#include "my_systime.h"
#include "my_thread.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/components/services/bits/psi_cond_bits.h"
#include "mysql/components/services/bits/psi_memory_bits.h"
#include "mysql/components/services/bits/psi_mutex_bits.h"
#include "mysql/components/services/bits/psi_rwlock_bits.h"
#include "mysql/psi/mysql_cond.h"
#include "mysql/psi/mysql_mdl.h"
#include "mysql/psi/mysql_memory.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_stage.h"
#include "mysql/psi/psi_mdl.h"
#include "mysql/service_thd_wait.h"
#include "mysql/strings/m_ctype.h"
#include "mysqld_error.h"
#include "prealloced_array.h"
#include "sql/debug_sync.h"
#include "sql/thr_malloc.h"
Classes | |
class | MDL_map |
A collection of all MDL locks. More... | |
class | Deadlock_detection_visitor |
A context of the recursive traversal through all contexts in all sessions in search for deadlock. More... | |
class | MDL_lock |
The lock context. More... | |
class | MDL_lock::Ticket_list |
struct | MDL_lock::MDL_lock_strategy |
Helper struct which defines how different types of locks are handled for a specific MDL_lock. More... | |
class | MDL_request_cmp |
Macros | |
#define | MDL_BIT(A) static_cast<MDL_lock::bitmap_t>(1U << A) |
Get a bit corresponding to enum_mdl_type value in a granted/waiting bitmaps and compatibility matrices. More... | |
Functions | |
static void | init_mdl_psi_keys (void) |
Initialise all the performance schema instrumentation points used by the MDL subsystem. More... | |
static const uchar * | mdl_locks_key (const uchar *record, size_t *length) |
void | mdl_init () |
Initialize the metadata locking subsystem. More... | |
void | mdl_destroy () |
Release resources of metadata locking subsystem. More... | |
int32 | mdl_get_unused_locks_count () |
Get number of unused MDL_lock objects in MDL_map cache. More... | |
static void | mdl_lock_cons (uchar *arg) |
static void | mdl_lock_dtor (uchar *arg) |
static void | mdl_lock_reinit (uchar *dst_arg, const uchar *src_arg) |
static uint | murmur3_adapter (const LF_HASH *, const uchar *key, size_t length) |
Adapter function which allows to use murmur3 with LF_HASH implementation. More... | |
static int | mdl_lock_match_unused (const uchar *arg, void *match_arg) |
Helper function which allows to check if MDL_lock object stored in LF_HASH is unused - i.e. More... | |
bool | equivalent (const MDL_ticket *a, const MDL_ticket *b, enum_mdl_duration target_duration) |
Variables | |
MYSQL_PLUGIN_IMPORT CHARSET_INFO * | system_charset_info |
static PSI_memory_key | key_memory_MDL_context_acquire_locks |
static PSI_mutex_key | key_MDL_wait_LOCK_wait_status |
static PSI_mutex_info | all_mdl_mutexes [] |
static PSI_rwlock_key | key_MDL_lock_rwlock |
static PSI_rwlock_key | key_MDL_context_LOCK_waiting_for |
static PSI_rwlock_info | all_mdl_rwlocks [] |
static PSI_cond_key | key_MDL_wait_COND_wait_status |
static PSI_cond_info | all_mdl_conds [] |
static PSI_memory_info | all_mdl_memory [] |
static bool | mdl_initialized = false |
int32 | mdl_locks_unused_locks_low_water |
Threshold for number of unused MDL_lock objects. More... | |
static MDL_map | mdl_locks |
#define MDL_BIT | ( | A | ) | static_cast<MDL_lock::bitmap_t>(1U << A) |
Get a bit corresponding to enum_mdl_type value in a granted/waiting bitmaps and compatibility matrices.
bool equivalent | ( | const MDL_ticket * | a, |
const MDL_ticket * | b, | ||
enum_mdl_duration | target_duration | ||
) |
|
static |
Initialise all the performance schema instrumentation points used by the MDL subsystem.
void mdl_destroy | ( | ) |
Release resources of metadata locking subsystem.
Destroys the global mutex and the condition variable. Called at server shutdown.
int32 mdl_get_unused_locks_count | ( | ) |
Get number of unused MDL_lock objects in MDL_map cache.
Mostly needed for unit-testing.
void mdl_init | ( | ) |
Initialize the metadata locking subsystem.
This function is called at server startup.
In particular, initializes the new global mutex and the associated condition variable: LOCK_mdl and COND_mdl. These locking primitives are implementation details of the MDL subsystem and are private to it.
|
static |
|
static |
|
static |
Helper function which allows to check if MDL_lock object stored in LF_HASH is unused - i.e.
doesn't have any locks on both "fast" and "slow" paths and is not marked as deleted.
Adapter function which allows to use murmur3 with LF_HASH implementation.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
int32 mdl_locks_unused_locks_low_water |
Threshold for number of unused MDL_lock objects.
We will start considering freeing some unused objects only after exceeding this value and if unused/total objects ratio is high enough.
Normally this threshold is constant. It is exposed outside of MDL subsystem as a variable only in order to simplify unit testing.
|
extern |