30#include <unordered_map>
69#define ENTER_COND(C, M, S, O) \
70 enter_cond(C, M, S, O, __func__, __FILE__, __LINE__)
77#define EXIT_COND(S) exit_cond(S, __func__, __FILE__, __LINE__)
107 const char *src_file,
int src_line) = 0;
119 const char *src_file,
int src_line) = 0;
160 bool needs_thr_lock_abort) = 0;
174 bool *victimized) = 0;
353#define MAX_MDLKEY_LENGTH (1 + NAME_LEN + 1 + NAME_LEN + 1)
366#ifdef HAVE_PSI_INTERFACE
521 const char *
name,
const char *column_name) {
538 size_t col_len = strlen(column_name);
597 if (remaining >= col_len + 1) {
638 const char *normalized_name,
size_t normalized_name_len,
689 size_t part_key_length,
size_t db_length) {
694 assert(strlen(part_key) == db_length);
695 assert(db_length + 1 + strlen(part_key + db_length + 1) + 1 ==
707 memcpy(
m_ptr + 1, part_key, part_key_length);
756 const char *name_arg) {
826 const std::nothrow_t &arg
827 [[maybe_unused]] = std::nothrow)
noexcept {
832 const std::nothrow_t &)
noexcept {}
835 const char *db_arg,
const char *name_arg,
838 const char *src_file,
uint src_line);
842 const char *src_file,
uint src_line);
844 const char *part_key_arg,
845 size_t part_key_length_arg,
846 size_t db_length_arg,
849 const char *src_file,
uint src_line);
852 assert(
ticket ==
nullptr);
904#define MDL_REQUEST_INIT(R, P1, P2, P3, P4, P5) \
905 (*R).init_with_source(P1, P2, P3, P4, P5, __FILE__, __LINE__)
907#define MDL_REQUEST_INIT_BY_KEY(R, P1, P2, P3) \
908 (*R).init_by_key_with_source(P1, P2, P3, __FILE__, __LINE__)
910#define MDL_REQUEST_INIT_BY_PART_KEY(R, P1, P2, P3, P4, P5, P6) \
911 (*R).init_by_part_key_with_source(P1, P2, P3, P4, P5, P6, __FILE__, __LINE__)
1206 template <
typename CLOS>
1209 for (
MDL_ticket *t = it++; t !=
nullptr; t = it++) {
1219 template <
typename CLOS>
1355 struct timespec *abs_timeout,
bool signal_timeout,
1455 const char *db,
const char *
name,
Element counting policy class for I_P_List which provides basic element counting.
Definition: sql_plist.h:221
Iterator for I_P_List.
Definition: sql_plist.h:167
I_P_List_iterator< MDL_ticket, Base > Iterator
Definition: sql_plist.h:156
An interface to separate the MDL module from the THD, and the rest of the server code.
Definition: mdl.h:84
virtual bool is_connected()=0
Does the owner still have connection to the client?
virtual void notify_shared_lock(MDL_context_owner *in_use, bool needs_thr_lock_abort)=0
virtual bool notify_hton_pre_acquire_exclusive(const MDL_key *mdl_key, bool *victimized)=0
Notify/get permission from interested storage engines before acquiring exclusive lock for the key.
virtual ~MDL_context_owner()=default
virtual void exit_cond(const PSI_stage_info *stage, const char *src_function, const char *src_file, int src_line)=0
End a wait on a condition.
virtual void notify_hton_post_release_exclusive(const MDL_key *mdl_key)=0
Notify interested storage engines that we have just released exclusive lock for the key.
virtual bool might_have_commit_order_waiters() const =0
Indicates that owner thread might have some commit order (non-MDL) waits for it which are still taken...
virtual int is_killed() const =0
Has the owner thread been killed?
virtual uint get_rand_seed() const =0
Get random seed specific to this THD to be used for initialization of PRNG for the MDL_context.
virtual void enter_cond(mysql_cond_t *cond, mysql_mutex_t *mutex, const PSI_stage_info *stage, PSI_stage_info *old_stage, const char *src_function, const char *src_file, int src_line)=0
Enter a condition wait.
virtual THD * get_thd()=0
Within MDL subsystem this one is only used for DEBUG_SYNC.
Abstract visitor class for inspecting MDL_context.
Definition: mdl.h:1393
virtual ~MDL_context_visitor()=default
virtual void visit_context(const MDL_context *ctx)=0
Context of the owner of metadata locks.
Definition: mdl.h:1410
Ticket_list::Iterator Ticket_iterator
Definition: mdl.h:1417
MDL_context_owner * get_owner() const
Definition: mdl.h:1487
bool acquire_locks(MDL_request_list *requests, Timeout_type lock_wait_timeout)
Acquire exclusive locks.
Definition: mdl.cc:3629
bool owns_equal_or_stronger_lock(const MDL_key *mdl_key, enum_mdl_type mdl_type)
Auxiliary function which allows to check if we have some kind of lock on a object.
Definition: mdl.cc:4366
bool clone_tickets(const MDL_context *ticket_owner, enum_mdl_duration duration)
Create copy of all granted tickets of particular duration from given context to current context.
Definition: mdl.cc:3683
MDL_savepoint mdl_savepoint()
Definition: mdl.h:1474
MDL_context()
Initialize a metadata locking context.
Definition: mdl.cc:1435
bool has_locks(enum_mdl_duration duration)
Definition: mdl.h:1469
bool acquire_lock(MDL_request *mdl_request, Timeout_type lock_wait_timeout)
Acquire one lock with waiting for conflicting locks to go away if needed.
Definition: mdl.cc:3358
uint get_deadlock_weight() const
Definition: mdl.h:1490
void set_explicit_duration_for_all_locks()
Set explicit duration for all locks in the context.
Definition: mdl.cc:4621
void set_force_dml_deadlock_weight(bool force_dml_deadlock_weight)
Definition: mdl.h:1520
void init(MDL_context_owner *arg)
Definition: mdl.h:1496
MDL_context_owner * m_owner
Definition: mdl.h:1610
void release_statement_locks()
Definition: mdl.cc:4500
void set_lock_duration(MDL_ticket *mdl_ticket, enum_mdl_duration duration)
Change lock duration for transactional lock.
Definition: mdl.cc:4597
void release_lock(MDL_ticket *ticket)
Release lock with explicit duration.
Definition: mdl.cc:4203
uint get_random()
Get pseudo random value in [0 .
Definition: mdl.h:1540
mysql_prlock_t m_LOCK_waiting_for
Read-write lock protecting m_waiting_for member.
Definition: mdl.h:1640
void release_locks(MDL_release_locks_visitor *visitor)
Release all explicit locks in the context for which the release() method of the provided visitor eval...
Definition: mdl.cc:4268
void release_all_locks_for_name(MDL_ticket *ticket)
Release all explicit locks in the context which correspond to the same name/object as this lock reque...
Definition: mdl.cc:4246
void set_needs_thr_lock_abort(bool needs_thr_lock_abort)
Definition: mdl.h:1498
bool clone_ticket(MDL_request *mdl_request)
Create a copy of a granted ticket.
Definition: mdl.cc:3171
void release_locks_stored_before(enum_mdl_duration duration, MDL_ticket *sentinel)
Release all locks associated with the context.
Definition: mdl.cc:4222
bool find_lock_owner(const MDL_key *mdl_key, MDL_context_visitor *visitor)
Find the first context which owns the lock and inspect it by calling MDL_context_visitor::visit_conte...
Definition: mdl.cc:4419
void rollback_to_savepoint(const MDL_savepoint &mdl_savepoint)
Releases metadata locks that were acquired after a specific savepoint.
Definition: mdl.cc:4477
uint m_rand_state
State for pseudo random numbers generator (PRNG) which output is used to perform random dives into MD...
Definition: mdl.h:1660
bool try_acquire_lock_impl(MDL_request *mdl_request, MDL_ticket **out_ticket)
Auxiliary method for acquiring lock without waiting.
Definition: mdl.cc:2807
MDL_context(const MDL_context &rhs)
void find_deadlock()
Try to find a deadlock.
Definition: mdl.cc:4034
bool m_force_dml_deadlock_weight
Indicates that we need to use DEADLOCK_WEIGHT_DML deadlock weight for this context and ignore the dea...
Definition: mdl.h:1631
void lock_deadlock_victim()
Definition: mdl.h:1703
I_P_List< MDL_ticket, I_P_List_adapter< MDL_ticket, &MDL_ticket::next_in_context, &MDL_ticket::prev_in_context > > Ticket_list
Definition: mdl.h:1415
LF_PINS * m_pins
Thread's pins (a.k.a.
Definition: mdl.h:1654
void materialize_fast_path_locks()
"Materialize" requests for locks which were satisfied using "fast path" by properly including them in...
Definition: mdl.cc:2758
bool try_acquire_lock(MDL_request *mdl_request)
Try to acquire one lock.
Definition: mdl.cc:2684
bool visit_subgraph(MDL_wait_for_graph_visitor *dvisitor)
A fragment of recursive traversal of the wait-for graph of MDL contexts in the server in search for d...
Definition: mdl.cc:4014
bool has_locks_waited_for() const
Do we hold any locks which are possibly being waited for by another MDL_context?
Definition: mdl.cc:4567
bool m_needs_thr_lock_abort
true - if for this context we will break protocol and try to acquire table-level locks while having o...
Definition: mdl.h:1620
bool upgrade_shared_lock(MDL_ticket *mdl_ticket, enum_mdl_type new_type, Timeout_type lock_wait_timeout)
Upgrade a shared metadata lock.
Definition: mdl.cc:3736
MDL_wait_for_subgraph * m_waiting_for
Tell the deadlock detector what metadata lock or table definition cache entry this session is waiting...
Definition: mdl.h:1648
void set_transaction_duration_for_all_locks()
Set transactional duration for all locks in the context.
Definition: mdl.cc:4629
MDL_ticket * find_ticket(MDL_request *mdl_req, enum_mdl_duration *duration)
Check whether the context already holds a compatible lock ticket on an object.
Definition: mdl.cc:2654
void done_waiting_for()
Remove the wait-for edge from the graph after we're done waiting.
Definition: mdl.h:1698
THD * get_thd() const
Within MDL subsystem this one is only used for DEBUG_SYNC.
Definition: mdl.h:1559
bool get_needs_thr_lock_abort() const
Definition: mdl.h:1518
bool has_lock(const MDL_savepoint &mdl_savepoint, MDL_ticket *mdl_ticket)
Does this savepoint have this lock?
Definition: mdl.cc:4515
bool has_locks() const
Definition: mdl.h:1462
MDL_ticket_store m_ticket_store
Lists of all MDL tickets acquired by this connection.
Definition: mdl.h:1608
MDL_wait m_wait
If our request for a lock is scheduled, or aborted by the deadlock detector, the result is recorded i...
Definition: mdl.h:1566
void destroy()
Destroy metadata locking context.
Definition: mdl.cc:1457
bool fix_pins()
Allocate pins which are necessary to work with MDL_map container if they are not allocated already.
Definition: mdl.cc:1471
void unlock_deadlock_victim()
Definition: mdl.h:1704
MDL_context & operator=(MDL_context &rhs)
void release_transactional_locks()
Release locks acquired by normal statements (SELECT, UPDATE, DELETE, etc) in the course of a transact...
Definition: mdl.cc:4494
void will_wait_for(MDL_wait_for_subgraph *waiting_for_arg)
Inform the deadlock detector there is an edge in the wait-for graph.
Definition: mdl.h:1679
Inspect if MDL_context is owned by any thread.
Definition: mdl.h:1748
MDL_lock_is_owned_visitor()
Definition: mdl.h:1750
bool m_exists
Definition: mdl.h:1775
bool exists() const
Returns if an owner for the MDL lock being inspected exists.
Definition: mdl.h:1771
void visit_context(const MDL_context *ctx) override
Collects relevant information about the MDL lock owner.
Definition: mdl.h:1761
The lock context.
Definition: mdl.cc:426
Base class to find out if the lock represented by a given ticket should be released.
Definition: mdl.h:1378
virtual bool release(MDL_ticket *ticket)=0
Check if the given ticket represents a lock that should be released.
virtual ~MDL_release_locks_visitor()=default
A pending metadata lock request.
Definition: mdl.h:800
bool is_ddl_or_lock_tables_lock_request() const
Is this a request for a strong, DDL/LOCK TABLES-type, of lock?
Definition: mdl.h:868
bool is_write_lock_request() const
Is this a request for a lock which allow data to be updated?
Definition: mdl.h:863
MDL_request(MDL_request &&)=default
enum_mdl_type type
Type of metadata lock.
Definition: mdl.h:803
void init_by_key_with_source(const MDL_key *key_arg, enum_mdl_type mdl_type_arg, enum_mdl_duration mdl_duration_arg, const char *src_file, uint src_line)
Initialize a lock request using pre-built MDL_key.
Definition: mdl.cc:1537
void init_by_part_key_with_source(MDL_key::enum_mdl_namespace namespace_arg, const char *part_key_arg, size_t part_key_length_arg, size_t db_length_arg, enum_mdl_type mdl_type_arg, enum_mdl_duration mdl_duration_arg, const char *src_file, uint src_line)
Initialize a lock request using partial MDL key.
Definition: mdl.cc:1566
void set_type(enum_mdl_type type_arg)
Set type of lock request.
Definition: mdl.h:851
MDL_request & operator=(MDL_request &&)=default
MDL_ticket * ticket
Pointer to the lock ticket object for this lock request.
Definition: mdl.h:816
MDL_request ** prev_in_list
Definition: mdl.h:811
const char * m_src_file
Definition: mdl.h:821
void init_with_source(MDL_key::enum_mdl_namespace namespace_arg, const char *db_arg, const char *name_arg, enum_mdl_type mdl_type_arg, enum_mdl_duration mdl_duration_arg, const char *src_file, uint src_line)
Initialize a lock request.
Definition: mdl.cc:1503
MDL_key key
A lock is requested based on a fully qualified name and type.
Definition: mdl.h:819
enum_mdl_duration duration
Duration for requested lock.
Definition: mdl.h:805
MDL_request()=default
This constructor exists for two reasons:
MDL_request * next_in_list
Pointers for participating in the list of lock requests for this context.
Definition: mdl.h:810
uint m_src_line
Definition: mdl.h:822
MDL_request(const MDL_request &rhs)
Definition: mdl.h:896
Savepoint for MDL context.
Definition: mdl.h:1315
MDL_ticket * m_trans_ticket
Pointer to last lock with transaction duration which was taken before creation of savepoint.
Definition: mdl.h:1335
MDL_ticket * m_stmt_ticket
Pointer to last lock with statement duration which was taken before creation of savepoint.
Definition: mdl.h:1330
MDL_savepoint(MDL_ticket *stmt_ticket, MDL_ticket *trans_ticket)
Definition: mdl.h:1320
Keep track of MDL_ticket for different durations.
Definition: mdl.h:1114
void for_each_ticket_in_ticket_lists(CLOS &&clos)
Calls the closure provided as argument for each of the MDL_tickets in the store.
Definition: mdl.h:1220
List_iterator list_iterator(int di) const
Return a P-list iterator to the given duration.
Definition: mdl.h:1269
std::unique_ptr< Ticket_map > m_map
Definition: mdl.h:1181
MDL_ticket_handle find(const MDL_request &req) const
Look up a ticket based on its MDL_key.
Definition: mdl.cc:4881
size_t m_count
Definition: mdl.h:1179
void set_materialized()
Mark boundary for tickets with fast_path=false, so that later calls to materialize_fast_path_locks() ...
Definition: mdl.cc:4895
const size_t INITIAL_BUCKET_COUNT
Initial number of buckets in the hash index.
Definition: mdl.h:1178
MDL_ticket_handle find_in_hash(const MDL_request &req) const
Definition: mdl.cc:4654
void remove(enum_mdl_duration dur, MDL_ticket *ticket)
Remove a ticket from a duration list.
Definition: mdl.cc:4735
void move_all_to_explicit_duration()
Move all tickets to the explicit duration list.
Definition: mdl.cc:4771
void move_explicit_to_transaction_duration()
Move all tickets to the transaction duration list.
Definition: mdl.cc:4830
MDL_ticket * materialized_front(int di)
Return the first ticket for which materialize_fast_path_locks already has been called for the given d...
Definition: mdl.cc:4901
const size_t THRESHOLD
If the number of tickets in the ticket store (in all durations) is equal to, or exceeds this constant...
Definition: mdl.h:1172
MDL_ticket_store()
Constructs store.
Definition: mdl.h:1195
void push_front(enum_mdl_duration dur, MDL_ticket *ticket)
Push a ticket onto the list for a given duration.
Definition: mdl.cc:4692
Duration m_durations[MDL_DURATION_END]
Definition: mdl.h:1150
MDL_ticket * front(int di)
Return the first MDL_ticket for the given duration.
Definition: mdl.cc:4688
MDL_ticket_handle find_in_lists(const MDL_request &req) const
Definition: mdl.cc:4637
void for_each_ticket_in_duration_list(enum_mdl_duration dur, CLOS &&clos)
Calls the closure provided as argument for each of the MDL_tickets in the given duration.
Definition: mdl.h:1207
bool is_empty() const
Predicate for the emptiness of the store.
Definition: mdl.cc:4676
std::unordered_multimap< const MDL_key *, MDL_ticket_handle, Hash, Key_equal > Ticket_map
Definition: mdl.h:1163
A granted metadata lock.
Definition: mdl.h:983
enum enum_mdl_type m_type
Type of metadata lock.
Definition: mdl.h:1069
bool m_is_fast_path
Indicates that ticket corresponds to lock acquired using "fast path" algorithm.
Definition: mdl.h:1093
MDL_ticket(const MDL_ticket &)
bool has_stronger_or_equal_type(enum_mdl_type type) const
Check if ticket represents metadata lock of "stronger" or equal type than specified one.
Definition: mdl.cc:2596
bool has_pending_conflicting_lock() const
Check if we have any pending locks which conflict with existing shared lock.
Definition: mdl.cc:4460
MDL_context * get_ctx() const
Definition: mdl.h:1002
void downgrade_lock(enum_mdl_type type)
Downgrade an EXCLUSIVE or SHARED_NO_WRITE lock to shared metadata lock.
Definition: mdl.cc:4286
~MDL_ticket() override
Definition: mdl.h:1057
MDL_ticket(MDL_context *ctx_arg, enum_mdl_type type_arg, enum_mdl_duration duration_arg)
Definition: mdl.h:1040
MDL_ticket & operator=(const MDL_ticket &)
static void destroy(MDL_ticket *ticket)
Definition: mdl.cc:1680
bool accept_visitor(MDL_wait_for_graph_visitor *dvisitor) override
Implement MDL_wait_for_subgraph interface.
Definition: mdl.cc:3994
bool is_incompatible_when_waiting(enum_mdl_type type) const
Definition: mdl.cc:2607
MDL_ticket * next_in_context
Pointers for participating in the list of lock requests for this context.
Definition: mdl.h:989
bool is_incompatible_when_granted(enum_mdl_type type) const
Definition: mdl.cc:2603
PSI_metadata_lock * m_psi
Definition: mdl.h:1102
MDL_ticket ** prev_in_lock
Definition: mdl.h:997
MDL_ticket ** prev_in_context
Definition: mdl.h:990
uint get_deadlock_weight() const override
Return the 'weight' of this ticket for the victim selection algorithm.
Definition: mdl.cc:1697
enum_mdl_duration get_duration() const
Definition: mdl.h:1022
bool is_upgradable_or_exclusive() const
Definition: mdl.h:1003
bool m_hton_notified
Indicates that ticket corresponds to lock request which required storage engine notification during i...
Definition: mdl.h:1100
enum_mdl_duration m_duration
Duration of lock represented by this ticket.
Definition: mdl.h:1075
enum_psi_status
Status of lock request represented by the ticket as reflected in P_S.
Definition: mdl.h:1030
@ GRANTED
Definition: mdl.h:1032
@ POST_RELEASE_NOTIFY
Definition: mdl.h:1034
@ PRE_ACQUIRE_NOTIFY
Definition: mdl.h:1033
@ PENDING
Definition: mdl.h:1031
MDL_lock * m_lock
Pointer to the lock object for this lock ticket.
Definition: mdl.h:1085
void set_duration(enum_mdl_duration dur)
Definition: mdl.h:1023
enum_mdl_type get_type() const
Definition: mdl.h:1007
MDL_ticket * next_in_lock
Pointers for participating in the list of satisfied/pending requests for the lock.
Definition: mdl.h:996
const MDL_key * get_key() const
Return a key identifying this lock.
Definition: mdl.cc:4466
MDL_context * m_ctx
Context of the owner of the metadata lock ticket.
Definition: mdl.h:1080
MDL_lock * get_lock() const
Definition: mdl.h:1008
static MDL_ticket * create(MDL_context *ctx_arg, enum_mdl_type type_arg, enum_mdl_duration duration_arg)
Auxiliary functions needed for creation/destruction of MDL_ticket objects.
Definition: mdl.cc:1666
An abstract class for inspection of a connected subgraph of the wait-for graph.
Definition: mdl.h:918
MDL_wait_for_graph_visitor()
Definition: mdl.h:925
virtual bool enter_node(MDL_context *node)=0
virtual bool inspect_edge(MDL_context *dest)=0
virtual ~MDL_wait_for_graph_visitor()
uint m_lock_open_count
XXX, hack: During deadlock search, we may need to inspect TABLE_SHAREs and acquire LOCK_open.
Definition: mdl.h:936
virtual void leave_node(MDL_context *node)=0
Abstract class representing an edge in the waiters graph to be traversed by deadlock detection algori...
Definition: mdl.h:944
static const uint DEADLOCK_WEIGHT_CO
Definition: mdl.h:954
static const uint DEADLOCK_WEIGHT_ULL
Definition: mdl.h:956
static const uint DEADLOCK_WEIGHT_DML
Definition: mdl.h:955
virtual ~MDL_wait_for_subgraph()
static const uint DEADLOCK_WEIGHT_DDL
Definition: mdl.h:957
virtual bool accept_visitor(MDL_wait_for_graph_visitor *gvisitor)=0
Accept a wait-for graph visitor to inspect the node this edge is leading to.
virtual uint get_deadlock_weight() const =0
A reliable way to wait on an MDL lock.
Definition: mdl.h:1342
enum_wait_status m_wait_status
Definition: mdl.h:1368
bool set_status(enum_wait_status result_arg)
Set the status unless it's already set.
Definition: mdl.cc:1762
enum_wait_status
Definition: mdl.h:1349
@ KILLED
Definition: mdl.h:1349
@ WS_EMPTY
Definition: mdl.h:1349
@ TIMEOUT
Definition: mdl.h:1349
@ GRANTED
Definition: mdl.h:1349
@ VICTIM
Definition: mdl.h:1349
MDL_wait()
Construct an empty wait slot.
Definition: mdl.cc:1745
void reset_status()
Clear the current value of the wait slot.
Definition: mdl.cc:1786
mysql_cond_t m_COND_wait_status
Definition: mdl.h:1367
~MDL_wait()
Destroy system resources.
Definition: mdl.cc:1752
enum_wait_status timed_wait(MDL_context_owner *owner, struct timespec *abs_timeout, bool signal_timeout, const PSI_stage_info *wait_state_name)
Wait for the status to be assigned to this wait slot.
Definition: mdl.cc:1806
enum_wait_status get_status()
Query the current value of the wait slot.
Definition: mdl.cc:1776
mysql_mutex_t m_LOCK_wait_status
Condvar which is used for waiting until this context's pending request can be satisfied or this threa...
Definition: mdl.h:1366
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
static MEM_ROOT mem_root
Definition: client_plugin.cc:109
#define mysql_prlock_wrlock(T)
Definition: mysql_rwlock.h:75
#define mysql_prlock_rdlock(T)
Definition: mysql_rwlock.h:65
#define mysql_prlock_unlock(T)
Definition: mysql_rwlock.h:95
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
mysql_mutex_t LOCK_open
LOCK_open protects the following variables/objects:
Definition: sql_base.cc:265
struct PSI_metadata_lock PSI_metadata_lock
Definition: psi_mdl_bits.h:51
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:176
char * strmake(char *dst, const char *src, size_t length)
Definition: strmake.cc:42
void mdl_init()
Initialize the metadata locking subsystem.
Definition: mdl.cc:1071
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
Definition: mdl.h:1403
#define MAX_MDLKEY_LENGTH
Maximal length of key for metadata locking subsystem.
Definition: mdl.h:353
int32 mdl_locks_unused_locks_low_water
Threshold for number of unused MDL_lock objects.
Definition: mdl.cc:282
const int32 MDL_LOCKS_UNUSED_LOCKS_LOW_WATER_DEFAULT
Default value for threshold for number of unused MDL_lock objects after exceeding which we start cons...
Definition: mdl.h:1732
int32 mdl_get_unused_locks_count()
Get number of unused MDL_lock objects in MDL_map cache.
Definition: mdl.cc:1101
enum_mdl_duration
Duration of metadata lock.
Definition: mdl.h:332
@ MDL_TRANSACTION
Locks with transaction duration are automatically released at the end of transaction.
Definition: mdl.h:342
@ MDL_STATEMENT
Locks with statement duration are automatically released at the end of statement or transaction.
Definition: mdl.h:337
@ MDL_EXPLICIT
Locks with explicit duration survive the end of statement and transaction.
Definition: mdl.h:347
@ MDL_DURATION_END
Definition: mdl.h:349
@ MDL_SHARED_WRITE
Definition: mdl.h:268
@ MDL_SHARED
Definition: mdl.h:230
@ MDL_SHARED_UPGRADABLE
Definition: mdl.h:285
@ MDL_SHARED_READ_ONLY
Definition: mdl.h:291
@ MDL_SHARED_HIGH_PRIO
Definition: mdl.h:247
@ MDL_SHARED_NO_WRITE
Definition: mdl.h:305
@ MDL_SHARED_NO_READ_WRITE
Definition: mdl.h:317
@ MDL_SHARED_WRITE_LOW_PRIO
Definition: mdl.h:274
@ MDL_SHARED_READ
Definition: mdl.h:258
@ MDL_TYPE_END
Definition: mdl.h:327
@ MDL_EXCLUSIVE
Definition: mdl.h:325
@ MDL_INTENTION_EXCLUSIVE
Definition: mdl.h:207
const double MDL_LOCKS_UNUSED_LOCKS_MIN_RATIO
Ratio of unused/total MDL_lock objects after exceeding which we start trying to free unused MDL_lock ...
Definition: mdl.h:1741
void mdl_destroy()
Release resources of metadata locking subsystem.
Definition: mdl.cc:1089
ulong max_write_lock_count
Definition: thr_lock.cc:122
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
Header for compiler-dependent features.
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:51
#define INT_MAX32
Definition: my_inttypes.h:77
int32_t int32
Definition: my_inttypes.h:65
uint16_t uint16
Definition: my_inttypes.h:64
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
Common header for many mysys elements.
Defines for getting and processing the current system type programmatically.
std::uint64_t Timeout_type
Type alias to reduce chance of conversion errors on timeout values.
Definition: my_systime.h:124
Common definition between mysql server & client.
#define NAME_LEN
Definition: mysql_com.h:66
#define NAME_CHAR_LEN
Field/table name length.
Definition: mysql_com.h:59
Instrumentation helpers for conditions.
ABI for instrumented mutexes.
Instrumentation helpers for rwlock.
MDL_request * mdl_request(const Import_target &t, MEM_ROOT *mem_root)
Creates an MDL_request for exclusive MDL on the table being imported.
Definition: sdi_api.cc:244
MDL_request * mdl_req(THD *thd, const Tablespace_table_ref &tref, enum enum_mdl_type mdl_type)
Create am MDL_request for a the table identified by a Tablespace_table_ref.
Definition: tablespace_impl.cc:533
bool test_drive_fix_pins(MDL_context *)
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
Instrumentation helpers for rwlock.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
required string type
Definition: replication_group_member_actions.proto:33
enum_mdl_type
Type of metadata lock request.
Definition: sql_lexer_yacc_state.h:105
case opt name
Definition: sslopt-case.h:32
Hook class which via its methods specifies which members of T should be used for participating in a i...
Definition: sql_plist.h:197
Metadata lock object key.
Definition: mdl.h:364
uint16 m_db_name_length
Definition: mdl.h:784
int cmp(const MDL_key *rhs) const
Compare two MDL keys lexicographically.
Definition: mdl.h:734
const char * db_name() const
Definition: mdl.h:425
static void init_psi_keys()
Definition: mdl.cc:135
uint db_name_length() const
Definition: mdl.h:426
MDL_key(const MDL_key &rhs)
Definition: mdl.h:748
uint name_length() const
Definition: mdl.h:432
bool is_equal(const MDL_key *rhs) const
Definition: mdl.h:727
const char * name() const
Definition: mdl.h:428
void mdl_key_init(enum_mdl_namespace mdl_namespace, const char *db, const char *name)
Construct a metadata lock key from a triplet (mdl_namespace, database and name).
Definition: mdl.h:473
enum_mdl_namespace
Object namespaces.
Definition: mdl.h:399
@ BACKUP_LOCK
Definition: mdl.h:401
@ EVENT
Definition: mdl.h:408
@ GLOBAL
Definition: mdl.h:400
@ LOCKING_SERVICE
Definition: mdl.h:411
@ USER_LEVEL_LOCK
Definition: mdl.h:410
@ COLUMN_STATISTICS
Definition: mdl.h:414
@ COMMIT
Definition: mdl.h:409
@ RESOURCE_GROUPS
Definition: mdl.h:415
@ SCHEMA
Definition: mdl.h:403
@ NAMESPACE_END
Definition: mdl.h:419
@ FUNCTION
Definition: mdl.h:405
@ TRIGGER
Definition: mdl.h:407
@ ACL_CACHE
Definition: mdl.h:413
@ FOREIGN_KEY
Definition: mdl.h:416
@ SRID
Definition: mdl.h:412
@ PROCEDURE
Definition: mdl.h:406
@ TABLESPACE
Definition: mdl.h:402
@ TABLE
Definition: mdl.h:404
@ CHECK_CONSTRAINT
Definition: mdl.h:417
enum_mdl_namespace mdl_namespace() const
Definition: mdl.h:458
void mdl_key_init(const MDL_key *rhs)
Definition: mdl.h:712
void mdl_key_init(enum_mdl_namespace mdl_namespace, const char *db, const char *normalized_name, size_t normalized_name_len, const char *name)
Construct a metadata lock key from a quadruplet (mdl_namespace, database, normalized object name buff...
Definition: mdl.h:637
uint16 m_length
Definition: mdl.h:783
uint length() const
Definition: mdl.h:423
char m_ptr[MAX_MDLKEY_LENGTH]
Definition: mdl.h:786
const uchar * ptr() const
Definition: mdl.h:422
const char * col_name() const
Definition: mdl.h:434
MDL_key & operator=(const MDL_key &rhs)
Definition: mdl.h:750
uint col_name_length() const
Definition: mdl.h:446
void mdl_key_init(enum_mdl_namespace mdl_namespace, const char *part_key, size_t part_key_length, size_t db_length)
Construct a metadata lock key from namespace and partial key, which contains info about object databa...
Definition: mdl.h:688
void reset()
Definition: mdl.h:721
MDL_key(enum_mdl_namespace namespace_arg, const char *db_arg, const char *name_arg)
Definition: mdl.h:755
uint16 m_object_name_length
Definition: mdl.h:785
void mdl_key_init(enum_mdl_namespace mdl_namespace, const char *db, const char *name, const char *column_name)
Construct a metadata lock key from a quadruplet (mdl_namespace, database, table and column name).
Definition: mdl.h:520
bool use_normalized_object_name() const
Check if normalized object name should be used.
Definition: mdl.h:776
const PSI_stage_info * get_wait_state_name() const
Get thread state name to be used in case when we have to wait on resource identified by key.
Definition: mdl.h:765
static PSI_stage_info m_namespace_to_wait_state_name[NAMESPACE_END]
Thread state names to be used in case when we have to wait on resource belonging to certain namespace...
Definition: mdl.h:787
MDL_ticket * m_mat_front
m_mat_front tracks what was the front of m_ticket_list, the last time MDL_context::materialize_fast_p...
Definition: mdl.h:1147
Ticket_p_list m_ticket_list
Definition: mdl.h:1135
size_t operator()(const MDL_key *k) const
Definition: mdl.cc:4633
bool operator()(const MDL_key *a, const MDL_key *b) const
Definition: mdl.h:1157
Utility struct for representing a ticket pointer and its duration.
Definition: mdl.h:1119
enum_mdl_duration m_dur
Definition: mdl.h:1120
MDL_ticket_handle(MDL_ticket *t, enum_mdl_duration d)
Definition: mdl.h:1124
MDL_ticket_handle()=default
MDL_ticket * m_ticket
Definition: mdl.h:1121
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
void * Alloc(size_t length)
Allocate memory.
Definition: my_alloc.h:144
Stage instrument information.
Definition: psi_stage_bits.h:73
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
An instrumented prlock structure.
Definition: mysql_rwlock_bits.h:71
unsigned int uint
Definition: uca-dump.cc:29