MDL_lock encapsulation: removed redundant methods
Given that MDL_lock::m_strategy is only accessed by MDL_lock methods, there is no point in having MDL_lock::needs_notification() and MDL_lock::hog_lock_types_bitmap() getters anymore. MDL_lock::has_pending_conflicting_lock() moved to MDL_lock class. This is part of broader cleanup, which aims to make large part of MDL_lock members private. It is needed to simplify further work on MDEV-19749 - MDL scalability regression after backup locks.
This commit is contained in:
parent
42336cedd2
commit
73798620a8
55
sql/mdl.cc
55
sql/mdl.cc
@ -370,11 +370,6 @@ Deadlock_detection_visitor::opt_change_victim_to(MDL_context *new_victim)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get a bit corresponding to enum_mdl_type value in a granted/waiting bitmaps
|
|
||||||
and compatibility matrices.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The lock context. Created internally for an acquired lock.
|
The lock context. Created internally for an acquired lock.
|
||||||
For a given name, there exists only one MDL_lock instance,
|
For a given name, there exists only one MDL_lock instance,
|
||||||
@ -620,8 +615,6 @@ class MDL_lock
|
|||||||
void remove_ticket(LF_PINS *pins, Ticket_list MDL_lock::*queue,
|
void remove_ticket(LF_PINS *pins, Ticket_list MDL_lock::*queue,
|
||||||
MDL_ticket *ticket);
|
MDL_ticket *ticket);
|
||||||
|
|
||||||
bool needs_notification(const MDL_ticket *ticket) const
|
|
||||||
{ return m_strategy->needs_notification(ticket); }
|
|
||||||
void notify_conflicting_locks(MDL_context *ctx, bool abort_blocking)
|
void notify_conflicting_locks(MDL_context *ctx, bool abort_blocking)
|
||||||
{
|
{
|
||||||
for (const auto &conflicting_ticket : m_granted)
|
for (const auto &conflicting_ticket : m_granted)
|
||||||
@ -639,9 +632,6 @@ class MDL_lock
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap_t hog_lock_types_bitmap() const
|
|
||||||
{ return m_strategy->hog_lock_types_bitmap(); }
|
|
||||||
|
|
||||||
#ifndef DBUG_OFF
|
#ifndef DBUG_OFF
|
||||||
bool check_if_conflicting_replication_locks(MDL_context *ctx);
|
bool check_if_conflicting_replication_locks(MDL_context *ctx);
|
||||||
#endif
|
#endif
|
||||||
@ -652,7 +642,24 @@ public:
|
|||||||
const bitmap_t *incompatible_waiting_types_bitmap() const
|
const bitmap_t *incompatible_waiting_types_bitmap() const
|
||||||
{ return m_strategy->incompatible_waiting_types_bitmap(); }
|
{ return m_strategy->incompatible_waiting_types_bitmap(); }
|
||||||
|
|
||||||
bool has_pending_conflicting_lock(enum_mdl_type type);
|
|
||||||
|
/**
|
||||||
|
Check if we have any pending locks which conflict with existing
|
||||||
|
shared lock.
|
||||||
|
|
||||||
|
@pre The ticket must match an acquired lock.
|
||||||
|
|
||||||
|
@return TRUE if there is a conflicting lock request, FALSE otherwise.
|
||||||
|
*/
|
||||||
|
bool has_pending_conflicting_lock(enum_mdl_type type)
|
||||||
|
{
|
||||||
|
bool result;
|
||||||
|
mysql_prlock_rdlock(&m_rwlock);
|
||||||
|
result= (m_waiting.bitmap() & incompatible_granted_types_bitmap()[type]);
|
||||||
|
mysql_prlock_unlock(&m_rwlock);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool visit_subgraph(MDL_ticket *waiting_ticket,
|
bool visit_subgraph(MDL_ticket *waiting_ticket,
|
||||||
MDL_wait_for_graph_visitor *gvisitor);
|
MDL_wait_for_graph_visitor *gvisitor);
|
||||||
@ -800,7 +807,7 @@ end:
|
|||||||
|
|
||||||
void notify_conflicting_locks_if_needed(MDL_ticket *ticket, bool abort_blocking)
|
void notify_conflicting_locks_if_needed(MDL_ticket *ticket, bool abort_blocking)
|
||||||
{
|
{
|
||||||
if (needs_notification(ticket))
|
if (m_strategy->needs_notification(ticket))
|
||||||
{
|
{
|
||||||
mysql_prlock_wrlock(&m_rwlock);
|
mysql_prlock_wrlock(&m_rwlock);
|
||||||
notify_conflicting_locks(ticket->get_ctx(), abort_blocking);
|
notify_conflicting_locks(ticket->get_ctx(), abort_blocking);
|
||||||
@ -867,7 +874,7 @@ end:
|
|||||||
res= TAL_WAIT;
|
res= TAL_WAIT;
|
||||||
m_waiting.add_ticket(ticket);
|
m_waiting.add_ticket(ticket);
|
||||||
|
|
||||||
if (needs_notification(ticket))
|
if (m_strategy->needs_notification(ticket))
|
||||||
notify_conflicting_locks(mdl_context, false);
|
notify_conflicting_locks(mdl_context, false);
|
||||||
|
|
||||||
DBUG_SLOW_ASSERT((ticket->get_type() != MDL_INTENTION_EXCLUSIVE &&
|
DBUG_SLOW_ASSERT((ticket->get_type() != MDL_INTENTION_EXCLUSIVE &&
|
||||||
@ -1449,7 +1456,7 @@ void MDL_lock::Ticket_list::remove_ticket(MDL_ticket *ticket)
|
|||||||
void MDL_lock::reschedule_waiters()
|
void MDL_lock::reschedule_waiters()
|
||||||
{
|
{
|
||||||
bool skip_high_priority= false;
|
bool skip_high_priority= false;
|
||||||
bitmap_t hog_lock_types= hog_lock_types_bitmap();
|
bitmap_t hog_lock_types= m_strategy->hog_lock_types_bitmap();
|
||||||
|
|
||||||
if (m_hog_lock_count >= max_write_lock_count)
|
if (m_hog_lock_count >= max_write_lock_count)
|
||||||
{
|
{
|
||||||
@ -1992,26 +1999,6 @@ void MDL_lock::remove_ticket(LF_PINS *pins, Ticket_list MDL_lock::*list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Check if we have any pending locks which conflict with existing
|
|
||||||
shared lock.
|
|
||||||
|
|
||||||
@pre The ticket must match an acquired lock.
|
|
||||||
|
|
||||||
@return TRUE if there is a conflicting lock request, FALSE otherwise.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool MDL_lock::has_pending_conflicting_lock(enum_mdl_type type)
|
|
||||||
{
|
|
||||||
bool result;
|
|
||||||
|
|
||||||
mysql_prlock_rdlock(&m_rwlock);
|
|
||||||
result= (m_waiting.bitmap() & incompatible_granted_types_bitmap()[type]);
|
|
||||||
mysql_prlock_unlock(&m_rwlock);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MDL_wait_for_graph_visitor::~MDL_wait_for_graph_visitor()
|
MDL_wait_for_graph_visitor::~MDL_wait_for_graph_visitor()
|
||||||
= default;
|
= default;
|
||||||
|
|
||||||
|
@ -31,6 +31,12 @@ class MDL_lock;
|
|||||||
class MDL_ticket;
|
class MDL_ticket;
|
||||||
|
|
||||||
typedef unsigned short mdl_bitmap_t;
|
typedef unsigned short mdl_bitmap_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get a bit corresponding to enum_mdl_type value in a granted/waiting bitmaps
|
||||||
|
and compatibility matrices.
|
||||||
|
*/
|
||||||
#define MDL_BIT(A) static_cast<mdl_bitmap_t>(1U << A)
|
#define MDL_BIT(A) static_cast<mdl_bitmap_t>(1U << A)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user