1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Patch that changes metadata locking subsystem to use mutex per lock and

condition variable per context instead of one mutex and one conditional
variable for the whole subsystem.

This should increase concurrency in this subsystem.

It also opens the way for further changes which are necessary to solve
such bugs as bug #46272 "MySQL 5.4.4, new MDL: unnecessary deadlock"
and bug #37346 "innodb does not detect deadlock between update and alter
table".

Two other notable changes done by this patch:

- MDL subsystem no longer implicitly acquires global intention exclusive
  metadata lock when per-object metadata lock is acquired. Now this has
  to be done by explicit calls outside of MDL subsystem.
- Instead of using separate MDL_context for opening system tables/tables
  for purposes of I_S we now create MDL savepoint in the main context
  before opening tables and rollback to this savepoint after closing
  them. This means that it is now possible to get ER_LOCK_DEADLOCK error
  even not inside a transaction. This might happen in unlikely case when
  one runs DDL on one of system tables while also running DDL on some
  other tables. Cases when this ER_LOCK_DEADLOCK error is not justified
  will be addressed by advanced deadlock detector for MDL subsystem which
  we plan to implement.
This commit is contained in:
Dmitry Lenev
2010-01-21 23:43:03 +03:00
parent c005126107
commit a63f8480db
24 changed files with 1595 additions and 848 deletions

View File

@ -78,7 +78,7 @@ SET DEBUG_SYNC= 'RESET';
--echo # locking subsystem.
--echo #
--disable_warnings
drop tables if exists t1, t2, t3, t4;
drop tables if exists t0, t1, t2, t3, t4, t5;
--enable_warnings
connect(deadlock_con1,localhost,root,,);
@ -189,7 +189,7 @@ connection default;
--echo # Switching to connection 'deadlock_con1'.
connection deadlock_con1;
begin;
insert into t1 values (2);
insert into t2 values (2);
--echo #
--echo # Switching to connection 'default'.
@ -201,7 +201,7 @@ connection default;
--echo # Switching to connection 'deadlock_con1'.
connection deadlock_con1;
--echo # Wait until the above RENAME TABLE is blocked because it has to wait
--echo # for 'deadlock_con1' which holds shared metadata lock on 't1'.
--echo # for 'deadlock_con1' which holds shared metadata lock on 't2'.
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "rename table t2 to t0, t1 to t2, t0 to t1";
@ -210,7 +210,7 @@ let $wait_condition=
--echo # The below statement should not wait as doing so will cause deadlock.
--echo # Instead it should fail and emit ER_LOCK_DEADLOCK statement.
--error ER_LOCK_DEADLOCK
select * from t2;
select * from t1;
--echo #
--echo # Let us check that failure of the above statement has not released
@ -276,7 +276,7 @@ let $wait_condition=
--echo # Send RENAME TABLE statement that will deadlock with the
--echo # SELECT statement and thus should abort the latter.
--send rename table t1 to t0, t2 to t1, t0 to t2;
--send rename table t1 to t5, t2 to t1, t5 to t2;
--echo #
--echo # Switching to connection 'deadlock_con1'.
@ -294,17 +294,11 @@ connection deadlock_con1;
--echo # is blocked.
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "rename table t1 to t0, t2 to t1, t0 to t2";
where state = "Waiting for table" and info = "rename table t1 to t5, t2 to t1, t5 to t2";
--source include/wait_condition.inc
--echo # Commit transaction to unblock this RENAME TABLE.
commit;
--echo #
--echo # Switching to connection 'deadlock_con3'.
connection deadlock_con3;
--echo # Reap RENAME TABLE t1 TO t0 ... .
--reap;
--echo #
--echo # Switching to connection 'deadlock_con2'.
connection deadlock_con2;
@ -317,6 +311,16 @@ connection default;
--echo # Reap RENAME TABLE t2 TO t0 ... .
--reap
--echo #
--echo # Switching to connection 'deadlock_con3'.
connection deadlock_con3;
--echo # Reap RENAME TABLE t1 TO t5 ... .
--reap;
--echo #
--echo # Switching to connection 'default'.
connection default;
drop tables t1, t2, t3, t4;
--echo #