Bug #102993 The connection is stuck, the connection state is "Waiting for schema metadata l
Submitted: 16 Mar 2021 7:21 Modified: 16 Mar 2021 13:36
Reporter: shangshang yu Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[16 Mar 2021 7:21] shangshang yu
Description:
Execute following queries, will cause new connection stuck.

session A:

create database test;
create table t1(a int);
lock table t1 write;

session B:
create database test; // the query is stuck

now connect mysql with database test, the connection is stuck:
mysql -uroot -p123456 -h127.0.0.1 -P3306 test

see Id 126

MySQL [information_schema]> show processlist;
+-----+-----------------+-----------------+--------------------+----------+-------+----------------------------------+----------------------+
| Id  | User            | Host            | db                 | Command  | Time  | State                            | Info                 |
+-----+-----------------+-----------------+--------------------+----------+-------+----------------------------------+----------------------+
|   5 | event_scheduler | localhost       | NULL               | Daemon   | 12583 | Waiting on empty queue           | NULL                 |
|   8 | root            | localhost:50266 | NULL               | Sync msg | 12582 | starting                         | NULL                 |
| 123 | root            | localhost:47044 | information_schema | Query    |     0 | init                             | show processlist     |
| 124 | root            | localhost:55510 | NULL               | Query    |   388 | Waiting for schema metadata lock | create database test |
| 125 | root            | localhost:55540 | test               | Sleep    |   391 |                                  | NULL                 |
| 126 | root            | localhost:55594 | NULL               | Connect  |   363 | Waiting for schema metadata lock | NULL                 |
+-----+-----------------+-----------------+--------------------+----------+-------+----------------------------------+----------------------+

How to repeat:
see Description
[16 Mar 2021 13:36] MySQL Verification Team
Hi Mr. yu

Thank you for your bug report.

However, this is not a bug. This is exactly how our MDL locks are designed to work.

Not a bug.