开发者

What steps should i follow to find the root cause of a table getting locked in mysql?

One of the table in mysql DB is getting locked. Please let me know the steps that i s开发者_高级运维hould follow to find the root cause behind it i.e. who is locking the table and when ?

Thanks, Sachin


First, check that the table is locked - does it appear in the results of:

mysql> SHOW OPEN TABLES WHERE in_use;

If it is currently locked, from the command line, run:

# mysqladmin debug -u <user> -p 

(<user> is most likely root, depending on your set-up)

Now check your error log (this is inside the data directory by default, find the location by checking your my.cnf file). You should find details of the process doing the locking.

The relevant bit of the output looks like:

Current locks:
lock: 0x7f759da38e90: write
write     : 0x7f759da97a00 (54:12);

From within the database (with a user with the SUPER privilege) run SHOW PROCESSLIST to find out which session the logs are referring to. In the example above, you want the process ID 54 (identified by the (54:12)).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜