31#include <unordered_map>
70#define ENTER_COND(C, M, S, O) \
71 enter_cond(C, M, S, O, __func__, __FILE__, __LINE__)
78#define EXIT_COND(S) exit_cond(S, __func__, __FILE__, __LINE__)
108 const char *src_file,
int src_line) = 0;
120 const char *src_file,
int src_line) = 0;
161 bool needs_thr_lock_abort) = 0;
175 bool *victimized) = 0;
354#define MAX_MDLKEY_LENGTH (1 + NAME_LEN + 1 + NAME_LEN + 1)
367#ifdef HAVE_PSI_INTERFACE
522 const char *
name,
const char *column_name) {
539 const size_t col_len = strlen(column_name);
542 const size_t remaining =
598 if (remaining >= col_len + 1) {
639 const char *normalized_name,
size_t normalized_name_len,
690 size_t part_key_length,
size_t db_length) {
695 assert(strlen(part_key) == db_length);
696 assert(db_length + 1 + strlen(part_key + db_length + 1) + 1 ==
708 memcpy(
m_ptr + 1, part_key, part_key_length);
714 const uint16 copy_length =
758 const char *name_arg) {
828 const std::nothrow_t &arg
829 [[maybe_unused]] = std::nothrow)
noexcept {
834 const std::nothrow_t &)
noexcept {}
837 const char *db_arg,
const char *name_arg,
840 const char *src_file, uint src_line);
844 const char *src_file, uint src_line);
846 const char *part_key_arg,
847 size_t part_key_length_arg,
848 size_t db_length_arg,
851 const char *src_file, uint src_line);
854 assert(
ticket ==
nullptr);
906#define MDL_REQUEST_INIT(R, P1, P2, P3, P4, P5) \
907 (*R).init_with_source(P1, P2, P3, P4, P5, __FILE__, __LINE__)
909#define MDL_REQUEST_INIT_BY_KEY(R, P1, P2, P3) \
910 (*R).init_by_key_with_source(P1, P2, P3, __FILE__, __LINE__)
912#define MDL_REQUEST_INIT_BY_PART_KEY(R, P1, P2, P3, P4, P5, P6) \
913 (*R).init_by_part_key_with_source(P1, P2, P3, P4, P5, P6, __FILE__, __LINE__)
1208 template <
typename CLOS>
1211 for (
MDL_ticket *t = it++; t !=
nullptr; t = it++) {
1221 template <
typename CLOS>
1357 struct timespec *abs_timeout,
bool signal_timeout,
1457 const char *db,
const char *
name,
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Element counting policy class for I_P_List which provides basic element counting.
Definition: sql_plist.h:222
Iterator for I_P_List.
Definition: sql_plist.h:168
I_P_List_iterator< MDL_ticket, Base > Iterator
Definition: sql_plist.h:157
An interface to separate the MDL module from the THD, and the rest of the server code.
Definition: mdl.h:85
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 bool is_connected(bool=false)=0
Does the owner still have connection to the client?
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:1395
virtual ~MDL_context_visitor()=default
virtual void visit_context(const MDL_context *ctx)=0
Context of the owner of metadata locks.
Definition: mdl.h:1412
Ticket_list::Iterator Ticket_iterator
Definition: mdl.h:1419
MDL_context_owner * get_owner() const
Definition: mdl.h:1489
bool acquire_locks(MDL_request_list *requests, Timeout_type lock_wait_timeout)
Acquire exclusive locks.
Definition: mdl.cc:3640
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:4377
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:3694
MDL_savepoint mdl_savepoint()
Definition: mdl.h:1476
MDL_context()
Initialize a metadata locking context.
Definition: mdl.cc:1436
bool has_locks(enum_mdl_duration duration)
Definition: mdl.h:1471
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:3361
uint get_deadlock_weight() const
Definition: mdl.h:1492
void set_explicit_duration_for_all_locks()
Set explicit duration for all locks in the context.
Definition: mdl.cc:4632
void set_force_dml_deadlock_weight(bool force_dml_deadlock_weight)
Definition: mdl.h:1522
void init(MDL_context_owner *arg)
Definition: mdl.h:1498
MDL_context_owner * m_owner
Definition: mdl.h:1612
void release_statement_locks()
Definition: mdl.cc:4511
void set_lock_duration(MDL_ticket *mdl_ticket, enum_mdl_duration duration)
Change lock duration for transactional lock.
Definition: mdl.cc:4608
void release_lock(MDL_ticket *ticket)
Release lock with explicit duration.
Definition: mdl.cc:4214
uint get_random()
Get pseudo random value in [0 .
Definition: mdl.h:1542
mysql_prlock_t m_LOCK_waiting_for
Read-write lock protecting m_waiting_for member.
Definition: mdl.h:1642
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:4279
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:4257
void set_needs_thr_lock_abort(bool needs_thr_lock_abort)
Definition: mdl.h:1500
bool clone_ticket(MDL_request *mdl_request)
Create a copy of a granted ticket.
Definition: mdl.cc:3174
void release_locks_stored_before(enum_mdl_duration duration, MDL_ticket *sentinel)
Release all locks associated with the context.
Definition: mdl.cc:4233
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:4430
void rollback_to_savepoint(const MDL_savepoint &mdl_savepoint)
Releases metadata locks that were acquired after a specific savepoint.
Definition: mdl.cc:4488
uint m_rand_state
State for pseudo random numbers generator (PRNG) which output is used to perform random dives into MD...
Definition: mdl.h:1662
bool try_acquire_lock_impl(MDL_request *mdl_request, MDL_ticket **out_ticket)
Auxiliary method for acquiring lock without waiting.
Definition: mdl.cc:2810
MDL_context(const MDL_context &rhs)
void find_deadlock()
Try to find a deadlock.
Definition: mdl.cc:4045
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:1633
void lock_deadlock_victim()
Definition: mdl.h:1705
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:1417
LF_PINS * m_pins
Thread's pins (a.k.a.
Definition: mdl.h:1656
void materialize_fast_path_locks()
"Materialize" requests for locks which were satisfied using "fast path" by properly including them in...
Definition: mdl.cc:2761
bool try_acquire_lock(MDL_request *mdl_request)
Try to acquire one lock.
Definition: mdl.cc:2687
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:4025
bool has_locks_waited_for() const
Do we hold any locks which are possibly being waited for by another MDL_context?
Definition: mdl.cc:4578
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:1622
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:3747
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:1650
void set_transaction_duration_for_all_locks()
Set transactional duration for all locks in the context.
Definition: mdl.cc:4640
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:2657
void done_waiting_for()
Remove the wait-for edge from the graph after we're done waiting.
Definition: mdl.h:1700
THD * get_thd() const
Within MDL subsystem this one is only used for DEBUG_SYNC.
Definition: mdl.h:1561
bool get_needs_thr_lock_abort() const
Definition: mdl.h:1520
bool has_lock(const MDL_savepoint &mdl_savepoint, MDL_ticket *mdl_ticket)
Does this savepoint have this lock?
Definition: mdl.cc:4526
bool has_locks() const
Definition: mdl.h:1464
MDL_ticket_store m_ticket_store
Lists of all MDL tickets acquired by this connection.
Definition: mdl.h:1610
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:1568
void destroy()
Destroy metadata locking context.
Definition: mdl.cc:1458
bool fix_pins()
Allocate pins which are necessary to work with MDL_map container if they are not allocated already.
Definition: mdl.cc:1472
void unlock_deadlock_victim()
Definition: mdl.h:1706
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:4505
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:1681
The lock context.
Definition: mdl.cc:427
Base class to find out if the lock represented by a given ticket should be released.
Definition: mdl.h:1380
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:802
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:870
bool is_write_lock_request() const
Is this a request for a lock which allow data to be updated?
Definition: mdl.h:865
MDL_request(MDL_request &&)=default
enum_mdl_type type
Type of metadata lock.
Definition: mdl.h:805
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:1538
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:1567
void set_type(enum_mdl_type type_arg)
Set type of lock request.
Definition: mdl.h:853
MDL_request & operator=(MDL_request &&)=default
MDL_ticket * ticket
Pointer to the lock ticket object for this lock request.
Definition: mdl.h:818
MDL_request ** prev_in_list
Definition: mdl.h:813
const char * m_src_file
Definition: mdl.h:823
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:1504
MDL_key key
A lock is requested based on a fully qualified name and type.
Definition: mdl.h:821
enum_mdl_duration duration
Duration for requested lock.
Definition: mdl.h:807
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:812
uint m_src_line
Definition: mdl.h:824
MDL_request(const MDL_request &rhs)
Definition: mdl.h:898
Savepoint for MDL context.
Definition: mdl.h:1317
MDL_ticket * m_trans_ticket
Pointer to last lock with transaction duration which was taken before creation of savepoint.
Definition: mdl.h:1337
MDL_ticket * m_stmt_ticket
Pointer to last lock with statement duration which was taken before creation of savepoint.
Definition: mdl.h:1332
MDL_savepoint(MDL_ticket *stmt_ticket, MDL_ticket *trans_ticket)
Definition: mdl.h:1322
Keep track of MDL_ticket for different durations.
Definition: mdl.h:1116
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:1222
List_iterator list_iterator(int di) const
Return a P-list iterator to the given duration.
Definition: mdl.h:1271
std::unique_ptr< Ticket_map > m_map
Definition: mdl.h:1183
MDL_ticket_handle find(const MDL_request &req) const
Look up a ticket based on its MDL_key.
Definition: mdl.cc:4892
size_t m_count
Definition: mdl.h:1181
void set_materialized()
Mark boundary for tickets with fast_path=false, so that later calls to materialize_fast_path_locks() ...
Definition: mdl.cc:4906
const size_t INITIAL_BUCKET_COUNT
Initial number of buckets in the hash index.
Definition: mdl.h:1180
MDL_ticket_handle find_in_hash(const MDL_request &req) const
Definition: mdl.cc:4665
void remove(enum_mdl_duration dur, MDL_ticket *ticket)
Remove a ticket from a duration list.
Definition: mdl.cc:4746
void move_all_to_explicit_duration()
Move all tickets to the explicit duration list.
Definition: mdl.cc:4782
void move_explicit_to_transaction_duration()
Move all tickets to the transaction duration list.
Definition: mdl.cc:4841
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:4912
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:1174
MDL_ticket_store()
Constructs store.
Definition: mdl.h:1197
void push_front(enum_mdl_duration dur, MDL_ticket *ticket)
Push a ticket onto the list for a given duration.
Definition: mdl.cc:4703
Duration m_durations[MDL_DURATION_END]
Definition: mdl.h:1152
MDL_ticket * front(int di)
Return the first MDL_ticket for the given duration.
Definition: mdl.cc:4699
MDL_ticket_handle find_in_lists(const MDL_request &req) const
Definition: mdl.cc:4648
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:1209
bool is_empty() const
Predicate for the emptiness of the store.
Definition: mdl.cc:4687
std::unordered_multimap< const MDL_key *, MDL_ticket_handle, Hash, Key_equal > Ticket_map
Definition: mdl.h:1165
A granted metadata lock.
Definition: mdl.h:985
enum enum_mdl_type m_type
Type of metadata lock.
Definition: mdl.h:1071
bool m_is_fast_path
Indicates that ticket corresponds to lock acquired using "fast path" algorithm.
Definition: mdl.h:1095
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:2599
bool has_pending_conflicting_lock() const
Check if we have any pending locks which conflict with existing shared lock.
Definition: mdl.cc:4471
MDL_context * get_ctx() const
Definition: mdl.h:1004
void downgrade_lock(enum_mdl_type type)
Downgrade an EXCLUSIVE or SHARED_NO_WRITE lock to shared metadata lock.
Definition: mdl.cc:4297
~MDL_ticket() override
Definition: mdl.h:1059
MDL_ticket(MDL_context *ctx_arg, enum_mdl_type type_arg, enum_mdl_duration duration_arg)
Definition: mdl.h:1042
MDL_ticket & operator=(const MDL_ticket &)
static void destroy(MDL_ticket *ticket)
Definition: mdl.cc:1681
bool accept_visitor(MDL_wait_for_graph_visitor *dvisitor) override
Implement MDL_wait_for_subgraph interface.
Definition: mdl.cc:4005
bool is_incompatible_when_waiting(enum_mdl_type type) const
Definition: mdl.cc:2610
MDL_ticket * next_in_context
Pointers for participating in the list of lock requests for this context.
Definition: mdl.h:991
bool is_incompatible_when_granted(enum_mdl_type type) const
Definition: mdl.cc:2606
PSI_metadata_lock * m_psi
Definition: mdl.h:1104
MDL_ticket ** prev_in_lock
Definition: mdl.h:999
MDL_ticket ** prev_in_context
Definition: mdl.h:992
uint get_deadlock_weight() const override
Return the 'weight' of this ticket for the victim selection algorithm.
Definition: mdl.cc:1698
enum_mdl_duration get_duration() const
Definition: mdl.h:1024
bool is_upgradable_or_exclusive() const
Definition: mdl.h:1005
bool m_hton_notified
Indicates that ticket corresponds to lock request which required storage engine notification during i...
Definition: mdl.h:1102
enum_mdl_duration m_duration
Duration of lock represented by this ticket.
Definition: mdl.h:1077
enum_psi_status
Status of lock request represented by the ticket as reflected in P_S.
Definition: mdl.h:1032
@ GRANTED
Definition: mdl.h:1034
@ POST_RELEASE_NOTIFY
Definition: mdl.h:1036
@ PRE_ACQUIRE_NOTIFY
Definition: mdl.h:1035
@ PENDING
Definition: mdl.h:1033
MDL_lock * m_lock
Pointer to the lock object for this lock ticket.
Definition: mdl.h:1087
void set_duration(enum_mdl_duration dur)
Definition: mdl.h:1025
enum_mdl_type get_type() const
Definition: mdl.h:1009
MDL_ticket * next_in_lock
Pointers for participating in the list of satisfied/pending requests for the lock.
Definition: mdl.h:998
const MDL_key * get_key() const
Return a key identifying this lock.
Definition: mdl.cc:4477
MDL_context * m_ctx
Context of the owner of the metadata lock ticket.
Definition: mdl.h:1082
MDL_lock * get_lock() const
Definition: mdl.h:1010
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:1667
An abstract class for inspection of a connected subgraph of the wait-for graph.
Definition: mdl.h:920
MDL_wait_for_graph_visitor()
Definition: mdl.h:927
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:938
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:946
static const uint DEADLOCK_WEIGHT_CO
Definition: mdl.h:956
static const uint DEADLOCK_WEIGHT_ULL
Definition: mdl.h:958
static const uint DEADLOCK_WEIGHT_DML
Definition: mdl.h:957
virtual ~MDL_wait_for_subgraph()
static const uint DEADLOCK_WEIGHT_DDL
Definition: mdl.h:959
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:1344
enum_wait_status m_wait_status
Definition: mdl.h:1370
bool set_status(enum_wait_status result_arg)
Set the status unless it's already set.
Definition: mdl.cc:1763
enum_wait_status
Definition: mdl.h:1351
@ KILLED
Definition: mdl.h:1351
@ WS_EMPTY
Definition: mdl.h:1351
@ TIMEOUT
Definition: mdl.h:1351
@ GRANTED
Definition: mdl.h:1351
@ VICTIM
Definition: mdl.h:1351
MDL_wait()
Construct an empty wait slot.
Definition: mdl.cc:1746
void reset_status()
Clear the current value of the wait slot.
Definition: mdl.cc:1787
mysql_cond_t m_COND_wait_status
Definition: mdl.h:1369
~MDL_wait()
Destroy system resources.
Definition: mdl.cc:1753
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:1807
enum_wait_status get_status()
Query the current value of the wait slot.
Definition: mdl.cc:1777
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:1368
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
#define mysql_prlock_wrlock(T)
Definition: mysql_rwlock.h:76
#define mysql_prlock_rdlock(T)
Definition: mysql_rwlock.h:66
#define mysql_prlock_unlock(T)
Definition: mysql_rwlock.h:96
mysql_mutex_t LOCK_open
LOCK_open protects the following variables/objects:
Definition: sql_base.cc:276
struct PSI_metadata_lock PSI_metadata_lock
Definition: psi_mdl_bits.h:52
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
void mdl_init()
Initialize the metadata locking subsystem.
Definition: mdl.cc:1072
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:1405
#define MAX_MDLKEY_LENGTH
Maximal length of key for metadata locking subsystem.
Definition: mdl.h:354
int32 mdl_locks_unused_locks_low_water
Threshold for number of unused MDL_lock objects.
Definition: mdl.cc:283
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:1734
int32 mdl_get_unused_locks_count()
Get number of unused MDL_lock objects in MDL_map cache.
Definition: mdl.cc:1102
enum_mdl_duration
Duration of metadata lock.
Definition: mdl.h:333
@ MDL_TRANSACTION
Locks with transaction duration are automatically released at the end of transaction.
Definition: mdl.h:343
@ MDL_STATEMENT
Locks with statement duration are automatically released at the end of statement or transaction.
Definition: mdl.h:338
@ MDL_EXPLICIT
Locks with explicit duration survive the end of statement and transaction.
Definition: mdl.h:348
@ MDL_DURATION_END
Definition: mdl.h:350
@ MDL_SHARED_WRITE
Definition: mdl.h:269
@ MDL_SHARED
Definition: mdl.h:231
@ MDL_SHARED_UPGRADABLE
Definition: mdl.h:286
@ MDL_SHARED_READ_ONLY
Definition: mdl.h:292
@ MDL_SHARED_HIGH_PRIO
Definition: mdl.h:248
@ MDL_SHARED_NO_WRITE
Definition: mdl.h:306
@ MDL_SHARED_NO_READ_WRITE
Definition: mdl.h:318
@ MDL_SHARED_WRITE_LOW_PRIO
Definition: mdl.h:275
@ MDL_SHARED_READ
Definition: mdl.h:259
@ MDL_TYPE_END
Definition: mdl.h:328
@ MDL_EXCLUSIVE
Definition: mdl.h:326
@ MDL_INTENTION_EXCLUSIVE
Definition: mdl.h:208
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:1743
void mdl_destroy()
Release resources of metadata locking subsystem.
Definition: mdl.cc:1090
ulong max_write_lock_count
Definition: thr_lock.cc:124
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:52
#define INT_MAX32
Definition: my_inttypes.h:78
int32_t int32
Definition: my_inttypes.h:66
uint16_t uint16
Definition: my_inttypes.h:65
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:125
Common definition between mysql server & client.
#define NAME_LEN
Definition: mysql_com.h:67
#define NAME_CHAR_LEN
Field/table name length.
Definition: mysql_com.h:60
Instrumentation helpers for conditions.
ABI for instrumented mutexes.
Instrumentation helpers for rwlock.
std::unordered_map< Key, CHARSET_INFO * > Hash
Definition: collations_internal.cc:548
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:247
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:534
bool test_drive_fix_pins(MDL_context *)
size_t size(const char *const c)
Definition: base64.h:46
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
Instrumentation helpers for rwlock.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
required string type
Definition: replication_group_member_actions.proto:34
enum_mdl_type
Type of metadata lock request.
Definition: sql_lexer_yacc_state.h:106
case opt name
Definition: sslopt-case.h:29
char * strmake(char *dst, const char *src, size_t length)
Definition: strmake.cc:42
Hook class which via its methods specifies which members of T should be used for participating in a i...
Definition: sql_plist.h:198
Metadata lock object key.
Definition: mdl.h:365
uint16 m_db_name_length
Definition: mdl.h:786
int cmp(const MDL_key *rhs) const
Compare two MDL keys lexicographically.
Definition: mdl.h:736
const char * db_name() const
Definition: mdl.h:426
static void init_psi_keys()
Definition: mdl.cc:136
uint db_name_length() const
Definition: mdl.h:427
MDL_key(const MDL_key &rhs)
Definition: mdl.h:750
uint name_length() const
Definition: mdl.h:433
bool is_equal(const MDL_key *rhs) const
Definition: mdl.h:729
const char * name() const
Definition: mdl.h:429
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:474
enum_mdl_namespace
Object namespaces.
Definition: mdl.h:400
@ BACKUP_LOCK
Definition: mdl.h:402
@ EVENT
Definition: mdl.h:409
@ GLOBAL
Definition: mdl.h:401
@ LOCKING_SERVICE
Definition: mdl.h:412
@ USER_LEVEL_LOCK
Definition: mdl.h:411
@ COLUMN_STATISTICS
Definition: mdl.h:415
@ COMMIT
Definition: mdl.h:410
@ RESOURCE_GROUPS
Definition: mdl.h:416
@ SCHEMA
Definition: mdl.h:404
@ NAMESPACE_END
Definition: mdl.h:420
@ FUNCTION
Definition: mdl.h:406
@ TRIGGER
Definition: mdl.h:408
@ ACL_CACHE
Definition: mdl.h:414
@ FOREIGN_KEY
Definition: mdl.h:417
@ SRID
Definition: mdl.h:413
@ PROCEDURE
Definition: mdl.h:407
@ TABLESPACE
Definition: mdl.h:403
@ TABLE
Definition: mdl.h:405
@ CHECK_CONSTRAINT
Definition: mdl.h:418
enum_mdl_namespace mdl_namespace() const
Definition: mdl.h:459
void mdl_key_init(const MDL_key *rhs)
Definition: mdl.h:713
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:638
uint16 m_length
Definition: mdl.h:785
uint length() const
Definition: mdl.h:424
char m_ptr[MAX_MDLKEY_LENGTH]
Definition: mdl.h:788
const uchar * ptr() const
Definition: mdl.h:423
const char * col_name() const
Definition: mdl.h:435
MDL_key & operator=(const MDL_key &rhs)
Definition: mdl.h:752
uint col_name_length() const
Definition: mdl.h:447
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:689
void reset()
Definition: mdl.h:723
MDL_key(enum_mdl_namespace namespace_arg, const char *db_arg, const char *name_arg)
Definition: mdl.h:757
uint16 m_object_name_length
Definition: mdl.h:787
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:521
bool use_normalized_object_name() const
Check if normalized object name should be used.
Definition: mdl.h:778
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:767
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:789
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:1149
Ticket_p_list m_ticket_list
Definition: mdl.h:1137
size_t operator()(const MDL_key *k) const
Definition: mdl.cc:4644
bool operator()(const MDL_key *a, const MDL_key *b) const
Definition: mdl.h:1159
Utility struct for representing a ticket pointer and its duration.
Definition: mdl.h:1121
enum_mdl_duration m_dur
Definition: mdl.h:1122
MDL_ticket_handle(MDL_ticket *t, enum_mdl_duration d)
Definition: mdl.h:1126
MDL_ticket_handle()=default
MDL_ticket * m_ticket
Definition: mdl.h:1123
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
void * Alloc(size_t length)
Allocate memory.
Definition: my_alloc.h:145
Stage instrument information.
Definition: psi_stage_bits.h:74
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
An instrumented prlock structure.
Definition: mysql_rwlock_bits.h:72