MySQL 8.4.3
Source Code Documentation
|
#include <assert.h>
#include <string.h>
#include <sys/types.h>
#include <algorithm>
#include <new>
#include <unordered_map>
#include "my_alloc.h"
#include "my_compiler.h"
#include "strmake.h"
#include "my_inttypes.h"
#include "my_psi_config.h"
#include "my_sys.h"
#include "my_systime.h"
#include "mysql/components/services/bits/mysql_cond_bits.h"
#include "mysql/components/services/bits/mysql_mutex_bits.h"
#include "mysql/components/services/bits/mysql_rwlock_bits.h"
#include "mysql/components/services/bits/psi_mdl_bits.h"
#include "mysql/components/services/bits/psi_stage_bits.h"
#include "mysql/psi/mysql_rwlock.h"
#include "mysql_com.h"
#include "sql/sql_plist.h"
#include "template_utils.h"
Go to the source code of this file.
Classes | |
class | MDL_context_owner |
An interface to separate the MDL module from the THD, and the rest of the server code. More... | |
struct | MDL_key |
Metadata lock object key. More... | |
class | MDL_request |
A pending metadata lock request. More... | |
class | MDL_wait_for_graph_visitor |
An abstract class for inspection of a connected subgraph of the wait-for graph. More... | |
class | MDL_wait_for_subgraph |
Abstract class representing an edge in the waiters graph to be traversed by deadlock detection algorithm. More... | |
class | MDL_ticket |
A granted metadata lock. More... | |
class | MDL_ticket_store |
Keep track of MDL_ticket for different durations. More... | |
struct | MDL_ticket_store::MDL_ticket_handle |
Utility struct for representing a ticket pointer and its duration. More... | |
struct | MDL_ticket_store::Duration |
struct | MDL_ticket_store::Hash |
struct | MDL_ticket_store::Key_equal |
class | MDL_savepoint |
Savepoint for MDL context. More... | |
class | MDL_wait |
A reliable way to wait on an MDL lock. More... | |
class | MDL_release_locks_visitor |
Base class to find out if the lock represented by a given ticket should be released. More... | |
class | MDL_context_visitor |
Abstract visitor class for inspecting MDL_context. More... | |
class | MDL_context |
Context of the owner of metadata locks. More... | |
Namespaces | |
namespace | mdl_unittest |
Macros | |
#define | ENTER_COND(C, M, S, O) enter_cond(C, M, S, O, __func__, __FILE__, __LINE__) |
Start a wait on a condition. More... | |
#define | EXIT_COND(S) exit_cond(S, __func__, __FILE__, __LINE__) |
End a wait on a condition. More... | |
#define | MAX_MDLKEY_LENGTH (1 + NAME_LEN + 1 + NAME_LEN + 1) |
Maximal length of key for metadata locking subsystem. More... | |
#define | MDL_REQUEST_INIT(R, P1, P2, P3, P4, P5) (*R).init_with_source(P1, P2, P3, P4, P5, __FILE__, __LINE__) |
#define | MDL_REQUEST_INIT_BY_KEY(R, P1, P2, P3) (*R).init_by_key_with_source(P1, P2, P3, __FILE__, __LINE__) |
#define | MDL_REQUEST_INIT_BY_PART_KEY(R, P1, P2, P3, P4, P5, P6) (*R).init_by_part_key_with_source(P1, P2, P3, P4, P5, P6, __FILE__, __LINE__) |
Typedefs | |
typedef I_P_List< MDL_request, I_P_List_adapter< MDL_request, &MDL_request::next_in_list, &MDL_request::prev_in_list >, I_P_List_counter > | MDL_request_list |
Enumerations | |
enum | enum_mdl_type { MDL_INTENTION_EXCLUSIVE = 0 , MDL_SHARED , MDL_SHARED_HIGH_PRIO , MDL_SHARED_READ , MDL_SHARED_WRITE , MDL_SHARED_WRITE_LOW_PRIO , MDL_SHARED_UPGRADABLE , MDL_SHARED_READ_ONLY , MDL_SHARED_NO_WRITE , MDL_SHARED_NO_READ_WRITE , MDL_EXCLUSIVE , MDL_TYPE_END , MDL_INTENTION_EXCLUSIVE = 0 , MDL_SHARED , MDL_SHARED_HIGH_PRIO , MDL_SHARED_READ , MDL_SHARED_WRITE , MDL_SHARED_WRITE_LOW_PRIO , MDL_SHARED_UPGRADABLE , MDL_SHARED_READ_ONLY , MDL_SHARED_NO_WRITE , MDL_SHARED_NO_READ_WRITE , MDL_EXCLUSIVE , MDL_TYPE_END } |
Type of metadata lock request. More... | |
enum | enum_mdl_duration { MDL_STATEMENT = 0 , MDL_TRANSACTION , MDL_EXPLICIT , MDL_DURATION_END } |
Duration of metadata lock. More... | |
Functions | |
bool | mdl_unittest::test_drive_fix_pins (MDL_context *) |
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... | |
Variables | |
mysql_mutex_t | LOCK_open |
LOCK_open protects the following variables/objects: More... | |
ulong | max_write_lock_count |
int32 | mdl_locks_unused_locks_low_water |
Threshold for number of unused MDL_lock objects. More... | |
const int32 | MDL_LOCKS_UNUSED_LOCKS_LOW_WATER_DEFAULT = 1000 |
Default value for threshold for number of unused MDL_lock objects after exceeding which we start considering freeing them. More... | |
const double | MDL_LOCKS_UNUSED_LOCKS_MIN_RATIO = 0.25 |
Ratio of unused/total MDL_lock objects after exceeding which we start trying to free unused MDL_lock objects (assuming that mdl_locks_unused_locks_low_water threshold is passed as well). More... | |
Start a wait on a condition.
C | the condition to wait on |
M | the associated mutex |
S | the new stage to enter |
O | the previous stage |
#define EXIT_COND | ( | S | ) | exit_cond(S, __func__, __FILE__, __LINE__) |
End a wait on a condition.
S | the new stage to enter |
Maximal length of key for metadata locking subsystem.
#define MDL_REQUEST_INIT | ( | R, | |
P1, | |||
P2, | |||
P3, | |||
P4, | |||
P5 | |||
) | (*R).init_with_source(P1, P2, P3, P4, P5, __FILE__, __LINE__) |
#define MDL_REQUEST_INIT_BY_KEY | ( | R, | |
P1, | |||
P2, | |||
P3 | |||
) | (*R).init_by_key_with_source(P1, P2, P3, __FILE__, __LINE__) |
#define MDL_REQUEST_INIT_BY_PART_KEY | ( | R, | |
P1, | |||
P2, | |||
P3, | |||
P4, | |||
P5, | |||
P6 | |||
) | (*R).init_by_part_key_with_source(P1, P2, P3, P4, P5, P6, __FILE__, __LINE__) |
typedef I_P_List<MDL_request, I_P_List_adapter<MDL_request, &MDL_request::next_in_list, &MDL_request::prev_in_list>, I_P_List_counter> MDL_request_list |
enum enum_mdl_duration |
Duration of metadata lock.
enum enum_mdl_type |
Type of metadata lock request.
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.
|
extern |
|
extern |
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.
const int32 MDL_LOCKS_UNUSED_LOCKS_LOW_WATER_DEFAULT = 1000 |
Default value for threshold for number of unused MDL_lock objects after exceeding which we start considering freeing them.
Only unit tests use different threshold value.
const double MDL_LOCKS_UNUSED_LOCKS_MIN_RATIO = 0.25 |
Ratio of unused/total MDL_lock objects after exceeding which we start trying to free unused MDL_lock objects (assuming that mdl_locks_unused_locks_low_water threshold is passed as well).
Note that this value should be high enough for our algorithm using random dives into hash to work well.