Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

From: http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-troubleshooting.html

Panel
 

24.4.5.3.4: I have a servlet/application that works fine for a day, and then stops working overnight
MySQL closes connections after 8 hours of inactivity. You either need to use a connection pool that handles stale connections or use the "autoReconnect" parameter (see Section 23.4.4.1, "Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J").

...

I'm not an expert on setting up connection pools or whether OFBiz already can handle this.  All I know is that OFBiz isn't set up OOTB to do this with the MySQL settings.  So, what can one do?  Well, for starters there is the peculiar statement:

Code Block

MySQL closes connections after 8 hours of inactivity.


Since you can schedule services to run at particular times and repeat until infinity and so on, why not just not allow 8 hours of inactivity to occur.  For my deployment, I've done the following:

Code Block

<simple-method method-name="hitTheDatabase" short-description="store and delete an entry to keep Mysql Database Alive">
   <make-value entity-name="GeoType" value-name="hitEntity" />
   <set field="hitEntity.geoTypeId" value="XXXXXXXXXX" />
   <create-value value-name="hitEntity" />
   <entity-one entity-name="GeoType" value-name="thisEntity">
     <field-map field-name="geoTypeId" env-name="hitEntity.geoTypeId" />   </entity-one>
   <remove-value value-name="thisEntity" /> </simple-method>


 Created a service to call it and then scheduled that service to run every 3.5 hours (Just in case there was a problem with the first call).
Note: it has been brought to my attention that this may not be sufficient for slightly busier but not quite busy enough deployments.  A better solution is being looked into. 


 
A better solution would be to adjust wait_timeout parameter in my.cnf. By default it is set to 28800 (which seems to be exactly 8h).
change or add the following line to your my.cnf and set it to a really large number:

...