Help understanding how IdleMaxAge works

Ask around here!

Help understanding how IdleMaxAge works

Postby flamarre » Wed Oct 26, 2011 8:12 pm

Here is a test scenario

Code: Select all
    public void testIdleCleanup() throws SQLException, InterruptedException{

      BoneCPDataSource ds = getBasicSetup();
      
      ds.setMinConnectionsPerPartition(2);
      ds.setMaxConnectionsPerPartition(10);
      ds.setAcquireIncrement(2);
      ds.setIdleMaxAgeInSeconds(5);
      
      Connection connection = ds.getConnection();
      Connection connection1 = ds.getConnection();
      Connection connection2 = ds.getConnection();
      Connection connection3 = ds.getConnection();      
      connection.close();
      
      Thread.sleep(7000);
      
      connection1.close();
      connection2.close();
      connection3.close();
      
      ds.close();
   }

        private BoneCPDataSource getBasicSetup(){
      
      //connection params
      BoneCPDataSource ds = new BoneCPDataSource();
      ds.setDriverClass("com.mysql.jdbc.Driver");
      ds.setJdbcUrl("jdbc:mysql://localhost/localtest");
      ds.setUsername("root");
      ds.setPassword("r00t");

      //basic params
      ds.setPartitionCount(1);
      ds.setMinConnectionsPerPartition(2);
      ds.setMaxConnectionsPerPartition(20);
      ds.setAcquireIncrement(4);
      ds.setPoolAvailabilityThreshold(0); //default 20 (20%)
      
      //acquisition params
      ds.setAcquireRetryAttempts(5);
      ds.setAcquireRetryDelayInMs(1000);
      ds.setConnectionTimeoutInMs(5000);
      
      //lifecycle params
      ds.setConnectionTestStatement("/* ping */SELECT 1");
      ds.setReleaseHelperThreads(3);
      ds.setIdleMaxAgeInSeconds(0);
      ds.setMaxConnectionAgeInSeconds(0);
      ds.setIdleConnectionTestPeriodInSeconds(300);
      
      //function params
      ds.setPoolName("BoneCP");
      ds.setLogStatementsEnabled(false);
      ds.setDefaultAutoCommit(false);
      ds.setLazyInit(false);
      ds.setDefaultTransactionIsolation("READ_COMMITTED");
      ds.setQueryExecuteTimeLimitInMs(5000);      //for slow query logs
      
      return ds;
   }


What I was expecting:
-4 connections created initially
-1 gets closed off after 5 seconds

What I saw:
-6 connections created initially (most of the time)
-1 connection gets closed after 5 seconds (0.7.2 only, nothing happens on 0.7.1)

BoneCP Versions tried:
bonecp-0.7.1.RELEASE.jar
bonecp-0.7.2-20110513.135025-9.jar

Are my expectations wrong?
flamarre
 
Posts: 9
Joined: Thu Jul 28, 2011 1:20 pm

Re: Help understanding how IdleMaxAge works

Postby dusan.czh » Wed May 30, 2012 11:27 am

I have a similar setup and the same thing happens to me.
My database is mysql, using com.mysql.jdbc.Driver as driver.

Code: Select all
config.setIdleConnectionTestPeriodInMinutes(1);
config.setIdleMaxAgeInMinutes(2);
config.setMaxConnectionAge(5, TimeUnit.MINUTES);


My idle connections get closed in 5 minutes instead of 2. It seams idleConnectionTestPeriod is overriding idleMaxAge.
I'm interested if anyone has answer to this.
dusan.czh
 
Posts: 3
Joined: Wed May 30, 2012 11:18 am

Re: Help understanding how IdleMaxAge works

Postby dusan.czh » Wed May 30, 2012 11:52 am

Finally found what i think is the answer:
http://jolbox.com/forum/viewtopic.php?f=3&t=142

Regards,
dusan.czh
 
Posts: 3
Joined: Wed May 30, 2012 11:18 am


Return to BoneCP - Help, Q&A, Whatever!

Who is online

Users browsing this forum: No registered users and 2 guests

cron