create table if not exists Waiting for table metadata lock

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 相互交流

相关文章

这篇文章主要介绍“hive和mysql的区别是什么”,在日常操作中...
这篇“MySQL数据库如何改名”文章的知识点大部分人都不太理解...
这篇文章主要介绍“mysql版本查询命令是什么”的相关知识,小...
本篇内容介绍了“mysql怎么修改字段的内容”的有关知识,在实...
这篇文章主要讲解了“mysql怎么删除unique约束”,文中的讲解...
今天小编给大家分享一下mysql怎么查询不为空的字段的相关知识...