#At file:///home/dlenev/src/bzr/mysql-trunk-runtime-exp/ based on revid:dlenev@stripped
3002 Dmitry Lenev 2010-03-24
Tentative fix for bug #52289 "performance regression for
MyISAM in sysbench OLTP_RW test".
Improve concurrency in MDL_lock::find_deadlock() method
by trying to reduce time during which MDL_lock::m_rwlock
is held. This is done by avoiding unnecessary iterations
through lists of granted or waiting tickets if we know
that they don't contain tickets conflicting with the one
which wait is being analyzed by this method.
modified:
sql/mdl.cc
=== modified file 'sql/mdl.cc'
--- a/sql/mdl.cc 2010-03-19 10:39:08 +0000
+++ b/sql/mdl.cc 2010-03-24 09:12:49 +0000
@@ -1758,52 +1758,97 @@ bool MDL_lock::find_deadlock(MDL_ticket
mysql_prlock_rdlock(&m_rwlock);
- Ticket_iterator granted_it(m_granted);
- Ticket_iterator waiting_it(m_waiting);
-
- while ((ticket= granted_it++))
+ if (m_granted.bitmap() &
+ incompatible_granted_types_bitmap()[waiting_ticket->get_type()])
{
- if (ticket->is_incompatible_when_granted(waiting_ticket->get_type()) &&
- ticket->get_ctx() != waiting_ticket->get_ctx() &&
- ticket->get_ctx() == deadlock_ctx->start)
+ /*
+ If 'm_granted' list contains tickets which conflict with ticket
+ waiting for the lock we need to iterate through this list and
+ check if any of those tickets belong to the MDL_context from
+ which we has started search for deadlock and thus we have
+ found a deadlock.
+ */
+ Ticket_iterator granted_it(m_granted);
+
+ while ((ticket= granted_it++))
{
- result= TRUE;
- goto end;
+ if (ticket->is_incompatible_when_granted(waiting_ticket->get_type()) &&
+ ticket->get_ctx() != waiting_ticket->get_ctx() &&
+ ticket->get_ctx() == deadlock_ctx->start)
+ {
+ result= TRUE;
+ goto end;
+ }
}
}
- while ((ticket= waiting_it++))
+ if (m_waiting.bitmap() &
+ incompatible_waiting_types_bitmap()[waiting_ticket->get_type()])
{
- if (ticket->is_incompatible_when_waiting(waiting_ticket->get_type()) &&
- ticket->get_ctx() != waiting_ticket->get_ctx() &&
- ticket->get_ctx() == deadlock_ctx->start)
+ /*
+ If 'm_waiting' list contains tickets which conflict with ticket
+ waiting for the lock we need to iterate through this list and
+ check if any of those tickets belong to the MDL_context from
+ which we has started search for deadlock and thus we have
+ found a deadlock.
+ */
+ Ticket_iterator waiting_it(m_waiting);
+
+ while ((ticket= waiting_it++))
{
- result= TRUE;
- goto end;
+ if (ticket->is_incompatible_when_waiting(waiting_ticket->get_type()) &&
+ ticket->get_ctx() != waiting_ticket->get_ctx() &&
+ ticket->get_ctx() == deadlock_ctx->start)
+ {
+ result= TRUE;
+ goto end;
+ }
}
}
- granted_it.rewind();
- while ((ticket= granted_it++))
+ if (m_granted.bitmap() &
+ incompatible_granted_types_bitmap()[waiting_ticket->get_type()])
{
- if (ticket->is_incompatible_when_granted(waiting_ticket->get_type()) &&
- ticket->get_ctx() != waiting_ticket->get_ctx() &&
- ticket->get_ctx()->find_deadlock(deadlock_ctx))
+ /*
+ If 'm_granted' list contains tickets which conflict with ticket
+ waiting for the lock we need to iterate through this list and
+ check if owners of any of those tickets is in their turn waiting
+ for some resource and participate in deadlock.
+ */
+ Ticket_iterator granted_it(m_granted);
+
+ while ((ticket= granted_it++))
{
- result= TRUE;
- goto end;
+ if (ticket->is_incompatible_when_granted(waiting_ticket->get_type()) &&
+ ticket->get_ctx() != waiting_ticket->get_ctx() &&
+ ticket->get_ctx()->find_deadlock(deadlock_ctx))
+ {
+ result= TRUE;
+ goto end;
+ }
}
}
- waiting_it.rewind();
- while ((ticket= waiting_it++))
+ if (m_waiting.bitmap() &
+ incompatible_waiting_types_bitmap()[waiting_ticket->get_type()])
{
- if (ticket->is_incompatible_when_waiting(waiting_ticket->get_type()) &&
- ticket->get_ctx() != waiting_ticket->get_ctx() &&
- ticket->get_ctx()->find_deadlock(deadlock_ctx))
+ /*
+ If 'm_waiting' list contains tickets which conflict with ticket
+ waiting for the lock we need to iterate through this list and
+ check if owners of any of those tickets is in their turn waiting
+ for some resource and participate in deadlock.
+ */
+ Ticket_iterator waiting_it(m_waiting);
+
+ while ((ticket= waiting_it++))
{
- result= TRUE;
- goto end;
+ if (ticket->is_incompatible_when_waiting(waiting_ticket->get_type()) &&
+ ticket->get_ctx() != waiting_ticket->get_ctx() &&
+ ticket->get_ctx()->find_deadlock(deadlock_ctx))
+ {
+ result= TRUE;
+ goto end;
+ }
}
}
Attachment: [text/bzr-bundle] bzr/dlenev@mysql.com-20100324091249-s7r8k6iwaistsfsj.bundle
Thread |
---|
• bzr commit into mysql-trunk-bugfixing branch (dlenev:3002) Bug#52289 | Dmitry Lenev | 24 Mar |