I was under the impression that one has to explicitly call releaseSession() after a getSession() or am I mistaken?
I am trying to diagnose a possible connection leak in our application. We have a DAO that extends HibernateDaoSupport. Some methods use the HibernateTemplate which I know handles everything automatically, other methods have calls to getSession() but in the method there is no corresponding call to releaseSession().
The Hibernate SessionFactory is injected to the DAO through Spring, a pretty standardized configuration. There is advice that is applied to this method as well which just has a propagation="REQUIRED" and nothing else.
The Hibernate session for the application UI is established via the OpenSessionInView pattern.
The strange thing is that our connection pool gets exhausted only under some scenarios i.e. when we are running some concurrent tasks performed by non-UI worker threads, just using the UI for any amount of time does not result in an increase in # of active pool connections. We have our connection pool set to max 30 connections, the app spawns a batch of 16 worker threads, after these are done the connections are not released, the next batch of 16 worker threads exhausts the pool as only 30-16=14 connections are available...so there is a leak somewhere and I think perhaps what I found above?
|