There are many Sleep threads executing show processlist in Mysql.

Source: Internet
Author: User

The execution of show processlist in Mysql shows many Sleep threads. Due to Program Design Bugs, there are many Sleep threads in the database currently used in this project. I have found many solutions and have not found any final solutions. You can only use the following method temporarily: Write a shell file, such as killSleepProcess. sh.

[Plain] while: do n = 'mysqladmin-uroot-p *** processlist | grep-I sleep | wc-l 'date = 'date + % Y % m % d \ [% H: % M: % S] 'echo $ n if ["$ n"-gt 10] then for I in 'mysqladmin-uroot-p *** processlist | grep-I sleep | awk '{ print $2} ''do mysqladmin-uroot-p *** kill $ I done echo "sleep is too I killed it">/root/tmp/sleep. log echo "$ date: $ n" >>/ root/tmp/sleep. log fi sleep 120 # Run done once every 120 seconds


The result of the above shell code is: kill all the threads in the Sleep state queried by show processlist.

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: 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.