Can anyone else confirm mysql connections being left open?
The connections in WordPress are opened with mysql_connect(), so they should not have to be closed as they are not persistent connections in the first place. They are closed automatically when the script ends.
If you really want to try using mysql_pconnect, just edit wp-includes/wp-db.php. It’s on line 52 towards the top. I cannot see how that would remedy your problem, however.
And this:
* If your PHP script does not close a connection once it is done using it, that connection will remain open for approximately 20 hours before the system resets it automatically.
is total nonsense. PHP’s own documentation says so:
From http://php.net/manual/en/function.mysql-close.php
Using mysql_close() isn’t usually necessary, as non-persistent open links are automatically closed at the end of the script’s execution.
Now, in theory, changing to mysql_pconnect would give a performance boost, if the database server didn’t totally break from attempting to handle a large number of persistent connections.
If you really want to force close connections, just change this:
function __destruct() {
return true;
}
to this:
function __destruct() {
mysql_close($this->dbh);
return true;
}
In wp-includes/wp-db.php.
Otto you make a lot more sense than Yahoo Support. Thank you.
Using phpinfo() I verified that mysql “active links” count was 1. I refreshed many times. It never changed.
Also using phpmyadmin I looked up runtime information. There’s a variable called “max used connections” which was set at 17 at the time.
So it doesn’t look like number of open connections is the issue.
However one thing that caught my attention in “runtime information” was the number of aborted connections. This was more than 20% of all connections. What causes aborted connections?
About aborted connections:
The server variable Aborted_connects is incremented when:
- When a connection packet doesn’t contain the right information.
-
When the user didn’t have privileges to connect to a database.
- When a user uses a wrong password.
- When it takes more than connect_timeout seconds to get a connect package.
Note: if this is high it could indicate that someone is trying to break into your database!
I couldn’t find “Function __ Destruct” in my wp-dp.php file.. I’m using WP 2.0.6… Is this named something else in my version?
What can I do similarly to force SQL to close connections in 2.0.6?
Thank you!
I have got the some problem. I am using wordpress 2.2 but some of my plugings doesn’t work when I change ‘function __destruct()’
Is there anyway to close all the connections at the end of the page?
i’m getting a similar issue http://wordpress.org/support/topic/137344?replies=4 although I think it might be related to a plugin.
[moderated fixed reference to topic 10/25/07 ]