Results 1 to 7 of 7
  1. #1
    Join Date
    May 2007
    Posts
    4

    Unanswered: Problem Releasing Connections

    Hello Group,
    I am using postgres in my web application. Number of physical DB connections are just getting increased for each re-deployment of my web application. I generally dont shutdown my webserver and only re-deploy my web application. I heard that "autoReconnect = true" reuses idle connections for each redeployments. I am not sure whether this can help me to make physical DB connections constant.
    My configuration parameters:

    <Resource
    name="jdbc/XXXX"
    scope="Shareable"
    type="javax.sql.DataSource"
    url="jdbcostgresql://mydb.test.com/micms"
    validationQuery="select tablename from pg_tables where schemaname = &#39;gpdb&#39;"
    maxIdle="10"
    maxActive="20"
    maxWait="-1"
    driverClassName="org.postgresql.Driver"
    removeAbandoned="true"
    username="xxxx"
    logAbandoned="true"
    removeAbandonedTimeout="120"
    password="xxxx" />


    Your help would be highly appreciated.

    regards,
    rbaisak

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    does java have no mechanism for releasing connections? Setting them to nothing?
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by loquin
    does java have no mechanism for releasing connections? Setting them to nothing?
    Good point.
    rbaisak, are you sure you are calling close() properly when you don't need the connections any longer?
    But it could be a problem of re-deploying. I usually refrain from doing that as there are two many problems.

  4. #4
    Join Date
    May 2007
    Posts
    4

    No problem with application level connections

    Yes all connections have been closed properly. The problem is with redeployment. E.g. currently application might be using 10 connections and on redeploying these 10 connections should be redeployed but that is not happening.

  5. #5
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Quote Originally Posted by rbaisak
    Yes all connections have been closed properly. The problem is with redeployment. E.g. currently application might be using 10 connections and on redeploying these 10 connections should be redeployed but that is not happening.
    have you explicitly closed ALL the objects that use the connection, as well as the connection itself?

    per apache.org,

    A database connection pool creates and manages a pool of connections to a database. Recycling and reusing already existing connections to a dB is more efficient than opening a new connection.

    There is one problem with connection pooling. A web application has to explicetely close ResultSet's, Statement's, and Connection's. Failure of a web application to close these resources can result in them never being available again for reuse, a db connection pool "leak". This can eventually result in your web application db connections failing if there are no more available connections.
    In your code, make absolutely sure that, for every object you open that is or uses a connection, you explicitly close it. possibly, under certain conditions, something which references a connection may not have been closed.

    I believe, at the application level, you need to RELEASE the connections - not just close them.
    Last edited by loquin; 05-25-07 at 18:27.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  6. #6
    Join Date
    May 2007
    Posts
    4

    Release connection

    I believe, at the application level, you need to RELEASE the connections - not just close them.

    I am not sure what do you mean by releasing connection. I am using DBCP connction pool and it is upto connection pool to manage connections. When I redeploy my application, app server is still running and I canot shut down server. The problem is with reusing the connections. After redeploying, pool should try to get all past connections and reuse them. It seems new connection pool after reploy, does not have any control or unaware of old connections. This is the problem which increases connection with time span.

  7. #7
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    I am not sure what do you mean by releasing connection.
    In other languages, you declare your connection object, you instanciate a copy of the new connection, you open and use the connection, you close the connection, and then you release the connection (set it to nothing) which releases it (or in a connection pool situation, releases the pointer to it) from the application's memory. Thus allowing connection pooling to 're-issue' the connection.

    I am using DBCP connction pool and it is up to connection pool to manage connections.
    Exactly. But, a connection must be released by your app before it can be reassigned by the connection pool manager. It appears that with JDBC, in order to 'release' the connection, not only do you need to close the connection itself, but, apparently, you also need to close every other object that uses your connection before the connection is actually released by your app, and thus made available for reassignment by the pool manager.

    ***

    Now, if your server goes for a month or more before you need to reboot it, it is unlikely that in every case that the connection was not released. Probably only in a small percentage of the times (a few hundred times per month) is it not being released.

    I would revisit (or add) error/exception handling code, to make sure that all database objects are closed under all circumstances.
    Last edited by loquin; 05-28-07 at 03:14.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •