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 相互交流
版本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 相互交流
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25099483/viewspace-1985342/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Waiting for table metadata lockAI
- MySQL新增索引偶遇waiting for table metadata lockMySql索引AI
- MySQL DDL Waiting for table metadata lock 解決MySqlAI
- MySQL 5.6 drop database時,table metadata lock等待MySqlDatabase
- MySQL:Analyze table導致'waiting for table flush'MySqlAI
- create a partition table using a exsit table
- create table of mysql databaseMySqlDatabase
- Oracle Create Table as SelectOracle
- MySQL5.7 Waiting FOR TABLE FLUSHMySqlAI
- Unable to create index.lock File exists錯誤Index
- enable table lock 的enqueue等待ENQ
- Kettle Table Exists控制元件優化控制元件優化
- MySQL5.6 create table原理分析MySql
- sqlserver不能直接create table as select ......SQLServer
- create table進階學習(一)
- create table進階學習(三)
- create table進階學習(四)
- 【MySQL】select for update 的Row Lock 與Table LockMySql
- Waiting for table阻塞查詢的問題AI
- beego報錯 table name: `xxx` not existsGo
- Query to Check SP/Table/Trigger Exists in Database or notDatabase
- MySQL的create table as 與 like區別MySql
- VBA從Excel中生成Oracle create tableExcelOracle
- create table進階學習系列(八)
- create table進階學習系列(五)
- create table進階學習系列(七)
- create table進階學習系列(九)
- CREATE TABLE AS SELECT(CAST)(二)-ConceptAST
- create table進階學習(二)_全域性臨時表_global temporary table
- Oracle blocking issue with lock table in exclusive modeOracleBloC
- 【DB】Direct Path EXP Corrupts The Dump If An Empty Table Partition Exists
- Get detailed table(many other objects) structure with dbms_metadataAIObjectStruct
- use azure data studio to create external table for oracleOracle
- create table之storage選項initial和其它
- T-SQL的CREATE TABLE語法(下)SQL
- T-SQL的CREATE TABLE語法(上)SQL
- v$lock之alter table drop column與alter table set unused column區別系列五
- oracle 19c 無法create table解決Oracle