温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

create table if not exists Waiting for table metadata lock

发布时间:2020-08-07 15:54:23 来源:ITPUB博客 阅读:194 作者:psufnxk2000 栏目:MySQL数据库
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 相互交流
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI