Skip to main content

Posts

Showing posts from November, 2015

Database Leak: getConnection() within Spring Transaction

I recently encountered an issue where one of my teammates was experiencing an issue where an application datasource would periodically become exhausted.  After discussing it a few times, we hypothesized that it was a situation where there was a database connection leak.  It was suspected the leak was within boundaries of some application code with a low call rate.  This would line up with, why the application would run for an extended period and then all of a sudden max out its database connections. By inspecting the logs around the times of the database connection pool becoming exhausted it became pretty clear the potential location of the problematic code. The cause of the issue was not a result of necessarily bad code writing, but more of a case of not knowing how legacy semantics would work within the context of a spring transactional boundary. The semantics of how a call to DataSource.getConnection() behaves within the Spring transaction boundary is probably not entirely evide