MySQL 8.4.2
Source Code Documentation
MDL_ticket Class Reference

A granted metadata lock. More...

#include <mdl.h>

Inheritance diagram for MDL_ticket:
[legend]

Public Types

enum  enum_psi_status { PENDING = 0 , GRANTED , PRE_ACQUIRE_NOTIFY , POST_RELEASE_NOTIFY }
 Status of lock request represented by the ticket as reflected in P_S. More...
 

Public Member Functions

bool has_pending_conflicting_lock () const
 Check if we have any pending locks which conflict with existing shared lock. More...
 
MDL_contextget_ctx () const
 
bool is_upgradable_or_exclusive () const
 
enum_mdl_type get_type () const
 
MDL_lockget_lock () const
 
const MDL_keyget_key () const
 Return a key identifying this lock. More...
 
void downgrade_lock (enum_mdl_type type)
 Downgrade an EXCLUSIVE or SHARED_NO_WRITE lock to shared metadata lock. More...
 
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. More...
 
bool is_incompatible_when_granted (enum_mdl_type type) const
 
bool is_incompatible_when_waiting (enum_mdl_type type) const
 
bool accept_visitor (MDL_wait_for_graph_visitor *dvisitor) override
 Implement MDL_wait_for_subgraph interface. More...
 
uint get_deadlock_weight () const override
 Return the 'weight' of this ticket for the victim selection algorithm. More...
 
enum_mdl_duration get_duration () const
 
void set_duration (enum_mdl_duration dur)
 
- Public Member Functions inherited from MDL_wait_for_subgraph
virtual ~MDL_wait_for_subgraph ()
 

Public Attributes

MDL_ticketnext_in_context
 Pointers for participating in the list of lock requests for this context. More...
 
MDL_ticket ** prev_in_context
 
MDL_ticketnext_in_lock
 Pointers for participating in the list of satisfied/pending requests for the lock. More...
 
MDL_ticket ** prev_in_lock
 

Private Member Functions

 MDL_ticket (MDL_context *ctx_arg, enum_mdl_type type_arg, enum_mdl_duration duration_arg)
 
 ~MDL_ticket () override
 
 MDL_ticket (const MDL_ticket &)
 
MDL_ticketoperator= (const MDL_ticket &)
 

Static Private Member Functions

static MDL_ticketcreate (MDL_context *ctx_arg, enum_mdl_type type_arg, enum_mdl_duration duration_arg)
 Auxiliary functions needed for creation/destruction of MDL_ticket objects. More...
 
static void destroy (MDL_ticket *ticket)
 

Private Attributes

enum enum_mdl_type m_type
 Type of metadata lock. More...
 
enum_mdl_duration m_duration
 Duration of lock represented by this ticket. More...
 
MDL_contextm_ctx
 Context of the owner of the metadata lock ticket. More...
 
MDL_lockm_lock
 Pointer to the lock object for this lock ticket. More...
 
bool m_is_fast_path
 Indicates that ticket corresponds to lock acquired using "fast path" algorithm. More...
 
bool m_hton_notified
 Indicates that ticket corresponds to lock request which required storage engine notification during its acquisition and requires storage engine notification after its release. More...
 
PSI_metadata_lockm_psi
 

Friends

class MDL_context
 

Additional Inherited Members

- Static Public Attributes inherited from MDL_wait_for_subgraph
static const uint DEADLOCK_WEIGHT_CO = 0
 
static const uint DEADLOCK_WEIGHT_DML = 25
 
static const uint DEADLOCK_WEIGHT_ULL = 50
 
static const uint DEADLOCK_WEIGHT_DDL = 100
 

Detailed Description

A granted metadata lock.

Warning
MDL_ticket members are private to the MDL subsystem.
Note
Multiple shared locks on a same object are represented by a single ticket. The same does not apply for other lock types.
There are two groups of MDL_ticket members:
  • "Externally accessible". These members can be accessed from threads/contexts different than ticket owner in cases when ticket participates in some list of granted or waiting tickets for a lock. Therefore one should change these members before including then to waiting/granted lists or while holding lock protecting those lists.
  • "Context private". Such members are private to thread/context owning this ticket. I.e. they should not be accessed from other threads/contexts.

Member Enumeration Documentation

◆ enum_psi_status

Status of lock request represented by the ticket as reflected in P_S.

Enumerator
PENDING 
GRANTED 
PRE_ACQUIRE_NOTIFY 
POST_RELEASE_NOTIFY 

Constructor & Destructor Documentation

◆ MDL_ticket() [1/2]

MDL_ticket::MDL_ticket ( MDL_context ctx_arg,
enum_mdl_type  type_arg,
enum_mdl_duration  duration_arg 
)
inlineprivate

◆ ~MDL_ticket()

MDL_ticket::~MDL_ticket ( )
inlineoverrideprivate

◆ MDL_ticket() [2/2]

MDL_ticket::MDL_ticket ( const MDL_ticket )
private

Member Function Documentation

◆ accept_visitor()

bool MDL_ticket::accept_visitor ( MDL_wait_for_graph_visitor gvisitor)
overridevirtual

Implement MDL_wait_for_subgraph interface.

Traverse a portion of wait-for graph which is reachable through the edge represented by this ticket and search for deadlocks.

Return values
trueA deadlock is found. A pointer to deadlock victim is saved in the visitor.
falseTBD

Implements MDL_wait_for_subgraph.

◆ create()

MDL_ticket * MDL_ticket::create ( MDL_context ctx_arg,
enum_mdl_type  type_arg,
enum_mdl_duration  duration_arg 
)
staticprivate

Auxiliary functions needed for creation/destruction of MDL_ticket objects.

◆ destroy()

void MDL_ticket::destroy ( MDL_ticket ticket)
staticprivate

◆ downgrade_lock()

void MDL_ticket::downgrade_lock ( enum_mdl_type  new_type)

Downgrade an EXCLUSIVE or SHARED_NO_WRITE lock to shared metadata lock.

Parameters
new_typeType of lock to which exclusive lock should be downgraded.

◆ get_ctx()

MDL_context * MDL_ticket::get_ctx ( ) const
inline

◆ get_deadlock_weight()

uint MDL_ticket::get_deadlock_weight ( ) const
overridevirtual

Return the 'weight' of this ticket for the victim selection algorithm.

Requests with lower weight are preferred to requests with higher weight when choosing a victim.

Note
When MDL_context::m_force_dml_deadlock_weight is set, the return value of this method is ignored and DEADLOCK_WEIGHT_DML is used for the context.

Implements MDL_wait_for_subgraph.

◆ get_duration()

enum_mdl_duration MDL_ticket::get_duration ( ) const
inline

◆ get_key()

const MDL_key * MDL_ticket::get_key ( ) const

Return a key identifying this lock.

◆ get_lock()

MDL_lock * MDL_ticket::get_lock ( ) const
inline

◆ get_type()

enum_mdl_type MDL_ticket::get_type ( ) const
inline

◆ has_pending_conflicting_lock()

bool MDL_ticket::has_pending_conflicting_lock ( ) const

Check if we have any pending locks which conflict with existing shared lock.

Precondition
The ticket must match an acquired lock.
Returns
true if there is a conflicting lock request, false otherwise.

◆ has_stronger_or_equal_type()

bool MDL_ticket::has_stronger_or_equal_type ( enum_mdl_type  type) const

Check if ticket represents metadata lock of "stronger" or equal type than specified one.

I.e. if metadata lock represented by ticket won't allow any of locks which are not allowed by specified type of lock.

Returns
true if ticket has stronger or equal type false otherwise.

◆ is_incompatible_when_granted()

bool MDL_ticket::is_incompatible_when_granted ( enum_mdl_type  type) const

◆ is_incompatible_when_waiting()

bool MDL_ticket::is_incompatible_when_waiting ( enum_mdl_type  type) const

◆ is_upgradable_or_exclusive()

bool MDL_ticket::is_upgradable_or_exclusive ( ) const
inline

◆ operator=()

MDL_ticket & MDL_ticket::operator= ( const MDL_ticket )
private

◆ set_duration()

void MDL_ticket::set_duration ( enum_mdl_duration  dur)
inline

Friends And Related Function Documentation

◆ MDL_context

friend class MDL_context
friend

Member Data Documentation

◆ m_ctx

MDL_context* MDL_ticket::m_ctx
private

Context of the owner of the metadata lock ticket.

Externally accessible.

◆ m_duration

enum_mdl_duration MDL_ticket::m_duration
private

Duration of lock represented by this ticket.

Context private. Debug-only.

◆ m_hton_notified

bool MDL_ticket::m_hton_notified
private

Indicates that ticket corresponds to lock request which required storage engine notification during its acquisition and requires storage engine notification after its release.

◆ m_is_fast_path

bool MDL_ticket::m_is_fast_path
private

Indicates that ticket corresponds to lock acquired using "fast path" algorithm.

Particularly this means that it was not included into MDL_lock::m_granted bitmap/list and instead is accounted for by MDL_lock::m_fast_path_locks_granted_counter

◆ m_lock

MDL_lock* MDL_ticket::m_lock
private

Pointer to the lock object for this lock ticket.

Externally accessible.

◆ m_psi

PSI_metadata_lock* MDL_ticket::m_psi
private

◆ m_type

enum enum_mdl_type MDL_ticket::m_type
private

Type of metadata lock.

Externally accessible.

◆ next_in_context

MDL_ticket* MDL_ticket::next_in_context

Pointers for participating in the list of lock requests for this context.

Context private.

◆ next_in_lock

MDL_ticket* MDL_ticket::next_in_lock

Pointers for participating in the list of satisfied/pending requests for the lock.

Externally accessible.

◆ prev_in_context

MDL_ticket** MDL_ticket::prev_in_context

◆ prev_in_lock

MDL_ticket** MDL_ticket::prev_in_lock

The documentation for this class was generated from the following files: