Commit cbf4019a authored by Konstantin Osipov's avatar Konstantin Osipov

A follow up for the previous patch, titled:

A code review comment for Bug#52289.
Encapsulate the deadlock detection functionality into
a visitor class...

Remove a race introduced by omission: 
initialize iterators under a read lock on the object.

sql/mdl.cc:
  Initialize iterators under a read lock on the object.
parent e7854c86
...@@ -1854,15 +1854,16 @@ bool MDL_lock::find_deadlock(MDL_ticket *waiting_ticket, ...@@ -1854,15 +1854,16 @@ bool MDL_lock::find_deadlock(MDL_ticket *waiting_ticket,
MDL_ticket *ticket; MDL_ticket *ticket;
MDL_context *src_ctx= waiting_ticket->get_ctx(); MDL_context *src_ctx= waiting_ticket->get_ctx();
bool result= TRUE; bool result= TRUE;
Ticket_iterator granted_it(m_granted);
Ticket_iterator waiting_it(m_waiting);
if (dvisitor->enter_node(src_ctx)) if (dvisitor->enter_node(src_ctx))
return TRUE; return TRUE;
mysql_prlock_rdlock(&m_rwlock); mysql_prlock_rdlock(&m_rwlock);
/* Must be initialized after taking a read lock. */
Ticket_iterator granted_it(m_granted);
Ticket_iterator waiting_it(m_waiting);
/* /*
We do a breadth-first search first -- that is, inspect all We do a breadth-first search first -- that is, inspect all
edges of the current node, and only then follow up to the next edges of the current node, and only then follow up to the next
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment