How is maxIdleTimeExcessConnections different from maxIdleTime in c3p0?
Good answer by Steve Walkdman, I just want to add a short answer:
The difference is that maxIdleTime will replace idle connections even in minPoolSize
-d pools, while maxIdleTimeExcessConnections
won't.
what a careful and lawyerly read!
but no, it's not correct.
there are several ways a Connection can die. as you quote:
c3p0 pools...shrink if Connections fail a Connection test or are expired away via the parameters described above.
the "parameters described above" include maxConnectionAge
, maxIdleTime
, and maxIdleTimeExcessConnections
. Connections can also be removed from the pool because they fail Connection tests while idle (see idleConnectionTestPeriod
), because they fail tests on check-in or on check-out (testConnectionOnCheckin
, testConnectionOnCheckout
), or because they fail tests triggered by an Exception in the course of client use.
however a pool shrinks, minPoolSize
matters, because if the pool shrinks below minPoolSize
, destroyed Connections will be replaced until minPoolSize
is restored.
what is unique about maxIdleTimeExcessConnections
is that it's behavior is directly contingent upon the size of the pool relative to minPoolSize
. all the other parameters and tests just do their thing. if their thing happens to bring the pool to something lower than minPoolSize
, then c3p0 will automatically bring the pool back to minPoolSize
. but maxIdleTimeExcessConnections
is different. it only has any effect when the pool is larger than minPoolSize
.
as you say, maxIdleTimeExcessConnections
is an advanced feature. most users do never and need never use it. it was added because some users wanted to aggressively force pools to shrink back to minPoolSize, but doing that with a very short unconditional maxIdleTime
causes unnecessarily churn through Connections, as Connections even in a minPoolSize
pool are constantly expired and replaced. setting a long or nonexistent maxIdleTime
, while setting a short maxIdleTimeExcessConnections
yields the desired result of fast, aggressive shrinking without churning through Connections once the pool hits minPoolSize
.
but even without maxIdleTimeExcessConnections
set, minPoolSize
matters very much. Connections do get destroyed and expunged from the pool, and minPoolSize
determines a threshhold below which destroyed Connections will be automatically replaced, even if no client load comes to provoke pool expansion.
i hope this makes sense!