Hi,
My site is on a shared server (a french company named OVH) and the max_user_connections is set to 3. So I get often the following error :
User site@ has already more than 'max_user_connections' active connections"
To avoid that I modified the adodb_mysql.inc to add a 3 times retry when the connection fails, with a 1 sec pause between them.
I modified the source only for php>=4.3 but it is straight forward to do the same for the other versions. Here is the new _connect function of /lib/adodb/drivers/adodb_mysql.inc :
---------------------------------------------------------------------------------------------------------
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!empty($this->port)) $argHostname .= ":".$this->port;
if (ADODB_PHPVER >= 0x4300){
$i=0;
$this->_connectionID = false;
while (($i<3)&&(!$this->_connectionID))
{
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
$this->forceNewConnect,$this->clientFlags);
$i++;
if (!$this->_connectionID)
{
sleep(1);
}
}
}
else if (ADODB_PHPVER >= 0x4200)
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
$this->forceNewConnect);
else
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false;
if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true;
}
---------------------------------------------------------------------------------------------------------
Posts: 32509
why not just use persistent connections?
there's a switch for that in
config.php
Posts: 8
But as far as I know persistent connections make each apache (in my case) process keep its existing connection to reuse it. But there are more than 3 apache servers running, so I might get out of connections ? Or am I completely mistaken.
PS : thanks for your reply
Posts: 1
Yes ! Finaly a solution !
A thousand thanks, o_dupuis.
Same company (OVH) and same problem. I've tried dozen solutions found here and there about broken thumbnails, but nothing was working, until yours.
(and with persistant connections -> not better).
I just slighly modified your hack to do a "sleep(rand(1, 3))" and my "while" counts up to 10 (what a ugly stuff ! ), to avoid problems with big thumbnail pages, and now everything is OK (except, of course, the page loading slower, but not that much in fact, maybe 2-3 seconds more, not a big deal).
Thanks again.