create table if not exists Waiting for table metadata lock
短信预约 -IT技能 免费直播动态提醒
create table if not exists Waiting for table metadata lock
版本mysql 5.5
现象:
mysql> show full processlist;
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
| 1 | event_scheduler | localhost | NULL | Daemon | 1661254 | Waiting on empty queue | NULL |
| 4 | root | localhost | test | Query | 13 | Waiting for table metadata lock | create table if not exists a like t |
| 5 | root | localhost | test | Sleep | 32 | | NULL |
| 7 | root | localhost | NULL | Query | 0 | NULL | show full processlist |
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
mysql> select * from information_schema.innodb_trx \G
Empty set (0.00 sec)
查不到锁。
重现:
session 1:
create table a (id int) engine=myisam;
begin;
select * from a;
session2 :
create table if not exists a like t;
....等待.....
session 3 :
mysql> show full processlist;
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
| 1 | event_scheduler | localhost | NULL | Daemon | 1661796 | Waiting on empty queue | NULL |
| 5 | root | localhost | test | Sleep | 51 | | NULL |
| 7 | root | localhost | NULL | Query | 0 | NULL | show full processlist |
| 10 | root | localhost | test | Query | 40 | Waiting for table metadata lock | create table if not exists a like t |
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
4 rows in set (0.00 sec)
mysql> select * from information_schema.innodb_trx \G
Empty set (0.00 sec)
如果a表的定义是innodb,就可以通过 select * from information_schema.innodb_trx \G 查询到记录
另:
5.6版本没有这个问题。
转载请注明源出处
QQ 273002188 欢迎一起学习
QQ 群 236941212
oracle,mysql,mongo 相互交流
版本mysql 5.5
现象:
mysql> show full processlist;
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
| 1 | event_scheduler | localhost | NULL | Daemon | 1661254 | Waiting on empty queue | NULL |
| 4 | root | localhost | test | Query | 13 | Waiting for table metadata lock | create table if not exists a like t |
| 5 | root | localhost | test | Sleep | 32 | | NULL |
| 7 | root | localhost | NULL | Query | 0 | NULL | show full processlist |
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
mysql> select * from information_schema.innodb_trx \G
Empty set (0.00 sec)
查不到锁。
重现:
session 1:
create table a (id int) engine=myisam;
begin;
select * from a;
session2 :
create table if not exists a like t;
....等待.....
session 3 :
mysql> show full processlist;
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
| 1 | event_scheduler | localhost | NULL | Daemon | 1661796 | Waiting on empty queue | NULL |
| 5 | root | localhost | test | Sleep | 51 | | NULL |
| 7 | root | localhost | NULL | Query | 0 | NULL | show full processlist |
| 10 | root | localhost | test | Query | 40 | Waiting for table metadata lock | create table if not exists a like t |
+----+-----------------+-----------+------+---------+---------+---------------------------------+-------------------------------------+
4 rows in set (0.00 sec)
mysql> select * from information_schema.innodb_trx \G
Empty set (0.00 sec)
如果a表的定义是innodb,就可以通过 select * from information_schema.innodb_trx \G 查询到记录
另:
5.6版本没有这个问题。
转载请注明源出处
QQ 273002188 欢迎一起学习
QQ 群 236941212
oracle,mysql,mongo 相互交流
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341