I have a script that is attempting to log some data (usually around 200-300kb at a time). It has been running just fine for quite some time. I do not know of any configuration changes made to either the MySQL server or the PHP on the processing server. Yesterday the following code block started misbehaving. Two days ago the "$sqlBucket" query worked just fine. Now, it fails and the mysql_error returns "MySQL server has gone away". I added the debugging in the first if block and it outputs:
The Link Is Down
Link still down
The code:
if (!mysql_ping($conn)) {
echo "The Link Is Down!\n";
mysql_close($conn);
if (!($conn = mysql_connect($hostname,$username,$password))) echo "Fail " . $mysql_error() . "\n";
mysql_select_db($db,$conn);
if (!mysql_ping($conn)) echo "Link still down\n";
}
if (!mysql_query($sqlBucket, $conn)) {
echo "Could not execute: {$sqlBucket}" . mysql_error() . "\n";
}
If anyone has any thoughts on something to check, debug, reconfigure, etc I have run out of ideas. Thanks.
EDIT: Extra info
The script executes and fails in ~3 seconds.
The wait_timeout value on the MySQL server is 28800.
I am able to send the queries successfully through the command line.
I added a check on the mysql_connect function and it is reporting success (at least I am not getting a "Fail" in the output).
mysql_close($conn);before reconnecting?