Mysql connections are being left open - Any advice why

Can someone shed some light onto why Dolphin 7.0.6 always has a load of Mysql connections open. This is after 30 minutes of killing Mysql

Kill     342467     dolphintest     localhost     dolphintest     Sleep     3793     ---     ---
Kill     342492     dolphintest     localhost     dolphintest     Sleep     3721     ---     ---
Kill     342504     dolphintest     localhost     dolphintest     Sleep     3721     ---     ---
Kill     342505     dolphintest     localhost     dolphintest     Sleep     3721     ---     ---
Kill     342506     dolphintest     localhost     dolphintest     Sleep     3721     ---     ---
Kill     342507     dolphintest     localhost     dolphintest     Sleep     3721     ---     ---
Kill     342508     dolphintest     localhost     dolphintest     Sleep     3749     ---     ---
Kill     342512     dolphintest     localhost     dolphintest     Sleep     1045     ---     ---
Kill     342725     dolphintest     localhost     dolphintest     Sleep     3509     ---     ---
Kill     343010     dolphintest     localhost     dolphintest     Sleep     3181     ---     ---
Kill     343268     dolphintest     localhost     dolphintest     Sleep     2997     ---     ---
Kill     343817     dolphintest     localhost     dolphintest     Sleep     2616     ---     ---
Kill     343857     dolphintest     localhost     dolphintest     Sleep     2167     ---     ---
Kill     343917     dolphintest     localhost     dolphintest     Sleep     1212     ---     ---
Kill     344074     dolphintest     localhost     dolphintest     Sleep     2472     ---     ---
Kill     344124     dolphintest     localhost     dolphintest     Sleep     2440     ---     ---
Kill     344227     dolphintest     localhost     dolphintest     Sleep     2377     ---     ---
Kill     344335     dolphintest     localhost     dolphintest     Sleep     2334     ---     ---
Kill     346483     dolphintest     localhost     dolphintest     Sleep     1599     ---     ---
Kill     347033     dolphintest     localhost     dolphintest     Sleep     1422     ---     ---
Kill     347058     dolphintest     localhost     dolphintest     Sleep     1414     ---     ---
Kill     347648     dolphintest     localhost     dolphintest     Sleep     1191     ---     ---
Kill     347907     dolphintest     localhost     dolphintest     Sleep     1114     ---     ---
Kill     348227     dolphintest     localhost     dolphintest     Sleep     1024     ---     ---

 

Server load is low at around 0.3

Any advise would be appreciated

Thanks

Quote · 20 Apr 2011

mysql.allow_persistent = Off

it might help.

Quote · 20 Apr 2011

Thanks Deano and that is right on task MY clear question is why would this be allowed to fester and not be addressed at all.  It is quite clear that this is an issue and one that is enough to bring my site to it knee's.  I ask garyw74

1) Did you resolve the issue?  Did you have high traffic or moderate traffic?

2) Did the suggestion given here work?

3) Where is that setting to change it?

Csampson
Quote · 21 Sep 2011

Hmmmmmm OK I found the file and it is set to off...............................

 

I really need some help here on how to stop these from sleeping..........................

Csampson
Quote · 21 Sep 2011

You can find this error if your scripts open persistent connections, wich aren't closed even if the script terminates. Use mysql_connect() instead of mysql_pconnect()

Two ways to dosable it. One i posted above it's in php.ini

mysql.allow_persistent = Off

Second one would be change the way the script connects to the db it's self.

/inc/classes/BxDolDb.php

find function

 /**
  * connect to database with appointed parameters
  */
 function connect()
 {
  $full_host = $this->host;
  $full_host .= $this->port ? ':'.$this->port : '';
  $full_host .= $this->socket ? ':'.$this->socket : '';

  $this->link = @mysql_pconnect($full_host, $this->user, $this->password);
  if (!$this->link)
            $this->error('Database connect failed', true);

  if (!$this->select_db())
            $this->error('Database select failed', true);
  
        mysql_query("SET NAMES 'utf8'", $this->link);
        mysql_query("SET sql_mode = ''", $this->link);

        $GLOBALS['bx_db_link'] = $this->link;
 }

and change to

 /**
  * connect to database with appointed parameters
  */
 function connect()
 {
  $full_host = $this->host;
  $full_host .= $this->port ? ':'.$this->port : '';
  $full_host .= $this->socket ? ':'.$this->socket : '';

  $this->link = @mysql_connect($full_host, $this->user, $this->password);
  if (!$this->link)
            $this->error('Database connect failed', true);

  if (!$this->select_db())
            $this->error('Database select failed', true);
  
        mysql_query("SET NAMES 'utf8'", $this->link);
        mysql_query("SET sql_mode = ''", $this->link);

        $GLOBALS['bx_db_link'] = $this->link;
 }


 Apache does not work well with persistent connections. When it receives a request from a new client, instead of using one of the available children which already has a persistent connection open, it tends to spawn a new child, which must then open a new database connection. This causes excess processes which are just sleeping, wasting resources, and causing errors when you reach your maximum connections, plus it defeats any benefit of persistent connections

Quote · 21 Sep 2011

@

Great I made the changes I hope that will work thank you so much for the guidance.............VERY HELPFUL>>>>>>>>

Csampson
Quote · 21 Sep 2011

Hello:

I re-enabled profile.php. Immediately, the server load shot up, and 135 copies of "profile.php" were spawned. 83+ MySQL queries spawened up immediately as well. In order to keep your server online, I had to change the permissions on the profile.php file back to 000:


The issue still seems to exist.
Hmmm I am at a loss is there some kind of file that is calling all these requests is there a way to clear it?  Please advise as they have turned off the profile.php to keep the server on.............
Csampson
Quote · 21 Sep 2011

You can rewrite the database class to use a mysql_connect and mysql_close as mentioned before.

----
Quote · 21 Sep 2011

 

You can rewrite the database class to use a mysql_connect and mysql_close as mentioned before.

 I made the change to mysql_connect and there is something that is killing the database on launch of the .........

and mysql_close did I miss that because I don't see it or what to do with it..............the profile.php is killing the site when the permissions are turned back on.............Thoughts are appreciated......

Csampson
Quote · 21 Sep 2011

Sorry for the late reply. This did sort my issue. I no longer have a load of connections left hanging

Quote · 21 Sep 2011
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.