Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Create table if not exists Waiting for table metadata lock

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Create table if not exists Waiting for table metadata lock

Version mysql 5.5

Phenomenon:

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)

No lock found.

Reproduce:

Session 1:

Create table a (id int) engine=myisam

Begin

Select * from a

Session2:

Create table if not exists a like t

.... Wait.

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)

If table an is defined as innodb, the record can be queried through select * from information_schema.innodb_trx\ G

In addition:

Version 5.6 does not have this problem.

Please indicate the source of the reprint.

QQ 273002188 Welcome to study together.

QQ group 236941212

Oracle,mysql,mongo communicate with each other

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report