I have problem with lock table command: LOCK TABLE v3_cam_date WRITE;
the command always running with state: "Waiting for table metadata lock"
.
Try to find out which thread was hold the lock on the table v3_cam_date by using command:
SHOW OPEN TABLES FROM reportingdb
LIKE '%v3_cam_date';
Database Table In_use Name_locked
reportingdb v3_cam_date 0 0
(In_use=0 => have no any lock on the table).
And I can't get write lock only on the table v3_cam_date while can get write lock on other tables.
Try to SHOW FULL PROCESSLIST;
return about 30 thread with idle state.
- Detail List
- InnoDB Status
- MySQL : 5.5.13
- Engine: InnoDB
Thanks,
Best Answer
According to the MySQL Documentation on MetaData Locking
Somone submitted this state as a bug, but the bug report claims it is not a bug.
Both of these links describe DDL (Data Definition Language) against a table as a contributing factor. What is interesting to keep in mind is that doing something like
TRUNCATE TABLE
is, in reality, DDL. We have to aware of any SQL we run. We may think it is SQL that is part of a transaction when, in fact, it is DDL.TRUNCATE TABLE
is an example of DDL we think is DML. This can cause current transactions to commit and may have unpredictable results when it comes to writing binary log events as the first link states: