Hi Gary, Thank you for your reply. I created a PR with a test case for the Eviction feature problem.
https://github.com/apache/commons-dbcp/pull/40 Best regards, Kyohei Nakamura 2020年4月27日(月) 0:46 Gary Gregory <garydgreg...@gmail.com>: > > Hi Kyohei, > > I think it would help a lot in if you would provide a PR on GitHub for a > failing JUnit test. Please use an H2 in-memory database as the underlying > database. > > https://github.com/apache/commons-dbcp > > Thank you, > Gary > > On Sun, Apr 26, 2020 at 8:49 AM Kyohei Nakamura < > nakamura.kyohei....@gmail.com> wrote: > > > 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: user-unsubscr...@commons.apache.org > > For additional commands, e-mail: user-h...@commons.apache.org > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org