#At file:///opt/local/work/next-4284-stage/ based on revid:kostja@stripped
3057 Konstantin Osipov 2010-01-20
Bug#46272/Bug#38924 review fixes in progress.
Rename a few members, realign comments to fit 66 characters,
update comments.
modified:
sql/mdl.cc
sql/mdl.h
=== modified file 'sql/mdl.cc'
--- a/sql/mdl.cc 2010-01-19 21:06:19 +0000
+++ b/sql/mdl.cc 2010-01-20 10:17:29 +0000
@@ -43,38 +43,15 @@ public:
typedef Ticket_list::Iterator Ticket_iterator;
-private:
- /**
- These three members are used to make it possible to separate the
- LOCK_mdl_hash mutex and MDL_lock::lock mutex in MDL_lock::find_or_insert()
- for increased scalability.
- The 'm_destroyed' member is only set by destroyers that have both the
- LOCK_mdl_hash and MDL_lock::lock mutex, thus holding any of the mutexes
- is sufficient to read it.
- The 'm_ref_usage; is incremented under protection by LOCK_mdl_hash, but
- when 'm_destroyed' is set to TRUE, this member is moved to be protected
- by the MDL_lock::lock mutex. This means that the MDL_lock::find_or_insert()
- which only holds the MDL_lock::lock can compare it to 'm_ref_release'
- without acquiring LOCK_mdl_hash again and if equal it can also destroy
- the lock object safely.
- The 'm_ref_release' is incremented under protection by MDL_lock::lock.
- Note since we are only interested in equality of these two counters we
- don't have to worry about overflows as long as their size is big enough
- to hold maximum number of concurrent threads on the system.
- */
- uint m_ref_usage;
- uint m_ref_release;
- bool m_destroyed;
-
public:
/** The key of the object (data) being protected. */
MDL_key key;
/** List of granted tickets for this lock. */
Ticket_list granted;
- /** Tickets for contexts waiting to acquire shared lock. */
+ /** Tickets for contexts waiting to acquire a shared lock. */
Ticket_list waiting_shared;
/**
- Tickets for contexts waiting to acquire exclusive lock.
+ Tickets for contexts waiting to acquire an exclusive lock.
There can be several upgraders and active exclusive
locks belonging to the same context. E.g.
in case of RENAME t1 to t2, t2 to t3, we attempt to
@@ -84,7 +61,7 @@ public:
void *cached_object;
mdl_cached_object_release_hook cached_object_release_hook;
/** Mutex protecting this lock context. */
- pthread_mutex_t lock;
+ pthread_mutex_t m_mutex;
bool is_empty() const
{
@@ -92,6 +69,14 @@ public:
waiting_exclusive.is_empty());
}
+ bool has_pending_exclusive_lock()
+ {
+ bool has_locks;
+ pthread_mutex_lock(&m_mutex);
+ has_locks= ! waiting_exclusive.is_empty();
+ pthread_mutex_unlock(&m_mutex);
+ return has_locks;
+ }
virtual bool can_grant_lock(const MDL_context *requestor_ctx,
enum_mdl_type type, bool is_upgrade) = 0;
virtual void wake_up_waiters() = 0;
@@ -104,24 +89,48 @@ public:
static void destroy_or_delegate_destruction(MDL_lock *lock);
MDL_lock(const MDL_key *key_arg)
- : m_ref_usage(0),
- m_ref_release(0),
- m_destroyed(FALSE),
- key(key_arg),
+ : key(key_arg),
cached_object(NULL),
- cached_object_release_hook(NULL)
+ cached_object_release_hook(NULL),
+ m_ref_usage(0),
+ m_ref_release(0),
+ m_is_destroyed(FALSE)
{
- pthread_mutex_init(&lock, NULL);
+ pthread_mutex_init(&m_mutex, NULL);
}
virtual ~MDL_lock()
{
- pthread_mutex_destroy(&lock);
+ pthread_mutex_destroy(&m_mutex);
}
+private:
+ /**
+ These three members are used to make it possible to separate
+ the LOCK_mdl_hash mutex and MDL_lock::m_mutex in
+ MDL_lock::find_or_insert() for increased scalability.
+ The 'm_is_destroyed' member is only set by destroyers that
+ have both the LOCK_mdl_hash and MDL_lock::m_mutex, thus
+ holding any of the mutexes is sufficient to read it.
+ The 'm_ref_usage; is incremented under protection by
+ LOCK_mdl_hash, but when 'm_is_destroyed' is set to TRUE, this
+ member is moved to be protected by the MDL_lock::m_mutex.
+ This means that the MDL_lock::find_or_insert() which only
+ holds the MDL_lock::m_mutex can compare it to 'm_ref_release'
+ without acquiring LOCK_mdl_hash again and if equal it can also
+ destroy the lock object safely.
+ The 'm_ref_release' is incremented under protection by
+ MDL_lock::m_mutex.
+ Note since we are only interested in equality of these two
+ counters we don't have to worry about overflows as long as
+ their size is big enough to hold maximum number of concurrent
+ threads on the system.
+ */
+ uint m_ref_usage;
+ uint m_ref_release;
+ bool m_is_destroyed;
private:
static bool move_from_hash_to_lock_mutex(MDL_lock *lock);
-
};
@@ -243,7 +252,7 @@ MDL_context::MDL_context()
to empty the list.
*/
m_tickets.empty();
- pthread_cond_init(&m_cond, NULL);
+ pthread_cond_init(&m_ctx_wakeup_cond, NULL);
}
@@ -262,7 +271,7 @@ MDL_context::MDL_context()
void MDL_context::destroy()
{
DBUG_ASSERT(m_tickets.is_empty());
- pthread_cond_destroy(&m_cond);
+ pthread_cond_destroy(&m_ctx_wakeup_cond);
}
@@ -374,7 +383,7 @@ void MDL_lock::destroy(MDL_lock *lock)
/**
- Release LOCK_mdl_hash mutex and lock MDL_lock::lock mutex for lock
+ Release LOCK_mdl_hash mutex and lock MDL_lock::m_mutex for lock
object from the hash. Handle situation when object was released
while the held no mutex.
@@ -385,20 +394,20 @@ void MDL_lock::destroy(MDL_lock *lock)
bool MDL_lock::move_from_hash_to_lock_mutex(MDL_lock *lock)
{
- DBUG_ASSERT(! lock->m_destroyed);
+ DBUG_ASSERT(! lock->m_is_destroyed);
safe_mutex_assert_owner(&LOCK_mdl_hash);
/*
We increment m_ref_usage which is a reference counter protected by
LOCK_mdl_hash under the condition it is present in the hash and
- m_destroyed is FALSE.
+ m_is_destroyed is FALSE.
*/
lock->m_ref_usage++;
pthread_mutex_unlock(&LOCK_mdl_hash);
- pthread_mutex_lock(&lock->lock);
+ pthread_mutex_lock(&lock->m_mutex);
lock->m_ref_release++;
- if (unlikely(lock->m_destroyed))
+ if (unlikely(lock->m_is_destroyed))
{
/*
Object was released while we held no mutex, we need to release
@@ -411,7 +420,7 @@ bool MDL_lock::move_from_hash_to_lock_mu
uint ref_usage, ref_release;
ref_usage= lock->m_ref_usage;
ref_release= lock->m_ref_release;
- pthread_mutex_unlock(&lock->lock);
+ pthread_mutex_unlock(&lock->m_mutex);
if (ref_usage == ref_release)
MDL_lock::destroy(lock);
return TRUE;
@@ -424,7 +433,7 @@ bool MDL_lock::move_from_hash_to_lock_mu
Find MDL_lock object corresponding to the key.
@retval non-NULL - MDL_lock instance for the key with locked
- MDL_lock::lock mutex.
+ MDL_lock::m_mutex.
@retval NULL - There was no MDL_lock for the key.
*/
@@ -454,7 +463,7 @@ retry:
if it does not exist.
@retval non-NULL - Success. MDL_lock instance for the key with
- locked MDL_lock::lock mutex.
+ locked MDL_lock::m_mutex.
@retval NULL - Failure (OOM).
*/
@@ -493,31 +502,33 @@ void MDL_lock::destroy_or_delegate_destr
{
uint ref_usage, ref_release;
- safe_mutex_assert_owner(&lock->lock);
+ safe_mutex_assert_owner(&lock->m_mutex);
if (lock->cached_object)
(*lock->cached_object_release_hook)(lock->cached_object);
/*
- Destroy the MDL_lock object, but ensure that anyone that is holding a
- reference to the object is not remaining, if so he has the responsibility
- to release it.
-
- Setting of m_destroyed to TRUE while holding _both_ LOCK_mdl_hash and
- MDL_lock::lock mutexes transfers the protection of m_ref_usage from
- LOCK_mdl_hash to MDL_lock::lock while removal of object from the hash
- makes it read-only. Therefore whoever acquires MDL_lock::lock next will
- see most up to date version of m_ref_usage.
-
- This means that when m_destroyed is TRUE and we hold the MDL_lock::lock
- mutex we can safely read the m_ref_usage member.
+ Destroy the MDL_lock object, but ensure that anyone that is
+ holding a reference to the object is not remaining, if so he
+ has the responsibility to release it.
+
+ Setting of m_is_destroyed to TRUE while holding _both_
+ LOCK_mdl_hash and MDL_lock::m_mutex mutexes transfers the
+ protection of m_ref_usage from LOCK_mdl_hash to
+ MDL_lock::m_mutex while removal of object from the hash makes
+ it read-only. Therefore whoever acquires MDL_lock::m_mutex next
+ will see most up to date version of m_ref_usage.
+
+ This means that when m_is_destroyed is TRUE and we hold the
+ MDL_lock::m_mutex we can safely read the m_ref_usage
+ member.
*/
pthread_mutex_lock(&LOCK_mdl_hash);
my_hash_delete(&mdl_locks, (uchar *)lock);
- lock->m_destroyed= TRUE;
+ lock->m_is_destroyed= TRUE;
ref_usage= lock->m_ref_usage;
ref_release= lock->m_ref_release;
- pthread_mutex_unlock(&lock->lock);
+ pthread_mutex_unlock(&lock->m_mutex);
if (ref_usage == ref_release)
MDL_lock::destroy(lock);
pthread_mutex_unlock(&LOCK_mdl_hash);
@@ -977,14 +988,15 @@ MDL_context::acquire_lock_impl(MDL_reque
if (! (ticket= MDL_ticket::create(this, mdl_request->type)))
return TRUE;
- /* The below call also implicitly locks MDL_lock::lock mutex. */
+ /* The below call also implicitly locks MDL_lock::m_mutex. */
if (! (lock= MDL_lock::find_or_insert(key)))
{
MDL_ticket::destroy(ticket);
return TRUE;
}
- old_msg= MDL_ENTER_COND(m_thd, mysys_var, &m_cond, &lock->lock);
+ old_msg= MDL_ENTER_COND(m_thd, mysys_var, &m_ctx_wakeup_cond,
+ &lock->m_mutex);
if (! lock->can_grant_lock(this, mdl_request->type, FALSE))
{
@@ -995,7 +1007,7 @@ MDL_context::acquire_lock_impl(MDL_reque
do
{
- pthread_cond_wait(&this->m_cond, &lock->lock);
+ pthread_cond_wait(&m_ctx_wakeup_cond, &lock->m_mutex);
}
while (! lock->can_grant_lock(this, mdl_request->type, FALSE) &&
! mysys_var->abort);
@@ -1007,9 +1019,9 @@ MDL_context::acquire_lock_impl(MDL_reque
as there is a chance that we will destroy MDL_lock object and
won't be able to call MDL_EXIT_COND after it.
*/
- MDL_EXIT_COND(m_thd, mysys_var, &lock->lock, old_msg);
+ MDL_EXIT_COND(m_thd, mysys_var, &lock->m_mutex, old_msg);
- pthread_mutex_lock(&lock->lock);
+ pthread_mutex_lock(&lock->m_mutex);
/* Get rid of pending ticket. */
if (mdl_request->is_shared())
lock->waiting_shared.remove(ticket);
@@ -1020,7 +1032,7 @@ MDL_context::acquire_lock_impl(MDL_reque
else
{
lock->wake_up_waiters();
- pthread_mutex_unlock(&lock->lock);
+ pthread_mutex_unlock(&lock->m_mutex);
}
MDL_ticket::destroy(ticket);
return TRUE;
@@ -1033,7 +1045,7 @@ MDL_context::acquire_lock_impl(MDL_reque
}
lock->granted.push_front(ticket);
- MDL_EXIT_COND(m_thd, mysys_var, &lock->lock, old_msg);
+ MDL_EXIT_COND(m_thd, mysys_var, &lock->m_mutex, old_msg);
ticket->m_state= MDL_ACQUIRED;
ticket->m_lock= lock;
@@ -1146,7 +1158,7 @@ MDL_context::try_acquire_lock_impl(MDL_r
if (!(ticket= MDL_ticket::create(this, mdl_request->type)))
return TRUE;
- /* The below call also implicitly locks MDL_lock::lock mutex. */
+ /* The below call also implicitly locks MDL_lock::m_mutex. */
if (!(lock= MDL_lock::find_or_insert(key)))
{
MDL_ticket::destroy(ticket);
@@ -1156,7 +1168,7 @@ MDL_context::try_acquire_lock_impl(MDL_r
if (lock->can_grant_lock(this, mdl_request->type, FALSE))
{
lock->granted.push_front(ticket);
- pthread_mutex_unlock(&lock->lock);
+ pthread_mutex_unlock(&lock->m_mutex);
ticket->m_state= MDL_ACQUIRED;
ticket->m_lock= lock;
@@ -1169,7 +1181,7 @@ MDL_context::try_acquire_lock_impl(MDL_r
{
/* We can't get here if we allocated a new lock. */
DBUG_ASSERT(! lock->is_empty());
- pthread_mutex_unlock(&lock->lock);
+ pthread_mutex_unlock(&lock->m_mutex);
MDL_ticket::destroy(ticket);
}
@@ -1238,9 +1250,9 @@ MDL_context::clone_ticket(MDL_request *m
ticket->m_lock= mdl_request->ticket->m_lock;
mdl_request->ticket= ticket;
- pthread_mutex_lock(&ticket->m_lock->lock);
+ pthread_mutex_lock(&ticket->m_lock->m_mutex);
ticket->m_lock->granted.push_front(ticket);
- pthread_mutex_unlock(&ticket->m_lock->lock);
+ pthread_mutex_unlock(&ticket->m_lock->m_mutex);
m_tickets.push_front(ticket);
@@ -1325,7 +1337,7 @@ bool MDL_context::acquire_exclusive_lock
if (!(ticket= MDL_ticket::create(this, mdl_request->type)))
return TRUE;
- /* The below call also implicitly locks MDL_lock::lock mutex. */
+ /* The below call also implicitly locks MDL_lock::m_mutex. */
if (!(lock= MDL_lock::find_or_insert(key)))
{
MDL_ticket::destroy(ticket);
@@ -1334,7 +1346,8 @@ bool MDL_context::acquire_exclusive_lock
lock->waiting_exclusive.push_front(ticket);
- old_msg= MDL_ENTER_COND(m_thd, mysys_var, &m_cond, &lock->lock);
+ old_msg= MDL_ENTER_COND(m_thd, mysys_var, &m_ctx_wakeup_cond,
+ &lock->m_mutex);
while (!lock->can_grant_lock(this, mdl_request->type, FALSE))
{
@@ -1349,9 +1362,9 @@ bool MDL_context::acquire_exclusive_lock
lock as there is a chance that we will destroy MDL_lock
object and won't be able to call MDL_EXIT_COND after it.
*/
- MDL_EXIT_COND(m_thd, mysys_var, &lock->lock, old_msg);
+ MDL_EXIT_COND(m_thd, mysys_var, &lock->m_mutex, old_msg);
- pthread_mutex_lock(&lock->lock);
+ pthread_mutex_lock(&lock->m_mutex);
/* Get rid of pending ticket. */
lock->waiting_exclusive.remove(ticket);
if (lock->is_empty())
@@ -1363,7 +1376,7 @@ bool MDL_context::acquire_exclusive_lock
lock which now might be able to do it. Wake them up!
*/
lock->wake_up_waiters();
- pthread_mutex_unlock(&lock->lock);
+ pthread_mutex_unlock(&lock->m_mutex);
}
MDL_ticket::destroy(ticket);
my_error(ER_LOCK_DEADLOCK, MYF(0));
@@ -1394,7 +1407,7 @@ bool MDL_context::acquire_exclusive_lock
*/
struct timespec abstime;
set_timespec(abstime, 1);
- pthread_cond_timedwait(&m_cond, &lock->lock, &abstime);
+ pthread_cond_timedwait(&m_ctx_wakeup_cond, &lock->m_mutex, &abstime);
if (mysys_var->abort)
{
@@ -1403,9 +1416,9 @@ bool MDL_context::acquire_exclusive_lock
as there is a chance that we will destroy MDL_lock object and
won't be able to call MDL_EXIT_COND after it.
*/
- MDL_EXIT_COND(m_thd, mysys_var, &lock->lock, old_msg);
+ MDL_EXIT_COND(m_thd, mysys_var, &lock->m_mutex, old_msg);
- pthread_mutex_lock(&lock->lock);
+ pthread_mutex_lock(&lock->m_mutex);
/* Get rid of pending ticket. */
lock->waiting_exclusive.remove(ticket);
if (lock->is_empty())
@@ -1417,7 +1430,7 @@ bool MDL_context::acquire_exclusive_lock
lock which now might be able to do it. Wake them up!
*/
lock->wake_up_waiters();
- pthread_mutex_unlock(&lock->lock);
+ pthread_mutex_unlock(&lock->m_mutex);
}
MDL_ticket::destroy(ticket);
return TRUE;
@@ -1431,7 +1444,7 @@ bool MDL_context::acquire_exclusive_lock
(*lock->cached_object_release_hook)(lock->cached_object);
lock->cached_object= NULL;
- MDL_EXIT_COND(m_thd, mysys_var, &lock->lock, old_msg);
+ MDL_EXIT_COND(m_thd, mysys_var, &lock->m_mutex, old_msg);
ticket->m_state= MDL_ACQUIRED;
ticket->m_lock= lock;
@@ -1597,11 +1610,12 @@ MDL_ticket::upgrade_shared_lock_to_exclu
if (! (pending_ticket= MDL_ticket::create(m_ctx, MDL_EXCLUSIVE)))
DBUG_RETURN(TRUE);
- pthread_mutex_lock(&m_lock->lock);
+ pthread_mutex_lock(&m_lock->m_mutex);
m_lock->waiting_exclusive.push_front(pending_ticket);
- old_msg= MDL_ENTER_COND(thd, mysys_var, &m_ctx->m_cond, &m_lock->lock);
+ old_msg= MDL_ENTER_COND(thd, mysys_var, &m_ctx->m_ctx_wakeup_cond,
+ &m_lock->m_mutex);
while (1)
{
@@ -1680,7 +1694,8 @@ MDL_ticket::upgrade_shared_lock_to_exclu
*/
struct timespec abstime;
set_timespec(abstime, 1);
- pthread_cond_timedwait(&m_ctx->m_cond, &m_lock->lock, &abstime);
+ pthread_cond_timedwait(&m_ctx->m_ctx_wakeup_cond, &m_lock->m_mutex,
+ &abstime);
if (mysys_var->abort)
{
@@ -1691,7 +1706,7 @@ MDL_ticket::upgrade_shared_lock_to_exclu
shared lock.
*/
m_lock->wake_up_waiters();
- MDL_EXIT_COND(thd, mysys_var, &m_lock->lock, old_msg);
+ MDL_EXIT_COND(thd, mysys_var, &m_lock->m_mutex, old_msg);
MDL_ticket::destroy(pending_ticket);
DBUG_RETURN(TRUE);
}
@@ -1707,7 +1722,7 @@ MDL_ticket::upgrade_shared_lock_to_exclu
(*m_lock->cached_object_release_hook)(m_lock->cached_object);
m_lock->cached_object= 0;
- MDL_EXIT_COND(thd, mysys_var, &m_lock->lock, old_msg);
+ MDL_EXIT_COND(thd, mysys_var, &m_lock->m_mutex, old_msg);
MDL_ticket::destroy(pending_ticket);
@@ -1797,7 +1812,7 @@ bool MDL_context::can_wait_lead_to_deadl
upgradeable shared metadata locks.
Otherwise we would also have to check for the presence of pending
requests for conflicting types of global lock.
- In addition MDL_ticket::has_pending_conflicting_lock_impl()
+ In addition MDL_ticket::has_pending_conflicting_lock()
won't work properly for exclusive type of lock.
*/
DBUG_ASSERT(! ticket->is_upgradable_or_exclusive());
@@ -1878,20 +1893,20 @@ MDL_context::wait_for_locks(MDL_request_
if (mdl_request->is_shared() ||
mdl_request->type == MDL_INTENTION_EXCLUSIVE)
{
- /* The below call also implicitly locks MDL_lock::lock mutex. */
+ /* The below call also implicitly locks MDL_lock::m_mutex. */
if (! (lock= MDL_lock::find(key)))
continue;
if (lock->can_grant_lock(this, mdl_request->type, FALSE))
{
- pthread_mutex_unlock(&lock->lock);
+ pthread_mutex_unlock(&lock->m_mutex);
continue;
}
MDL_ticket *pending_ticket;
if (! (pending_ticket= MDL_ticket::create(this, mdl_request->type)))
{
- pthread_mutex_unlock(&lock->lock);
+ pthread_mutex_unlock(&lock->m_mutex);
return TRUE;
}
if (mdl_request->is_shared())
@@ -1899,18 +1914,19 @@ MDL_context::wait_for_locks(MDL_request_
else
lock->waiting_exclusive.push_front(pending_ticket);
- old_msg= MDL_ENTER_COND(m_thd, mysys_var, &m_cond, &lock->lock);
+ old_msg= MDL_ENTER_COND(m_thd, mysys_var, &m_ctx_wakeup_cond,
+ &lock->m_mutex);
- pthread_cond_wait(&this->m_cond, &lock->lock);
+ pthread_cond_wait(&m_ctx_wakeup_cond, &lock->m_mutex);
/*
We have to do MDL_EXIT_COND here and then re-acquire the lock
as there is a chance that we will destroy MDL_lock object and
won't be able to call MDL_EXIT_COND after it.
*/
- MDL_EXIT_COND(m_thd, mysys_var, &lock->lock, old_msg);
+ MDL_EXIT_COND(m_thd, mysys_var, &lock->m_mutex, old_msg);
- pthread_mutex_lock(&lock->lock);
+ pthread_mutex_lock(&lock->m_mutex);
if (mdl_request->is_shared())
lock->waiting_shared.remove(pending_ticket);
else
@@ -1918,7 +1934,7 @@ MDL_context::wait_for_locks(MDL_request_
if (lock->is_empty())
MDL_lock::destroy_or_delegate_destruction(lock);
else
- pthread_mutex_unlock(&lock->lock);
+ pthread_mutex_unlock(&lock->m_mutex);
MDL_ticket::destroy(pending_ticket);
break;
}
@@ -1952,7 +1968,7 @@ void MDL_context::release_lock(MDL_ticke
if (ticket == m_lt_or_ha_sentinel)
m_lt_or_ha_sentinel= ++Ticket_list::Iterator(m_tickets, ticket);
- pthread_mutex_lock(&lock->lock);
+ pthread_mutex_lock(&lock->m_mutex);
lock->granted.remove(ticket);
@@ -1961,7 +1977,7 @@ void MDL_context::release_lock(MDL_ticke
else
{
lock->wake_up_waiters();
- pthread_mutex_unlock(&lock->lock);
+ pthread_mutex_unlock(&lock->m_mutex);
}
m_tickets.remove(ticket);
@@ -2023,7 +2039,7 @@ void MDL_context::release_locks_stored_b
void MDL_context::release_all_locks_for_name(MDL_ticket *name)
{
- /* Use MDL_ticket::lock to identify other locks for the same object. */
+ /* Use MDL_ticket::m_lock to identify other locks for the same object. */
MDL_lock *lock= name->m_lock;
/* Remove matching lock tickets from the context. */
@@ -2054,7 +2070,7 @@ void MDL_ticket::downgrade_exclusive_loc
if (is_shared())
return;
- pthread_mutex_lock(&m_lock->lock);
+ pthread_mutex_lock(&m_lock->m_mutex);
m_type= MDL_SHARED_UPGRADABLE;
if (! m_lock->waiting_shared.is_empty())
@@ -2065,7 +2081,7 @@ void MDL_ticket::downgrade_exclusive_loc
ticket->get_ctx()->wake_up();
}
- pthread_mutex_unlock(&m_lock->lock);
+ pthread_mutex_unlock(&m_lock->m_mutex);
}
@@ -2162,15 +2178,10 @@ MDL_context::is_lock_owner(MDL_key::enum
bool MDL_ticket::has_pending_conflicting_lock() const
{
- bool result;
-
safe_mutex_assert_not_owner(&LOCK_open);
DBUG_ASSERT(is_shared());
- pthread_mutex_lock(&m_lock->lock);
- result= !m_lock->waiting_exclusive.is_empty();
- pthread_mutex_unlock(&m_lock->lock);
- return result;
+ return m_lock->has_pending_exclusive_lock();
}
=== modified file 'sql/mdl.h'
--- a/sql/mdl.h 2010-01-20 09:20:07 +0000
+++ b/sql/mdl.h 2010-01-20 10:17:29 +0000
@@ -36,7 +36,8 @@ class MDL_ticket;
(because of that their acquisition involves implicit
acquisition of global intention-exclusive lock).
- @see Comments for can_grant_lock() and can_grant_global_lock() for details.
+ @sa Comments for MDL_object_lock::can_grant_lock() and
+ MDL_global_lock::can_grant_lock() for details.
*/
enum enum_mdl_type {MDL_SHARED=0, MDL_SHARED_HIGH_PRIO,
@@ -421,7 +422,7 @@ public:
*/
void wake_up()
{
- pthread_cond_signal(&m_cond);
+ pthread_cond_signal(&m_ctx_wakeup_cond);
}
bool try_acquire_global_intention_exclusive_lock(MDL_request *mdl_request);
@@ -462,7 +463,7 @@ private:
by adding ticket corresponding to the request to an appropriate
queue of waiters).
*/
- pthread_cond_t m_cond;
+ pthread_cond_t m_ctx_wakeup_cond;
private:
MDL_ticket *find_ticket(MDL_request *mdl_req,
bool *is_lt_or_ha);
Attachment: [text/bzr-bundle] bzr/kostja@sun.com-20100120101729-j3t9g0qj0zqbw2x5.bundle
| Thread |
|---|
| • bzr commit into mysql-5.6-next-mr branch (kostja:3057) Bug#38924Bug#46272 | Konstantin Osipov | 20 Jan |