We use MySQL with both SQLMap and DAO. We are configured to use Apache's DBCP data source. All transactions are automatic except for 2 where we needed to explicitly startTransaction()/commitTransaction/endTransaction(). The endTransaction() is always in a finally block, and we verified we are always calling endTransaction(), whenever we start one including when an error occurs. The data source is set to test connections on checkout.
Our DaoManager is a singleton and likewise we verified we only have one instance. All DAO's are local in scope - they fall out of scope when we are done with them. We have no global DAO's.
After periods of inactivity, we occasionally get a Broke Pipe error because the inactivity timeout for connections has been exceeded. This should never happen because of the test that is being performed by the data source. Upon further analysis, there is a condition where a connection is not tested, and my assumption is that we are holding on to it and not checking it back in. Given all of the above, I cannot see how. Assuming all I said was true, is there a condition in which this could happen?
The only kicker I can think of is that we do have a DAO that returns a composite object meaning it contains data from different data sources. So, we have a DAO that gets and uses other DAO's inside it, but not within a transaction.
Yes, we can stop the problem by setting timeout high, but I want to know why we are holding on a connection. Any ideas?
Thanks,
Tom
