Too Many MySQL Sleep Processes

I’ve been using the CodeIgniter PHP framework to develop a web site that connects to a MySQL database using InnoDB tables and transactions. I ran into some trouble when I filled the MySQL process list with entries with “Sleep” in the command column. This happened even if I was rendering a page that only required reading from the database (and not using transactions). Solutions on the Internet suggesting that I should reduce the MySQL wait_timeout value to 3 seconds (from a setting of 28,800 seconds) or increasing the number of allowed connections didn’t ring true. A post on the MySQL Performance Blog pointed me in the right direction. Apparently, persistent connections do not currently play nice with transactions and InnoDB. The fix was to set the $db['default']['pconnect'] value to FALSE in the CodeIgniter database configuration file (application/config/database.php).

Leave a Reply