我的 MySQL 数据库提供三个 webapps 作为存储后端。但是我最近经常遇到错误“等待表元数据锁定”。它几乎一直在发生,我不明白为什么。
mysql> show processlist
-> ;
+------+-----------+-----------------+------------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+------+-----------+-----------------+------------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| 36 | root | localhost:33444 | bookmaker2 | Sleep | 139 | | NULL |
| 37 | root | localhost:33445 | bookmaker2 | Sleep | 139 | | NULL |
| 38 | root | localhost:33446 | bookmaker2 | Sleep | 139 | | NULL |
| 39 | root | localhost:33447 | bookmaker2 | Sleep | 49 | | NULL |
| 40 | root | localhost:33448 | bookmaker2 | Sleep | 139 | | NULL |
| 1315 | bookmaker | localhost:34869 | bookmaker | Sleep | 58 | | NULL |
| 1316 | root | localhost:34874 | bookmaker3 | Sleep | 56 | | NULL |
| 1395 | bookmaker | localhost:34953 | bookmaker | Sleep | 58 | | NULL |
| 1396 | root | localhost:34954 | bookmaker3 | Sleep | 46 | | NULL |
| 1398 | root | localhost:34956 | bookmaker3 | Query | 28 | Waiting for table metadata lock | CREATE TABLE IF NOT EXISTS LogEntries (
lid INT NOT NULL AUTO_INCREMEN |
| 1399 | root | localhost | NULL | Query | 0 | NULL | show processlist |
+------+-----------+-----------------+------------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
当然可以杀死相应的进程。但是,如果我重新启动尝试创建数据库“bookmaker3”的表结构的程序,则新创建的进程再次以金属锁结束。
我什至不能删除数据库:
mysql> drop database bookmaker3;
这也产生了一个金属锁。
如何修复?