You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Vjeran Marcinko <vj...@tis.hr> on 2004/08/18 08:19:06 UTC

[DBCP] Somebody explain me eviction feature ?

Hi again.

Can someone explain me when is eviction feature useful ? 'testOnBorrow'
feature seems to me as really robust way to fetch valid db connections, thus
why is this eviction feature needed anyway ?
Are there some situations when 'testOnBorrow' is not enough ?

Regards,
Vjeran


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [DBCP] Somebody explain me eviction feature ?

Posted by Dirk Verbeeck <di...@pandora.be>.
The eviction feature prevents connections to be broken by firewall 
idle timeout (you set the pool idle timeout lower then the firewall 
idle timeout).

These broken connections will also be detected by the testOnBorrow but 
it depends on the database driver, OS & network how fast this will be 
detected. If there are multiple broken connections in the pool this 
can take a relative long time but eventually all broken connection 
will be removed.

By the way, this won't help against a connection leak. If numActive 
reaches maxActive then all these connections are in use by your 
application and if it doesn't go down then somewhere, somehow the 
close method isn't called.

You could try to enable the abandoned feature or log the pool usage 
(numActive / numIdle) during the day and see how the pool usage evolves.

-- Dirk


Vjeran Marcinko wrote:

> ----- Original Message ----- 
> From: "Dirk Verbeeck" <di...@pandora.be>
> To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
> Sent: Wednesday, August 18, 2004 11:42 AM
> Subject: Re: [DBCP] Somebody explain me eviction feature ?
> 
> 
> 
>>If you use testOnBorrow then you don't need testWhileIdle.
>>Evicting old cnnections is usefull wel you have a database or firewell
>>that closes idle connections.
> 
> 
> But is 'testOnBorrow' sufficient even if I have this situation with firewall
> ? Or eviction feature should be enabled then beside 'testOnBorrow' ?
> 
> I am also wondering if I have this 'invalid' connection in pool, and
> validation querying should discover it, how long does it usually take for
> this validation query to fail (or throw exception) ? Is it momentarily, or
> this thread will wait for a while, thus applicaition user will think it has
> hanged ?
> 
> The reason for all this is because I have case where I use testOnBorrow
> feature (without idle evicting feature), in deployment with firewall between
> my app and db, my app always calls connection.close() in finally block, and
> my app gets stuck once every day. Number of connections in pool gets
> exhausted....
> 
> -Vjeran




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [DBCP] Somebody explain me eviction feature ?

Posted by Vjeran Marcinko <vj...@tis.hr>.
----- Original Message ----- 
From: "Dirk Verbeeck" <di...@pandora.be>
To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
Sent: Wednesday, August 18, 2004 11:42 AM
Subject: Re: [DBCP] Somebody explain me eviction feature ?


> If you use testOnBorrow then you don't need testWhileIdle.
> Evicting old cnnections is usefull wel you have a database or firewell
> that closes idle connections.

But is 'testOnBorrow' sufficient even if I have this situation with firewall
? Or eviction feature should be enabled then beside 'testOnBorrow' ?

I am also wondering if I have this 'invalid' connection in pool, and
validation querying should discover it, how long does it usually take for
this validation query to fail (or throw exception) ? Is it momentarily, or
this thread will wait for a while, thus applicaition user will think it has
hanged ?

The reason for all this is because I have case where I use testOnBorrow
feature (without idle evicting feature), in deployment with firewall between
my app and db, my app always calls connection.close() in finally block, and
my app gets stuck once every day. Number of connections in pool gets
exhausted....

-Vjeran

-Vjeran


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [DBCP] Somebody explain me eviction feature ?

Posted by Dirk Verbeeck <di...@pandora.be>.
The eviction thread will run every "timeBetweenEvictionRunsMillis" ms.
Each run it will test "numTestsPerEvictionRun" connections.
First it will test if a connection has been idle for more then 
"minEvictableIdleTimeMillis" ms and remove the connection if it is too 
old.
Secondly if testWhileIdle is enabled the connection will be tested 
using the validationQuery and invalid connection are removed.
At the end the eviction thread also checks the minIdle and creates new 
connections if needed.

If you use testOnBorrow then you don't need testWhileIdle.
Evicting old cnnections is usefull wel you have a database or firewell 
that closes idle connections.

-- Dirk

Vjeran Marcinko wrote:

> Hi again.
> 
> Can someone explain me when is eviction feature useful ? 'testOnBorrow'
> feature seems to me as really robust way to fetch valid db connections, thus
> why is this eviction feature needed anyway ?
> Are there some situations when 'testOnBorrow' is not enough ?
> 
> Regards,
> Vjeran




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org