Sleep Process Thread in MySQL

  • Avinash
  • 2
  • Nov 13, 2011
  • Database

While working with the MySQL Administrator, You can see the list of all connections.

Have you checked the different status of the each connections?

You might get some connections which the status sleep.
MySQL Sleep Thread

Reason for This Connection Status

The reason for getting this type of connection is the MySQL Persistent Connection. So whenever you open the database connection in persistent mode, it will remain open untill some defined time limit.

At this state that database connection will display as status in sleep.

Within this time limit if another user tries to open the connection with same credentials, it will use that connection in sleep mode and connection will become active again.

Default time for leave this connection open is 28,800 seconds. This time can be defined in the configuration file of the mysql as below.

wait_timeout=15 connect_timeout=10 interactive_timeout=100
  wait_timeout=15
  connect_timeout=10
  interactive_timeout=100

Remove Sleep Process Thread

To remove any thread in sleep mode, you will need a process ID for thread. You can get this process ID using show processlists; query.

After getting process ID you can use kill command to kill the database connection.

kill processid
  kill processid

Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by: