NLP-er
12-25-2009, 01:48 PM
Hi.
My mod is taking data from Google. Usually it is fast, still sometimes it took long enough that MySQL is going away (error 'MySQL hs gone away').
I wrote code to reestablish connection, but it seems that it doesn't work for all.
if (!mysql_ping($vbulletin->db->connection_recent)) {
$vbulletin->db->close();
// make database connection
$vbulletin->db->connect(
$vbulletin->config['Database']['dbname'],
$vbulletin->config['MasterServer']['servername'],
$vbulletin->config['MasterServer']['port'],
$vbulletin->config['MasterServer']['username'],
$vbulletin->config['MasterServer']['password'],
$vbulletin->config['MasterServer']['usepconnect'],
$vbulletin->config['SlaveServer']['servername'],
$vbulletin->config['SlaveServer']['port'],
$vbulletin->config['SlaveServer']['username'],
$vbulletin->config['SlaveServer']['password'],
$vbulletin->config['SlaveServer']['usepconnect'],
$vbulletin->config['Mysqli']['ini_file'],
$vbulletin->config['Mysqli']['charset']
);
if (!empty($vbulletin->config['Database']['force_sql_mode'])){
$vbulletin->db->force_sql_mode('');
}
}
The code is mostly taken from vB, so there is no configuration/typo issue. Some have issue with mysql_ping - error tells that $vbulletin->db->connection_recent is wrong object. And some still have MySql server has gone away - like reconnection didn't occurs...
What is wrong? And how to made reconnection?
My mod is taking data from Google. Usually it is fast, still sometimes it took long enough that MySQL is going away (error 'MySQL hs gone away').
I wrote code to reestablish connection, but it seems that it doesn't work for all.
if (!mysql_ping($vbulletin->db->connection_recent)) {
$vbulletin->db->close();
// make database connection
$vbulletin->db->connect(
$vbulletin->config['Database']['dbname'],
$vbulletin->config['MasterServer']['servername'],
$vbulletin->config['MasterServer']['port'],
$vbulletin->config['MasterServer']['username'],
$vbulletin->config['MasterServer']['password'],
$vbulletin->config['MasterServer']['usepconnect'],
$vbulletin->config['SlaveServer']['servername'],
$vbulletin->config['SlaveServer']['port'],
$vbulletin->config['SlaveServer']['username'],
$vbulletin->config['SlaveServer']['password'],
$vbulletin->config['SlaveServer']['usepconnect'],
$vbulletin->config['Mysqli']['ini_file'],
$vbulletin->config['Mysqli']['charset']
);
if (!empty($vbulletin->config['Database']['force_sql_mode'])){
$vbulletin->db->force_sql_mode('');
}
}
The code is mostly taken from vB, so there is no configuration/typo issue. Some have issue with mysql_ping - error tells that $vbulletin->db->connection_recent is wrong object. And some still have MySql server has gone away - like reconnection didn't occurs...
What is wrong? And how to made reconnection?