diff options
-rw-r--r-- | sql/mdl.cc | 9 | ||||
-rw-r--r-- | sql/mdl.h | 5 |
2 files changed, 11 insertions, 3 deletions
diff --git a/sql/mdl.cc b/sql/mdl.cc index 1990ce2800b..fe9f4053e67 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -838,6 +838,12 @@ void MDL_lock::Ticket_list::clear_bit_if_not_in_list(enum_mdl_type type) void MDL_lock::Ticket_list::add_ticket(MDL_ticket *ticket) { + /* + Ticket being added to the list must have MDL_ticket::m_lock set, + since for such tickets methods accessing this member might be + called by other threads. + */ + DBUG_ASSERT(ticket->get_lock()); m_list.push_front(ticket); m_bitmap|= MDL_BIT(ticket->get_type()); } @@ -1317,11 +1323,10 @@ MDL_context::try_acquire_lock(MDL_request *mdl_request) if (lock->can_grant_lock(mdl_request->type, this)) { + ticket->m_lock= lock; lock->m_granted.add_ticket(ticket); rw_unlock(&lock->m_rwlock); - ticket->m_lock= lock; - m_tickets.push_front(ticket); mdl_request->ticket= ticket; diff --git a/sql/mdl.h b/sql/mdl.h index 848c446496f..d560f38ce0a 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -397,6 +397,7 @@ public: m_type == MDL_EXCLUSIVE; } enum_mdl_type get_type() const { return m_type; } + MDL_lock *get_lock() const { return m_lock; } void downgrade_exclusive_lock(enum_mdl_type type); bool has_stronger_or_equal_type(enum_mdl_type type) const; @@ -423,7 +424,9 @@ private: */ MDL_context *m_ctx; - /** Pointer to the lock object for this lock ticket. Context private. */ + /** + Pointer to the lock object for this lock ticket. Externally accessible. + */ MDL_lock *m_lock; private: |