Hi all,

I use DBCP2 version 2.7.0 (with POOL2 version 2.7.0).
I want to destroy idle connections in the pool using Eviction function.

the config (code snippet) is in the following.
----
BasicDataSource ds = new BasicDataSource();
ds.setInitialSize(10);
ds.setMaxIdle(10);
ds.setMaxTotal(10);
ds.setMinIdle(5);
ds.setNumTestsPerEvictionRun(3);
ds.setMinEvictableIdleTimeMillis(5000);
ds.setTimeBetweenEvictionRunsMillis(5000);
ds.setPoolPreparedStatements(true);
----
At that time, I confirmed the following behavior.

1. After starting, 10 connections of initialSize are created into the pool
2. After a few seconds, 3 connections numTestsPerEvictionRun of are
destroyed from the pool
3. After that, other connections are not destroyed and
"commons-pool-evictor-thread" thread is disappeared

However, I have confirmed when set poolPreparedStatements to false,
connections decrease to the value of minIdle and
"commons-pool-evictor-thread" thread still alive.

I think that when poolPreparedStatements is true, the close method of
the GenericKeyedObjectPool class that managed PreparedStatement is
called when the connection is destoryed.
And, this method executes the stopEvictor method.
So I think it is a problem.

For your reference,
It is happend when using DBCP2 version 2.7.0 (with POOL2 version 2.7.0).
However, It is not happend when using DBCP2 version 2.1.1 (with POOL2
version 2.4.2).
At that time "commons-pool-EvictionTimer" thread alive.


Best regards,
Kyohei Nakamura

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to