Home >Database >Mysql Tutorial >MySQLMDL与存储引擎相关吗?_MySQL

MySQLMDL与存储引擎相关吗?_MySQL

WBOY
WBOYOriginal
2016-06-01 13:04:15966browse

背景是某个业务的logdb历史oss_log(MyISAM表类型)例行删除,有时候会告"deadlock"。分析slow log发现有些删除需要很长时间,比如:drop table 2014_10_17_oss_abandonquest 花费了15041.2410秒。删除行为在凌晨4点发出,刚好落在备份期间,因为5.5有了MDL(Meta data lock),所以–single-transaction时,事务内操作过的表都会持有MDL,因此不会被DDL破坏。所以,查看get_status.err会有如下日志:
11966363,hardcore,localhost,oss_log,Query,11084,Waiting for table metadata lock,drop table 2014_10_17_oss_abandonquest

5.5的MDL机制是如果事务不释放,事务里边涉及到的表都会持有该表的DML锁,事务不释放,锁就不释放。而5.0、5.1的MDL机制与事务无关,只要语句结束,语句持有的MDL锁就会释放。这是两者的区别,确实该表引擎没关系。

下面是个测试:

session.1 session.2
Step.1 begin;
Step.2 select * from tb_myisam;
Step.3 drop table tb_myisam;
被阻塞…
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn