I have lately noticed that my c3p0
connection pool keeps growing in size and reaches to the max limit I have specified at times. I initially thought that this might be happening because of the application code not returning connection back to the pool. This was not the case. To simulate the problem on development environment, I did a simple test:
I wrote an API that does nothing but a very simple database query and returns the result. Following is the c3p0 pool setting I am using:
#Pool configuration
c3p0.initialPoolSize=10
c3p0.minPoolSize=10
c3p0.maxPoolSize=100
c3p0.acquireIncrement=1
c3p0.maxIdleTime=1800
c3p0.unreturnedConnectionTimeout=20
c3p0.idleConnectionTestPeriod=600
c3p0.testConnectionOnCheckout=true
On hiting the test API with concurrency 10, I expect the pool size to never grow beyond 10. But it goes to 20-30 at times. What explains this?
I know I can get the pool size reduced by setting maxIdleTimeExcessConnections
to a lower value. What what is causing it to grow at the first place?
Here are the versions I am using:
c3p0: 0.9.1.2
hibernate entitymanager: 4.2.1.Final
spring-data-jpa: 1.3.4.RELEASE