Description:
The metadata locking description in the MySQL manual does not list LOCK TABLES statement as been affected by the MDL locks. It only lists DDL statements.
A LOCK TABLES statement also waits on MDL locks acquired by a transaction or a running query and should be listed in the manual page.
How to repeat:
-- session 1
CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` varchar(1000) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
mysql [localhost] {msandbox} (test) > start transaction;
Query OK, 0 rows affected (0.00 sec)
mysql [localhost] {msandbox} (test) > select * from t1;
...
2 rows in set (0.00 sec)
-- session 2
mysql [localhost] {msandbox} (test) > lock tables t1 write;
-- session 3
mysql [localhost] {msandbox} (test) > select * from t1;
-- session 4
mysql [localhost] {msandbox} (test) > show processlist;
+----+----------+-----------+------+---------+------+---------------------------------+----------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+----------+-----------+------+---------+------+---------------------------------+----------------------+
| 1 | msandbox | localhost | test | Sleep | 125 | | NULL |
| 2 | msandbox | localhost | test | Query | 101 | Waiting for table metadata lock | lock tables t1 write |
| 3 | msandbox | localhost | test | Query | 14 | Waiting for table metadata lock | select * from t1 |
| 4 | msandbox | localhost | test | Query | 0 | NULL | show processlist |
+----+----------+-----------+------+---------+------+---------------------------------+----------------------+
4 rows in set (0.00 sec)