Lisp HUG Maillist Archive

MySQL server has gone away

I developed an application using the sql package (Mac OS 10.4.9, LW  
5.0.1, Entreprise).
When the MySQL database is not queried for a while, I get the  
following error:

Sql-Fatal-Error id 2006 : In PREPARE : MySQL server has gone away

Here is a backtrace after a function calling select (if this can be  
helpful).
Call to SQL::CALL-WITH-CURSOR-REPORTING-ERROR
Call to CLOS::METHOD-COMBINATION-TEMPLATE
Call to SQL::DB-PREP
Call to SQL::DB-PREP-X
Call to SQL::EXEC-OBJECT-QUERY
Call to SQL:QUERY

I think this is caused by MySQL closing connections when they are  
idle for a while.
When the fatal error occurs, I cannot issue a select command.  
However, if I reconnect, then everything is back to normal.

I would like to be able to check if MySQL is awake or not before  
issuing an sql command. I looked at the *default-database* parameter  
value and I did not see any obvious differences between before and  
after the break.

Calling connected-database also shows my database as being connected  
in spite of the fatal error.

Any suggestions as to where I can check the connection status?

Thanks

Bruno


Updated at: 2020-12-10 08:46 UTC