-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
connection leaks #41
Comments
I've found something similar in one of my apps when running scheduled jobs that aren't triggered by a web request. Are you using @UnitOfWork for transaction management? Could you provide a simple example of how your app is using dropwizard-entitymanager? |
Hello, I just ran into a similar issue. I'm trying to multi thread queries therefore I'm using UnitOfWorkAwareProxyFactory to have access to an EntityManager on my runner threads. This leads to a connection leak. After debugging, it seems that the issue is because the afterEnd() method in UnitOfWorkAspect does not close the entityManager and therefore does not release the connection. There is a comment indicating that the entityManager should not be closed in case the session is needed while serializing the response for lazy loading purposes. The reason why it does not leak on web requests is that the UnitOfWorkApplicationListener calls EntityManagerContext.unBindAll which closes all the entityManagers in the current thread context. UnitOfWorkAwareProxyFactory created proxies do not have the same behavior and therefore never close the entityManagers. |
Hi,
In my usage, I'm delegating all database access to
dropwizard-entitymanager
and not managing database connectivity manually anywhere (I'm also using C3P0 for pooling) After running the app for a while, I saw aMySQLNonTransientConnectionException: Too many connections
exceptions (log here: https://gist.github.com/bladecatcher/a297171f8fedbbadbcac50478fb91e79)When I saw this for the first time, I realised that the mysql instance I was running could only accept a maximum of 66 connections (AWS RDS micro tier) and I had
hibernate.c3p0.max_size
set to 100. I then reduced thehibernate.c3p0.max_size
to 10.After running the new instance for a while, I now observe (upon taking a thread dump) that C3P0 hangs at
My hibernate configuration is as follows:
This seems to indicate a possible connection leak. Found this Stack Overflow link http://stackoverflow.com/questions/14105932/c3p0-hangs-in-awaitavailable-with-hibernate which discusses this error.
The text was updated successfully, but these errors were encountered: