[jira] Commented: (DBCP-156) [dbcp] Specifying the maximum lifetime of a connection

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[jira] Commented: (DBCP-156) [dbcp] Specifying the maximum lifetime of a connection

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/DBCP-156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877113#action_12877113 ]

Garick Hamlin commented on DBCP-156:

I am completely new to dbcp, so perhaps I am barking up the wrong tree here, but this feature is exactly what I was just now looking for in the documentation.

BTW, I wanted this for a postgres setup, not mysql so the feature is generic.

There are good reasons to have a maximum connection life.
+ It is handy for graceful downtime free maintenance by allowing tomcat tcp sessions to be migrated one at a time
+ It help deals with things that shouldn't happen like memory leaks in a database backend.  This is not a problem
I am currently experiencing, but it a good practice to have a maximium lifetime in case a leak was introduced this
would make it non-critical to operations.

A connect costs a few milliseconds.   Having a lifetime of 10 seconds would be a huge benefit for failover.  A connect costs a milliseconds, re-prepares are often cheap and may actually improve performance for me on this app.

Basically the high level design was looking like this:
[ App ] -> [ DBCP ] -> [ pgbouncer ] -> [ postgres cluster ]

(I could eliminate pgbouncer here and replace it with stateful NAT but by having pgbouncer there I can have pgbouncer allow connect / logins to succeed and cause things to merely block  briefy during switchover so the change is more transparent.)

So, I think this is useful.

If dbcp had it ... I would probably use dbcp.  I may or may not use it as it stands now..

> [dbcp] Specifying the maximum lifetime of a connection
> ------------------------------------------------------
>                 Key: DBCP-156
>                 URL: https://issues.apache.org/jira/browse/DBCP-156
>             Project: Commons Dbcp
>          Issue Type: Improvement
>    Affects Versions: 1.1
>         Environment: Operating System: All
> Platform: All
>            Reporter: Juergen Hoeller
>            Priority: Minor
>             Fix For: 2.0
> It would be excellent if BasicDataSource had a "maxLifetime" property, for
> specifying the maximum lifetime of a connection in the pool, no matter how long
> it's been active or idle, and no matter whether it still seems to be alive.
> Commons DBCP does not support this yet; it just offers various connection
> validation means, which is not the same.
> This is particularly relevant for MySQL Connector/J 3.0.x which tries to apply
> some weird automatic recovery when a MySQL connection has timed out, resulting
> in all sorts of issues. The best way to deal with this is to set the maximum
> lifetime of a connection to 4 hours or the like: If it's older, simply kill it,
> even if it's still alive at that point of time.
> Note that Proxool (http://proxool.sourceforge.net) does have such a property,
> namely "maximum-connection-lifetime". Resin's connection pool has a similar
> property named "max-pool-time" (http://www.caucho.com/resin-2.1/ref/db-
> config.xtp). I tend to prefer Commons DBCP, but the lack of such a property
> forces me to look for alternative pools.
> Juergen

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.