If you’re still running an older version of Pligg (pre-Beta 9.5) and you get a spike in traffic, it could bring your MySQL server down. The fix is easy. Here’s how.
Note: If you’re running Pligg Beta 9.5 or later, you don’t need to worry about this. I’m writing this up to help you avoid the head scratching I just went through.
A Little Background
After getting a bump in traffic on the Upstart Blogger Grapevine after my post about the Upstart Blogger One Pligg template, I was greeted with this error message when I went to look at my Mint stats:
MySQL Error: User [name] has already more than ‘max_user_connections’ active connections.
Refreshing the page a few minutes later, everything was fine. But since all of my domains run WordPress or Pligg, both of which rely on MySQL, and MySQL had too many connections, there was a good chance you were greeted by a similar error page if you tried to visit one of my sites this morning.
At first I thought it was a problem with my host, AN Hosting. But when I submitted a ticket, I got this message from Dmitry in support:
Dear customer, the problem is your scripts use pconnect() function instead of connect one. Your scripts open connections and don’t close them. That is why there are a lot connections even from scripts that were executed 1 hour ago.
I increased your maximum connections to allow your site working perfectly. Please chek and please use connect() function to avoid such problem in the future.
Great. But how to find the offending script? I searched within all my WordPress files and plugins, then all the files in the latest Pligg version, Beta 9.5. Nothing. I sent Dmitry an email asking for help. He identified the problem in the Upstart Blogger Grapevinedatabase which, I remembered, is running an older version of Pligg. I ran a quick search on all the files and found the culprit in /libs/db.php.
The Fix
The fix is simple. Open /libs/db.php in your Pligg installation (remember, if you’re running Pligg Beta 9.5 or later, you don’t need to worry about this), and find the offending line near the top of the file:
$globals['mysql_persistent'] = true;
Then, set persistent=false.
You’ll find more about this in the Pligg forums in Overload request of mysql? and in Should one use true or false for mysql_persistent? (There’s nothing if you do a search for pconnect).
For more about pconnect and connect, see PHPFAQ.








One Trackback
One Comment
Post your articles on http://www.bestofindya.com