mysql AWS 性能监控案例 Waiting for table metadata lock

来源:互联网 发布:java redis面试题 编辑:程序博客网 时间:2024/04/30 03:41

最近项目迁移到亚马逊上,同时把mysql从5.1升级到了5.7

数据库常常突然内存飙升 导致系统死机。

在询问了某个靠谱的dba之后,在网上找了jetprofiler来监控数据库当机前发生了什么。

www.jetprofiler.com



抓到了这样一个sql

locklock tables t write

通过full processlist,发现这个查询myisam table的query status是 Waiting for table metadata lock

59965   xxxx AAA.BBB.CCC.DDD:PPP      xxxx Query   305     Waiting for table metadata lock lock tables t write

同时还发现这样的thread有很多,反复在Waiting for table metadata lock opening tables之间切换

https://dev.mysql.com/doc/refman/5.7/en/general-thread-states.html

Opening tables

The thread is trying to open a table. This is should be veryfast procedure, unless something prevents opening. For example, an ALTER TABLE or a LOCKTABLE statementcan prevent opening a table until the statement is finished. It is also worthchecking that your table_open_cache value is large enough.

 

http://dev.mysql.com/doc/refman/5.7/en/metadata-locking.html

http://blog.itpub.net/25704976/viewspace-1379568/


MySQL5.5.3 and up uses metadata locking to manage concurrent access to databaseobjects and to ensure data consistency. Metadata locking applies not just totables, but also to schemas and stored programs (procedures, functions,triggers, and scheduled events).


由于myisam是表级锁,所以移除lock table语句 避免触发metadata lock机制。

目前数据库平稳运行超过48小时。

存疑:

myisam 的表会导致 innodb disk IO上升??


0 0
原创粉丝点击