I have a problem with MySQL timeouts in my 24/7 PHP shell script.
I was under impression that Pear DB DB::connect() would create new handle but this does not seem to be the case. DB::connect() actually returns “server has gone away” error even when used in a loop for five times.
I now added db->disconnect() and unset( $db) to the script before the DB::connect(). Will this cause the underlying mysql module to free the resources before connect (localhost) ? If not then I don’t see other options than using the proprietary new_link.
Hmm. Inconclusive.
I made sample php script to connect twice with same settings, run mysql_close() and then third connection.
I also ran tcpdump in another window.
On the first few runs there was some traffic to the server on subsequent connects. Then this traffic disappeared.
Now the result is that without mysql_close() the mysql_connect() indeed uses the previous connection and there is zero traffic on subsequent mysql_connect().
When running mysql_close() the dump would indicate the TCP connection is closed.
On the third connect the connection is again established from the start.
And the script: