summaryrefslogtreecommitdiff
path: root/mysql-test/r/mdl_sync.result
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
commit96344befd355da789f206f81e228eb03828ce462 (patch)
tree6c8f7502b8b58b23eb754e7a3508781afa2d9436 /mysql-test/r/mdl_sync.result
parent7dc5666c6be292e8b88f0112c2fd16e0e78b03f0 (diff)
downloadmariadb-git-96344befd355da789f206f81e228eb03828ce462.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. mysql-test/r/mdl_sync.result: Added test for bug #50998 "Deadlock in MDL code during test rqg_mdl_stability" as well as coverage for the case when addition of statement waiting for metadata lock adds several loops in the waiters graph and therefore several searches for deadlock should be performed by MDL deadlock detector. mysql-test/t/mdl_sync.test: Added test for bug #50998 "Deadlock in MDL code during test rqg_mdl_stability" as well as coverage for the case when addition of statement waiting for metadata lock adds several loops in the waiters graph and therefore several searches for deadlock should be performed by MDL deadlock detector. sql/mdl.cc: Ensure that in cases when MDL deadlock detector had to perform several searches for deadlock because several loops in waiters graph are possible we reset Deadlock_detection_context before performing each 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 (no one was able to acquire write lock on it anymore).
Diffstat (limited to 'mysql-test/r/mdl_sync.result')
-rw-r--r--mysql-test/r/mdl_sync.result53
1 files changed, 53 insertions, 0 deletions
diff --git a/mysql-test/r/mdl_sync.result b/mysql-test/r/mdl_sync.result
index 1e88d2ad27a..299df47b409 100644
--- a/mysql-test/r/mdl_sync.result
+++ b/mysql-test/r/mdl_sync.result
@@ -2322,3 +2322,56 @@ set debug_sync= 'now SIGNAL go';
# Reaping TRUNCATE TABLE.
set debug_sync= 'RESET';
drop table t1;
+#
+# Test for bug #50998 "Deadlock in MDL code during test
+# rqg_mdl_stability".
+# Also provides coverage for the case when addition of
+# waiting statement adds several loops in the waiters
+# graph and therefore several searches for deadlock
+# should be performed.
+drop table if exists t1;
+set debug_sync= 'RESET';
+create table t1 (i int);
+# Switching to connection 'con1'.
+begin;
+select * from t1;
+i
+# Switching to connection 'con2'.
+begin;
+select * from t1;
+i
+# Switching to connection 'default'.
+# Start ALTER TABLE which will acquire SNW lock and
+# table lock and get blocked on sync point.
+set debug_sync= 'thr_multi_lock_after_thr_lock SIGNAL parked WAIT_FOR go';
+# Sending:
+alter table t1 add column j int;
+# Switching to connection 'con1'.
+# Wait until ALTER TABLE gets blocked on a sync point.
+set debug_sync= 'now WAIT_FOR parked';
+# Sending:
+insert into t1 values (1);
+# Switching to connection 'con2'.
+# Sending:
+insert into t1 values (1);
+# Switching to connection 'con3'.
+# Wait until both 'con1' and 'con2' are blocked trying to acquire
+# SW lock on the table.
+# Unblock ALTER TABLE. Since it will try to upgrade SNW to X lock
+# deadlock with two loops in waiting graph will occur. Both loops
+# should be found and DML statements in both 'con1' and 'con2'
+# should be aborted with ER_LOCK_DEADLOCK errors.
+set debug_sync= 'now SIGNAL go';
+# Switching to connection 'con1'.
+# Reaping INSERT. It should end with ER_LOCK_DEADLOCK error and
+# not wait indefinitely (as it happened before the bugfix).
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+commit;
+# Switching to connection 'con2'.
+# Reaping INSERT.
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+commit;
+# Switching to connection 'default'.
+# Reap ALTER TABLE.
+set debug_sync= 'RESET';
+drop table t1;