Question

I am using Spring 2.5; a SimpleJdbcTemplate using apache-commons-dbcp connection pooling. There is also a thread pool which spawns a thread when a query is run (several queries are performed and their results processed once all are complete, so the threads are spawned to run queries in parallel).

Eventually, all the threads are waiting on getConnection() in a TIMED_WAIT. No thread seems to get a Connection. I check the DB and the connections are all idle.

What is causing this? I have 10 connections as the max Pool size and 50-100 threads. How should I be configuring this? The DBA says that should be enough connections (and I agree since they are all idle).

The same thing happens with BoneCP as the datasource for the SimpleJdbcTemplate as well.

Was it helpful?

Solution

Turns out it was because in the middle of looping through a ResultSet, another query was started, so with enough first queries, the second ones cannot get a connection and everything deadlocks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top