MySQL Kill (Kill) lock Process script

Source: Internet
Author: User

The quickest way to kill the lock process is to restart MySQL, like in your case, with more than 1000 SQL locked, preferably a reboot
If I do not allow a restart, I provide a shell script that generates a Kill ID command to kill the lock thread, as follows:
------------------------------------
#!/bin/bash
Mysql-u root-e "Show processlist" |grep-i "Locked" >> locked.txt;
For line in awk ' {print '} ' locked.txt
Do
echo "Kill $line;" >>kill_lock.sql
Done
----------------------------------

After executing the script, a kill_lock.sql file is generated that resembles the following:

Kill 1;
Kill 2;
Kill 3;
-------------------These are the lock SessionID, directly copy the contents of the file, and then execute it in MySQL OK.

As for which SQL to troubleshoot, this is a bit difficult, but you can try to turn on slow log and no index logs to confirm more time-consuming queries and avoid clogging again

MySQL Kill (Kill) lock Process script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.