summaryrefslogtreecommitdiff
path: root/sql/mdl.cc
diff options
context:
space:
mode:
authorDmitry Lenev <dlenev@mysql.com>2010-02-10 18:46:03 +0300
committerDmitry Lenev <dlenev@mysql.com>2010-02-10 18:46:03 +0300
commitf229ac073ab52741b3660b468f2ed4aba4e27adf (patch)
tree6c8f7502b8b58b23eb754e7a3508781afa2d9436 /sql/mdl.cc
parent73ef80f47cd4eda0b93b0f532846a8e16e021699 (diff)
downloadmariadb-git-f229ac073ab52741b3660b468f2ed4aba4e27adf.tar.gz
Fix for bug #50998 "Deadlock in MDL code during test
rqg_mdl_stability". When start of statement's waiting on a metadata lock created more than one loop in waiters graph server might have entered deadlock condition. The problem was that in the case described above MDL deadlock detector had to perform several searches for deadlock but forgot to reset Deadlock_detection_context before performing new search. Failure to do so has broken assumption in code resposible for choosing victim that if Deadlock_detection_context::victim is set we also have read lock on m_waiting_for_lock for this context. As result this lock could have been unlocked more times than it was acquired which corrupted rwlock's state which led to server deadlock. This fix ensures that such reset is done before each attempt to find a deadlock.
Diffstat (limited to 'sql/mdl.cc')
-rw-r--r--sql/mdl.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/mdl.cc b/sql/mdl.cc
index 54931f89e40..e48ae8a3f59 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -1755,10 +1755,15 @@ bool MDL_context::find_deadlock(Deadlock_detection_context *deadlock_ctx)
bool MDL_context::find_deadlock()
{
- Deadlock_detection_context deadlock_ctx(this);
-
while (1)
{
+ /*
+ The fact that we use fresh instance of deadlock_ctx for each
+ search performed by find_deadlock() below is important, code
+ responsible for victim selection relies on this.
+ */
+ Deadlock_detection_context deadlock_ctx(this);
+
if (! find_deadlock(&deadlock_ctx))
{
/* No deadlocks are found! */