0

We have a connection pool for an embedded derby database. We are setting

  • max wait time to 5 secs
  • max connection in pool 100

We are getting org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object very frequently. When this exception is coming, the connections owned by the application is always 1, this is evident from the logs.

The above exception states that the pool manager cannot produce a viable connection to a waiting requester and the maxWait has passed therefore triggering a timeout. Ref: Cannot get a connection, pool error Timeout waiting for idle object in PutSQL?

There is 1 application using derby, the Derby database, and 2 other applications.

As per my understanding, the following are the main reason for not getting a connection

  • There is a network issue
  • Connection pool has been exhausted, because of connection leak
  • Connection pool getting exhausted, because of long-running queries

In our case, it's an embedded derby database which is local to the application. So, network issue is ruled out. There are no long-running queries. I am not able to figure out what is causing wait timeout. Could it be related to OS, Filesystem, server utilization going high etc?

Any help is appreciated.

dpapadopoulos
  • 1,834
  • 5
  • 23
  • 34
ba6971
  • 85
  • 7
  • At the instant that you get the pool error exception, what happens if you have your program try to make a direct connection to Derby, right then? Try this, and capture the **exact** exception information that the underlying Derby JDBC connection request gives you; perhaps that will have more clues about what is going wrong trying to get a connection. – Bryan Pendleton Feb 06 '19 at 03:22
  • This is something which we cannot replicate / reproduce. It happens randomly. In happy hours, my derby connection usage is never going above 10. It's just random. – ba6971 Feb 06 '19 at 06:36
  • Yes, those are frustrating. All the more reason, however, to add more infrastructure to your program to gather more information about what's going on when these rare events occur. – Bryan Pendleton Feb 07 '19 at 05:34
  • There is no issues with the pool. We had a thread which sleeps when a specific condition is true else it keeps on running. Due to some bug, the thread went into recursion and never slept. Which led to exhaustion of the connection pool – ba6971 May 21 '19 at 07:31
  • Ah! Glad you figured it out. Thanks for updating us with the outcome. – Bryan Pendleton May 21 '19 at 22:36

0 Answers0