32#include <unordered_map>
71#define ENTER_COND(C, M, S, O) \
72 enter_cond(C, M, S, O, __func__, __FILE__, __LINE__)
79#define EXIT_COND(S) exit_cond(S, __func__, __FILE__, __LINE__)
109 const char *src_file,
int src_line) = 0;
121 const char *src_file,
int src_line) = 0;
162 bool needs_thr_lock_abort) = 0;
176 bool *victimized) = 0;
355#define MAX_MDLKEY_LENGTH (1 + NAME_LEN + 1 + NAME_LEN + 1)
368#ifdef HAVE_PSI_INTERFACE
523 const char *
name,
const char *column_name) {
540 const size_t col_len = strlen(column_name);
543 const size_t remaining =
599 if (remaining >= col_len + 1) {
640 const char *normalized_name,
size_t normalized_name_len,
691 size_t part_key_length,
size_t db_length) {
696 assert(strlen(part_key) == db_length);
697 assert(db_length + 1 + strlen(part_key + db_length + 1) + 1 ==
709 memcpy(
m_ptr + 1, part_key, part_key_length);
715 const uint16 copy_length =
759 const char *name_arg) {
829 const std::nothrow_t &arg
830 [[maybe_unused]] = std::nothrow)
noexcept {
835 const std::nothrow_t &)
noexcept {}
838 const char *db_arg,
const char *name_arg,
841 const char *src_file, uint src_line);
845 const char *src_file, uint src_line);
847 const char *part_key_arg,
848 size_t part_key_length_arg,
849 size_t db_length_arg,
852 const char *src_file, uint src_line);
855 assert(
ticket ==
nullptr);
907#define MDL_REQUEST_INIT(R, P1, P2, P3, P4, P5) \
908 (*R).init_with_source(P1, P2, P3, P4, P5, __FILE__, __LINE__)
910#define MDL_REQUEST_INIT_BY_KEY(R, P1, P2, P3) \
911 (*R).init_by_key_with_source(P1, P2, P3, __FILE__, __LINE__)
913#define MDL_REQUEST_INIT_BY_PART_KEY(R, P1, P2, P3, P4, P5, P6) \
914 (*R).init_by_part_key_with_source(P1, P2, P3, P4, P5, P6, __FILE__, __LINE__)
1209 template <
typename CLOS>
1212 for (
MDL_ticket *t = it++; t !=
nullptr; t = it++) {
1222 template <
typename CLOS>
1358 struct timespec *abs_timeout,
bool signal_timeout,
1374 std::function<
void(
unsigned long)> tracker_function,
1474 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:86
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:1412
virtual ~MDL_context_visitor()=default
virtual void visit_context(const MDL_context *ctx)=0
Context of the owner of metadata locks.
Definition: mdl.h:1429
Ticket_list::Iterator Ticket_iterator
Definition: mdl.h:1436
MDL_context_owner * get_owner() const
Definition: mdl.h:1506
bool acquire_locks(MDL_request_list *requests, Timeout_type lock_wait_timeout)
Acquire exclusive locks.
Definition: mdl.cc:3695
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:4432
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:3749
MDL_savepoint mdl_savepoint()
Definition: mdl.h:1493
MDL_context()
Initialize a metadata locking context.
Definition: mdl.cc:1436
bool has_locks(enum_mdl_duration duration)
Definition: mdl.h:1488
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:3416
uint get_deadlock_weight() const
Definition: mdl.h:1509
void set_explicit_duration_for_all_locks()
Set explicit duration for all locks in the context.
Definition: mdl.cc:4687
void set_force_dml_deadlock_weight(bool force_dml_deadlock_weight)
Definition: mdl.h:1539
void init(MDL_context_owner *arg)
Definition: mdl.h:1515
MDL_context_owner * m_owner
Definition: mdl.h:1629
void release_statement_locks()
Definition: mdl.cc:4566
void set_lock_duration(MDL_ticket *mdl_ticket, enum_mdl_duration duration)
Change lock duration for transactional lock.
Definition: mdl.cc:4663
void release_lock(MDL_ticket *ticket)
Release lock with explicit duration.
Definition: mdl.cc:4269
uint get_random()
Get pseudo random value in [0 .
Definition: mdl.h:1559
mysql_prlock_t m_LOCK_waiting_for
Read-write lock protecting m_waiting_for member.
Definition: mdl.h:1659
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:4334
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:4312
void set_needs_thr_lock_abort(bool needs_thr_lock_abort)
Definition: mdl.h:1517
bool clone_ticket(MDL_request *mdl_request)
Create a copy of a granted ticket.
Definition: mdl.cc:3229
void release_locks_stored_before(enum_mdl_duration duration, MDL_ticket *sentinel)
Release all locks associated with the context.
Definition: mdl.cc:4288
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:4485
void rollback_to_savepoint(const MDL_savepoint &mdl_savepoint)
Releases metadata locks that were acquired after a specific savepoint.
Definition: mdl.cc:4543
uint m_rand_state
State for pseudo random numbers generator (PRNG) which output is used to perform random dives into MD...
Definition: mdl.h:1679
bool try_acquire_lock_impl(MDL_request *mdl_request, MDL_ticket **out_ticket)
Auxiliary method for acquiring lock without waiting.
Definition: mdl.cc:2865
MDL_context(const MDL_context &rhs)
void find_deadlock()
Try to find a deadlock.
Definition: mdl.cc:4100
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:1650
void lock_deadlock_victim()
Definition: mdl.h:1722
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:1434
LF_PINS * m_pins
Thread's pins (a.k.a.
Definition: mdl.h:1673
void materialize_fast_path_locks()
"Materialize" requests for locks which were satisfied using "fast path" by properly including them in...
Definition: mdl.cc:2816
bool try_acquire_lock(MDL_request *mdl_request)
Try to acquire one lock.
Definition: mdl.cc:2742
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:4080
bool has_locks_waited_for() const
Do we hold any locks which are possibly being waited for by another MDL_context?
Definition: mdl.cc:4633
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:1639
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:3802
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:1667
void set_transaction_duration_for_all_locks()
Set transactional duration for all locks in the context.
Definition: mdl.cc:4695
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:2712
void done_waiting_for()
Remove the wait-for edge from the graph after we're done waiting.
Definition: mdl.h:1717
THD * get_thd() const
Within MDL subsystem this one is only used for DEBUG_SYNC.
Definition: mdl.h:1578
bool get_needs_thr_lock_abort() const
Definition: mdl.h:1537
bool has_lock(const MDL_savepoint &mdl_savepoint, MDL_ticket *mdl_ticket)
Does this savepoint have this lock?
Definition: mdl.cc:4581
bool has_locks() const
Definition: mdl.h:1481
MDL_ticket_store m_ticket_store
Lists of all MDL tickets acquired by this connection.
Definition: mdl.h:1627
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:1585
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:1723
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:4560
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:1698
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:1397
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:803
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:871
bool is_write_lock_request() const
Is this a request for a lock which allow data to be updated?
Definition: mdl.h:866
MDL_request(MDL_request &&)=default
enum_mdl_type type
Type of metadata lock.
Definition: mdl.h:806
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:854
MDL_request & operator=(MDL_request &&)=default
MDL_ticket * ticket
Pointer to the lock ticket object for this lock request.
Definition: mdl.h:819
MDL_request ** prev_in_list
Definition: mdl.h:814
const char * m_src_file
Definition: mdl.h:824
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:822
enum_mdl_duration duration
Duration for requested lock.
Definition: mdl.h:808
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:813
uint m_src_line
Definition: mdl.h:825
MDL_request(const MDL_request &rhs)
Definition: mdl.h:899
Savepoint for MDL context.
Definition: mdl.h:1318
MDL_ticket * m_trans_ticket
Pointer to last lock with transaction duration which was taken before creation of savepoint.
Definition: mdl.h:1338
MDL_ticket * m_stmt_ticket
Pointer to last lock with statement duration which was taken before creation of savepoint.
Definition: mdl.h:1333
MDL_savepoint(MDL_ticket *stmt_ticket, MDL_ticket *trans_ticket)
Definition: mdl.h:1323
Keep track of MDL_ticket for different durations.
Definition: mdl.h:1117
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:1223
List_iterator list_iterator(int di) const
Return a P-list iterator to the given duration.
Definition: mdl.h:1272
std::unique_ptr< Ticket_map > m_map
Definition: mdl.h:1184
MDL_ticket_handle find(const MDL_request &req) const
Look up a ticket based on its MDL_key.
Definition: mdl.cc:4947
size_t m_count
Definition: mdl.h:1182
void set_materialized()
Mark boundary for tickets with fast_path=false, so that later calls to materialize_fast_path_locks() ...
Definition: mdl.cc:4961
const size_t INITIAL_BUCKET_COUNT
Initial number of buckets in the hash index.
Definition: mdl.h:1181
MDL_ticket_handle find_in_hash(const MDL_request &req) const
Definition: mdl.cc:4720
void remove(enum_mdl_duration dur, MDL_ticket *ticket)
Remove a ticket from a duration list.
Definition: mdl.cc:4801
void move_all_to_explicit_duration()
Move all tickets to the explicit duration list.
Definition: mdl.cc:4837
void move_explicit_to_transaction_duration()
Move all tickets to the transaction duration list.
Definition: mdl.cc:4896
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:4967
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:1175
MDL_ticket_store()
Constructs store.
Definition: mdl.h:1198
void push_front(enum_mdl_duration dur, MDL_ticket *ticket)
Push a ticket onto the list for a given duration.
Definition: mdl.cc:4758
Duration m_durations[MDL_DURATION_END]
Definition: mdl.h:1153
MDL_ticket * front(int di)
Return the first MDL_ticket for the given duration.
Definition: mdl.cc:4754
MDL_ticket_handle find_in_lists(const MDL_request &req) const
Definition: mdl.cc:4703
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:1210
bool is_empty() const
Predicate for the emptiness of the store.
Definition: mdl.cc:4742
std::unordered_multimap< const MDL_key *, MDL_ticket_handle, Hash, Key_equal > Ticket_map
Definition: mdl.h:1166
A granted metadata lock.
Definition: mdl.h:986
enum enum_mdl_type m_type
Type of metadata lock.
Definition: mdl.h:1072
bool m_is_fast_path
Indicates that ticket corresponds to lock acquired using "fast path" algorithm.
Definition: mdl.h:1096
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:2654
bool has_pending_conflicting_lock() const
Check if we have any pending locks which conflict with existing shared lock.
Definition: mdl.cc:4526
MDL_context * get_ctx() const
Definition: mdl.h:1005
void downgrade_lock(enum_mdl_type type)
Downgrade an EXCLUSIVE or SHARED_NO_WRITE lock to shared metadata lock.
Definition: mdl.cc:4352
~MDL_ticket() override
Definition: mdl.h:1060
MDL_ticket(MDL_context *ctx_arg, enum_mdl_type type_arg, enum_mdl_duration duration_arg)
Definition: mdl.h:1043
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:4060
bool is_incompatible_when_waiting(enum_mdl_type type) const
Definition: mdl.cc:2665
MDL_ticket * next_in_context
Pointers for participating in the list of lock requests for this context.
Definition: mdl.h:992
bool is_incompatible_when_granted(enum_mdl_type type) const
Definition: mdl.cc:2661
PSI_metadata_lock * m_psi
Definition: mdl.h:1105
MDL_ticket ** prev_in_lock
Definition: mdl.h:1000
MDL_ticket ** prev_in_context
Definition: mdl.h:993
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:1025
bool is_upgradable_or_exclusive() const
Definition: mdl.h:1006
bool m_hton_notified
Indicates that ticket corresponds to lock request which required storage engine notification during i...
Definition: mdl.h:1103
enum_mdl_duration m_duration
Duration of lock represented by this ticket.
Definition: mdl.h:1078
enum_psi_status
Status of lock request represented by the ticket as reflected in P_S.
Definition: mdl.h:1033
@ GRANTED
Definition: mdl.h:1035
@ POST_RELEASE_NOTIFY
Definition: mdl.h:1037
@ PRE_ACQUIRE_NOTIFY
Definition: mdl.h:1036
@ PENDING
Definition: mdl.h:1034
MDL_lock * m_lock
Pointer to the lock object for this lock ticket.
Definition: mdl.h:1088
void set_duration(enum_mdl_duration dur)
Definition: mdl.h:1026
enum_mdl_type get_type() const
Definition: mdl.h:1010
MDL_ticket * next_in_lock
Pointers for participating in the list of satisfied/pending requests for the lock.
Definition: mdl.h:999
const MDL_key * get_key() const
Return a key identifying this lock.
Definition: mdl.cc:4532
MDL_context * m_ctx
Context of the owner of the metadata lock ticket.
Definition: mdl.h:1083
MDL_lock * get_lock() const
Definition: mdl.h:1011
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:921
MDL_wait_for_graph_visitor()
Definition: mdl.h:928
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:939
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:947
static const uint DEADLOCK_WEIGHT_CO
Definition: mdl.h:957
static const uint DEADLOCK_WEIGHT_ULL
Definition: mdl.h:959
static const uint DEADLOCK_WEIGHT_DML
Definition: mdl.h:958
virtual ~MDL_wait_for_subgraph()
static const uint DEADLOCK_WEIGHT_DDL
Definition: mdl.h:960
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:1345
enum_wait_status m_wait_status
Definition: mdl.h:1387
bool set_status(enum_wait_status result_arg)
Set the status unless it's already set.
Definition: mdl.cc:1763
enum_wait_status observable_timed_wait(MDL_context_owner *owner, unsigned long abs_timeout, bool signal_timeout, std::function< void(unsigned long)> tracker_function, const PSI_stage_info *wait_state_name)
Wait for the status to be assigned to this wait slot.
Definition: mdl.cc:1851
enum_wait_status
Definition: mdl.h:1352
@ KILLED
Definition: mdl.h:1352
@ WS_EMPTY
Definition: mdl.h:1352
@ TIMEOUT
Definition: mdl.h:1352
@ GRANTED
Definition: mdl.h:1352
@ VICTIM
Definition: mdl.h:1352
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:1386
~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:1385
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:275
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:1422
#define MAX_MDLKEY_LENGTH
Maximal length of key for metadata locking subsystem.
Definition: mdl.h:355
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:1751
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:334
@ MDL_TRANSACTION
Locks with transaction duration are automatically released at the end of transaction.
Definition: mdl.h:344
@ MDL_STATEMENT
Locks with statement duration are automatically released at the end of statement or transaction.
Definition: mdl.h:339
@ MDL_EXPLICIT
Locks with explicit duration survive the end of statement and transaction.
Definition: mdl.h:349
@ MDL_DURATION_END
Definition: mdl.h:351
@ MDL_SHARED_WRITE
Definition: mdl.h:270
@ MDL_SHARED
Definition: mdl.h:232
@ MDL_SHARED_UPGRADABLE
Definition: mdl.h:287
@ MDL_SHARED_READ_ONLY
Definition: mdl.h:293
@ MDL_SHARED_HIGH_PRIO
Definition: mdl.h:249
@ MDL_SHARED_NO_WRITE
Definition: mdl.h:307
@ MDL_SHARED_NO_READ_WRITE
Definition: mdl.h:319
@ MDL_SHARED_WRITE_LOW_PRIO
Definition: mdl.h:276
@ MDL_SHARED_READ
Definition: mdl.h:260
@ MDL_TYPE_END
Definition: mdl.h:329
@ MDL_EXCLUSIVE
Definition: mdl.h:327
@ MDL_INTENTION_EXCLUSIVE
Definition: mdl.h:209
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:1760
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:366
uint16 m_db_name_length
Definition: mdl.h:787
int cmp(const MDL_key *rhs) const
Compare two MDL keys lexicographically.
Definition: mdl.h:737
const char * db_name() const
Definition: mdl.h:427
static void init_psi_keys()
Definition: mdl.cc:136
uint db_name_length() const
Definition: mdl.h:428
MDL_key(const MDL_key &rhs)
Definition: mdl.h:751
uint name_length() const
Definition: mdl.h:434
bool is_equal(const MDL_key *rhs) const
Definition: mdl.h:730
const char * name() const
Definition: mdl.h:430
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:475
enum_mdl_namespace
Object namespaces.
Definition: mdl.h:401
@ BACKUP_LOCK
Definition: mdl.h:403
@ EVENT
Definition: mdl.h:410
@ GLOBAL
Definition: mdl.h:402
@ LOCKING_SERVICE
Definition: mdl.h:413
@ USER_LEVEL_LOCK
Definition: mdl.h:412
@ COLUMN_STATISTICS
Definition: mdl.h:416
@ COMMIT
Definition: mdl.h:411
@ RESOURCE_GROUPS
Definition: mdl.h:417
@ SCHEMA
Definition: mdl.h:405
@ NAMESPACE_END
Definition: mdl.h:421
@ FUNCTION
Definition: mdl.h:407
@ TRIGGER
Definition: mdl.h:409
@ ACL_CACHE
Definition: mdl.h:415
@ FOREIGN_KEY
Definition: mdl.h:418
@ SRID
Definition: mdl.h:414
@ PROCEDURE
Definition: mdl.h:408
@ TABLESPACE
Definition: mdl.h:404
@ TABLE
Definition: mdl.h:406
@ CHECK_CONSTRAINT
Definition: mdl.h:419
enum_mdl_namespace mdl_namespace() const
Definition: mdl.h:460
void mdl_key_init(const MDL_key *rhs)
Definition: mdl.h:714
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:639
uint16 m_length
Definition: mdl.h:786
uint length() const
Definition: mdl.h:425
char m_ptr[MAX_MDLKEY_LENGTH]
Definition: mdl.h:789
const uchar * ptr() const
Definition: mdl.h:424
const char * col_name() const
Definition: mdl.h:436
MDL_key & operator=(const MDL_key &rhs)
Definition: mdl.h:753
uint col_name_length() const
Definition: mdl.h:448
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:690
void reset()
Definition: mdl.h:724
MDL_key(enum_mdl_namespace namespace_arg, const char *db_arg, const char *name_arg)
Definition: mdl.h:758
uint16 m_object_name_length
Definition: mdl.h:788
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:522
bool use_normalized_object_name() const
Check if normalized object name should be used.
Definition: mdl.h:779
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:768
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:790
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:1150
Ticket_p_list m_ticket_list
Definition: mdl.h:1138
size_t operator()(const MDL_key *k) const
Definition: mdl.cc:4699
bool operator()(const MDL_key *a, const MDL_key *b) const
Definition: mdl.h:1160
Utility struct for representing a ticket pointer and its duration.
Definition: mdl.h:1122
enum_mdl_duration m_dur
Definition: mdl.h:1123
MDL_ticket_handle(MDL_ticket *t, enum_mdl_duration d)
Definition: mdl.h:1127
MDL_ticket_handle()=default
MDL_ticket * m_ticket
Definition: mdl.h:1124
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