commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cyrille <cyrille....@free.fr>
Subject Re: [DBCP] getConnection Timeout
Date Fri, 03 Sep 2010 06:34:24 GMT
  Hi Sic,
this can happen if your queries takes longer to execute.
General thoughts: It can show you that your db is getting bigger, or 
your indexes are not up to date.

I think you are right with both of your feeling.

1. You should recycle your connections less frequently, i.e increase the

<property name="timeBetweenEvictionRunsMillis" value="10000"/>

In previous dbcp implementations, when evicting the connections, the 
pool had to synchronise its access to the list of connections, so it was 
preventing connections from being borrowed by the rest of the application.
I am not sure this is still true, but I guess so.
Trying to evict every 10 s seems quite agressive for me.

2. I would use testOnBorrow instead of testOnReturn, which will test if 
connections are valid before using them.
If not, the pool will borrow another one.
I find this safer than using testOnReturn.

3. You can wait longer before having a timeout when no connection is 
available by increasing the maxWait.
Note: waiting 10 s for a connection to be available seems long enough.
I would start with evicting less frequently.

I used this connection pool, configuring the testOnBorrow and not using 
the evictor, ie removed those lines:

	<property name="testWhileIdle" value="true"/>  

	<property name="timeBetweenEvictionRunsMillis" value="10000"/>


Regards,
Cyrille.

Le 03/09/10 04:20, sic a écrit :
> I'm using dbcp on the web application server whose version is
> commons-dbcp-1.3, commons-pool-1.5.4 on jdk1.5.
>
> It can be used to execute some DML statements when receiving about 30 ~ 150
> number of data(data is less than 3 KB) peridically per minute
>
> Expected to do these simple works with no difficulties, it generated some
> errors occasionally(50 ~ 150 per day).
>
> org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool
> error Timeout waiting for idle object
> 	at
> org.apache.commons.dbcp.PoolDataSource.getConnection(PoolingDataSource.java:114)
> 	at
> org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
> 	...
>
> The web application server could use 30 threads at most, using oracle DB and
> the configurations are following:
>
> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
> destroy-method="close">
> 	<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
> 	<property name="url" value="..." />
> 	<property name="username" value="..." />
> 	<property name="password" value="..." />
> 	<property name="initialSize" value="5"/>
> 	<property name="maxActive" value="30"/>
> 	<property name="maxIdle" value="30"/>
> 	<property name="minIdle" value="5"/>
> 	<property name="maxWait" value="10000"/>
> 	<property name="testWhileIdle" value="true"/>
> 	<property name="validationQuery" value="select 1 from dual"/>
> 	<property name="testOnReturn" value="true"/>
> 	<property name="timeBetweenEvictionRunsMillis" value="10000"/>
> </bean>
>
> How can I prevent it from generating continuously?
>
> I have a feeling of doubt about my maxWait and
> timeBetweenEvictionRunsMillis.
> Surely I guess, if I change the maxWait value more sufficiently, it would be
> generated much less than the present, which is just a temporary resolution.
> I'm not certain whether timeBetweenEvictionRunsMillis has influence on this
> issue.
>
> And I have to put a lot of effort as it has already run for a long time, not
> easy to change something.
>
> I appreciate somebody make a helpful advice for that issue.
>
> regards,
> sic
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message