3
votes

The Glassfish4 server installed on my machine has Maximum Pool Size = 32 connections. Two cron jobs are scheduled from my application after every 10 and 15 mins on this server. The server crashed after 2 hours with the exception "java.sql.SQLException: Error in allocating a connection. Cause: In-use connections equal max-pool-size and expired max-wait-time. Cannot allocate more connections."

So, I altered the JDBC Connection pool settings and put in really large numbers just to see what would happen.

Maximum Pool Size: 1000000000 (1 billion) Max Wait Time: 300000 (5 minutes)

Now my cron jobs are running fine.

Do you think having set the JDBC Connection pool attributes this high could cause issues? Please advise what values will be optimum.

1
I think you should check mysql processlist and check the connections state before increasing the pool size. Not handling the connection properly leave the con object in indeterministic stateKenshin
1000000000 and 5 min is a terrible valueKenshin
Thanks for your reply. We are using Hibernate with JPA Entity Manager. All the values are set to null after use. The transactions are container managed. I agree the values are not good. But no alternate solution till now.Rashmi
It depends on various factors 1) Maximum allowed connection limit in your database 2) Large number of query hitting database 3) Time it takes for each query to complete 4) Error in handling connection ( ie, not closing connection properly ) You could get a better overview, if you could login to your database and see the number of open connections at a timeKenshin

1 Answers

4
votes

I have resolved this issue with below settings in Glassfish4

Initial and Minimum Pool Size:16

Maximum Pool Size:64

Pool Resize Quantity:4

Idle Timeout:60

Max Wait Time:3000

I enabled connection leak monitoring in Glassfish4.

After enabling connection leak monitoring, when I checked the monitored data after some time, I could see ConnectionLeak exception in logs in some of my java classes. I closed the connections in these classes as they were being made directly from Connection object and JPA Entity Manager was not used in them.

Now all my cron jobs are running without Server crash.