commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn Nielsen <>
Subject Re: [DBCP] AbandonedTrace - Connection Recovery
Date Wed, 23 Jul 2003 15:16:10 GMT

David Graham wrote:
> --- "Hope, Matthew" <> wrote:
>>>-----Original Message-----
>>>From: Glenn Nielsen [] 
>>>Sent: 23 July 2003 13:52
>>>To: Jakarta Commons Developers List
>>>Subject: Re: [DBCP] AbandonedTrace - Connection Recovery
>>>Hope, Matthew wrote:
>>>>I would disagree on one point. The idea of logging when a 
>>>connection is
>>>>closed due to garbage collection finalization strikes me as 
>>>a good one
>>>>(assuming the pool used is using a weakly referenced 
>>>mapping otherwise
>>>>garbage collection release of resources is going to be a 
>>>real bummer).
>>>Using GC to log or recover an abandoned connection won't work 
>>>because the
>>>connection is a member of the pool and will never be eligible for GC.
>>I feel you may have missed my comment above to the effect that the pool
>>using a weakly referenced map.
> Using a WeakHashMap might be a good solution.  Connections are guaranteed
> to be closed when they are garbage collected so if a client doesn't return
> a connection and loses all pointers to it, the pool would lose its
> reference to it and the Connection would get gc'd.  This is *much* better
> than grabbing a connection away from the client application that may still
> be using it.

Using a weak reference for pooled connections which are in use is a good idea
and I am all for it.

The only problem is that there is no guarantee when the weak referenced
db connection pool object will be GC'd.  That is highly dependent upon
how the JVM implements GC.  There is no guarantee that this would prevent
abandoned connections from causing the pool to be exhausted.

> What would happen to the connection when it gets closed by garbage
> collection though?  Since it's a pooled connection, calling close() tries
> to return it to the pool but the pool lost its reference to the connection
> when the client didn't return it.  How would the pool ensure the
> connection originated from the pool?

I'm sure that can be worked through.

> David
>>In those circumstances garbage collection would free resources. I would
>>think that their use is sensible so long as the pool can handle their
>>garbage collection and get another one (though that may have the knock
>>effect of causing the getting of the connection to be synchronized to
>>client request - not a huge big deal in most cases but in a well managed
>>resource environment such weak references would be unnecessary.
>>for an explanation see:
> **************************************************************************
>>The information transmitted herewith is sensitive information intended
>>for use by the individual or entity to which it is addressed. If the
>>of this message is not the intended recipient, you are hereby notified
>>any review, retransmission, dissemination, distribution, copying or
>>use of, or taking of any action in reliance upon this information is
>>strictly prohibited. If you have received this communication in error,
>>please contact the sender and delete the material from your computer.
>>To unsubscribe, e-mail:
>>For additional commands, e-mail:
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Glenn Nielsen    | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message