#20 expiring connections below the min

closed
nobody
None
5
2014-08-27
2006-02-01
navin_m
No

I have the following settings:

minPoolSize 2
maxIdleTime 30

What I was expecting to happen is that after my
connections were idle for 30 seconds, all but 2 would
be expired, and I would be left with 2 connections.

What actually seems to be happening is that all of my
connections are expiring, and then 2 new ones are
getting created. When my application is completely
idle, my 2 connections get expired and re-created every
30 seconds (notice the stats [managed: 0, unused: 0,
excluded: 0]):

1564990 DEBUG [Thread-3] v2.resourcepool - Checking for
expired resources - Wed Feb 01 08:21:42 MST 2006
[com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab]
1564990 DEBUG [Thread-3] v2.resourcepool - EXPIRED
resource:
com.mchange.v2.c3p0.impl.NewPooledConnection@f7821d
---> age: 30075 max: 30000
[com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab]
1564990 DEBUG [Thread-3] v2.resourcepool - Removing
expired resource:
com.mchange.v2.c3p0.impl.NewPooledConnection@f7821d
[com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab]
1564990 DEBUG [Thread-3] v2.resourcepool - trace
com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab
[managed: 1, unused: 1, excluded: 0] (e.g.
com.mchange.v2.c3p0.impl.NewPooledConnection@1444319)
1564990 DEBUG [Thread-3] v2.resourcepool - EXPIRED
resource:
com.mchange.v2.c3p0.impl.NewPooledConnection@17f7bf6
---> age: 30075 max: 30000
[com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab]
1564990 DEBUG [Thread-3] v2.resourcepool - Removing
expired resource:
com.mchange.v2.c3p0.impl.NewPooledConnection@17f7bf6
[com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab]
1564990 DEBUG [Thread-3] v2.resourcepool - trace
com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab
[managed: 0, unused: 0, excluded: 0] (e.g.
com.mchange.v2.c3p0.impl.NewPooledConnection@1444319)
1564990 DEBUG
[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0]
v2.resourcepool - trace
com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab
[managed: 1, unused: 1, excluded: 0] (e.g.
com.mchange.v2.c3p0.impl.NewPooledConnection@1444319)
1564990 DEBUG
[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0]
v2.resourcepool - trace
com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab
[managed: 2, unused: 2, excluded: 0] (e.g.
com.mchange.v2.c3p0.impl.NewPooledConnection@1444319)
1568750 DEBUG [Thread-3] v2.resourcepool - Checking for
expired resources - Wed Feb 01 08:21:46 MST 2006
[com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab]
1568750 DEBUG [Thread-3] v2.resourcepool - resource age
is okay:
com.mchange.v2.c3p0.impl.NewPooledConnection@15afd61
---> age: 3760 max: 30000
[com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab]
1568750 DEBUG [Thread-3] v2.resourcepool - resource age
is okay:
com.mchange.v2.c3p0.impl.NewPooledConnection@b0f534
---> age: 3760 max: 30000
[com.mchange.v2.resourcepool.BasicResourcePool@1a6eeab]

My understanding is that if I don't set maxIdleTime, my
pool will never get smaller. Is there any way to get
connections to expire, down to the minimum, but not
keep expiring my minimum number of connections if they
are also left idle?

Thanks in advance.

Discussion

  • Steve Waldman
    Steve Waldman
    2006-02-13

    Logged In: YES
    user_id=175530

    Navin,

    Sorry for the slow response. As you've observed, maxIdleTime expires out any
    older Connections, regardless of whether they are in excess of minPoolSize.
    This is important, because some databases time out old Connections, and
    there has to be a way of dropping them just because they are old.

    But what you want is quite reasonable. I'll try to add it as a new feature, via a
    config param (maxExcessConnectionIdleTime?) for c3p0-0.9.1. (The first
    prerelease of 0.9.1 will be out in a few days, but it won't have this
    functionality yet.)

    Thanks for the good suggestion!

     
  • Logged In: NO

    I have confirmed this excact, unexpected behavior using the
    c3p0 provided with hibernate 3.2CR2. It appears that the
    minPoolSize (min_siz) conflicts with maxIdleTime (timeout).
    Ben Groeneveld.

     
  • Steve Waldman
    Steve Waldman
    2006-09-07

    • status: open --> closed
     
  • Steve Waldman
    Steve Waldman
    2006-09-07

    Logged In: YES
    user_id=175530

    Navin,

    Sorry that this is so long unaddressed.

    At long last, your suggestion is implemented in
    c3p0-0.9.1-pre7 as maxIdleTimeExcessConnections. This
    parameter will bring the pool down to minPoolSize, but no
    lower, if Connections are idle for some period of time.

    The issue that some people have experienced with pools
    dropping below minPoolSize and never recovering is a bug,
    should never happen, unless the database itself fails to
    supply new Connections. I still don't know precisely why or
    when this occurs for some users under c3p0-0.9.0.x, but
    c3p0-0.9.1-preX radically overhauls pool size management,
    and I haven't heard this issue reappearing. If you get a
    chance, please give c3p0-0.9.1-pre7 a try.