Home     Articles & Projects     Products & Web Services     Forum

Connections not closing in MYSQL

Hello David,

Just wondering if you or anyone on your forum can answer this/solve this problem.

I've received the following from my hosting company where I have wordpress blog installed.

What this means is that wordpress is opening up a connection and then not closing it before the page request is complete. This leaves the connection open which in turn causes load issues. You will need to resolve this issue immediately or the account will need to be suspended again to prevent further server issues.

and

this account has recently been showing signs of causing stability problems on the server which appear to be due to mysql usage on the wordpress installation, it does not appear to be closing it's connections which are then hanging and causing problems for the rest of the server.

I've tried wordpress support and their stuck, unable to answer the problem,

Is there a way of running a script that will close all connections which I could possible use as a cron like every hour?

Thanks

Mally

Hi Mally, This sounds like

Hi Mally,

This sounds like WordPress is uing mysql_pconnect which opens a persistent connection and is intended to remain open for use by subsequent requests (using the same db/username/password) as a way of speeding up page view.

Wondering if this is an option in WordPress, I found this page:

http://www.mydigitallife.info/2007/09/14/using-php-mysql-persistent-conn...

...however that implies that WordPress uses non-persistent connections by default; but it might be that you are running a later version; or your site has been modified to use mysql_pconnect() instead of mysql_connect().

Have a look for the file mentioned on that page (wp-includes/wp-db.php) and see if you can find either of the above functions (it should only appear once) - and if (fingers crossed) you find mysql_pconnect, changing it to mysql_connect should solve the problem!!

Cheers,
David.

Hello David Thanks for your

Hello David

Thanks for your reply. I've check the file wp-includes/wp-db.php and it looks like its using mysql_connect and not the persistent connection.

Its got me stumped, not sure if you've any other suggestions

Thanks

Mally