You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Hans Holmlund <ha...@excito.se> on 2008/01/31 08:37:05 UTC

Stale DB-connections

I have just upgraded to the latest version of Entity Engine and stumbled 
upon a problem. The problem I had was that db-connections were dropped 
after awhile but without actually closing the TCP session with the 
database. So when I checked with netstat I had a lot of connections in a 
CLOSE_WAIT state. I'm using MySQL but I guess this may happen with other 
databases too.
I had a look in the code and come up with a fix. In 
DBCPConnectionFactory (row 96) there is a line saying:
    pool.setTimeBetweenEvictionRunsMillis(600000);

In GenericPool to set this parameter has the effect of creating an 
eviction thread, so every 10 minutes the pool will be checked if there 
exist any unused objects. The problem seems to be when the object is 
evicted, I'm not sure what is happening but the object is not correctly 
removed.
I don't think that this cleaning procedure is necessary, if I have set 
the pool-maxsize to 200 I can probably live with that the actual 
pool-size never shrinks.
So I made this change:
    pool.setTimeBetweenEvictionRunsMillis(-1);
The eviction thread will not be created. And after I made this change I 
have not had any problems with stale DB-connections.

/ Hans Holmlund

Re: Stale DB-connections

Posted by Jacques Le Roux <ja...@9business.fr>.
Sorry to bring back this old user thread on dev ML, but I think we should defintively made this configurable. At least to allow 
people to easily
try 2 basic configurations (ie -1 or 600000) and especially to make people aware of possible problems there.
The related doc is here http://commons.apache.org/dbcp/configuration.html.

Jacques

From: "David E Jones" <jo...@hotwaxmedia.com>
To: <us...@ofbiz.apache.org>
Sent: Thursday, January 31, 2008 8:10 PM
Subject: Re: Stale DB-connections


>
> This is an interesting find Hans.
>
> Has anyone noticed, or tested, this with other databases (ie other  than MySQL which is what Hans mentions testing with)?
>
> The big question in my mind is do we turn it off altogether, or make  it a configurable option with recommended settings for
> different  databases?
>
> If anyone can take a peek at their system(s) and offer feedback that  would be great.
>
> -David
>
>
> On Jan 31, 2008, at 12:37 AM, Hans Holmlund wrote:
>
>> I have just upgraded to the latest version of Entity Engine and  stumbled upon a problem. The problem I had was that
>> db-connections  were dropped after awhile but without actually closing the TCP  session with the database. So when I checked with
>> netstat I had a  lot of connections in a CLOSE_WAIT state. I'm using MySQL but I  guess this may happen with other databases too.
>> I had a look in the code and come up with a fix. In  DBCPConnectionFactory (row 96) there is a line saying:
>>   pool.setTimeBetweenEvictionRunsMillis(600000);
>>
>> In GenericPool to set this parameter has the effect of creating an  eviction thread, so every 10 minutes the pool will be checked
>> if  there exist any unused objects. The problem seems to be when the  object is evicted, I'm not sure what is happening but the
>> object is  not correctly removed.
>> I don't think that this cleaning procedure is necessary, if I have  set the pool-maxsize to 200 I can probably live with that the
>> actual  pool-size never shrinks.
>> So I made this change:
>>   pool.setTimeBetweenEvictionRunsMillis(-1);
>> The eviction thread will not be created. And after I made this  change I have not had any problems with stale DB-connections.
>>
>> / Hans Holmlund
>
>



Re: Stale DB-connections

Posted by Jacques Le Roux <ja...@9business.fr>.
Sorry to bring back this old user thread on dev ML, but I think we should defintively made this configurable. At least to allow 
people to easily
try 2 basic configurations (ie -1 or 600000) and especially to make people aware of possible problems there.
The related doc is here http://commons.apache.org/dbcp/configuration.html.

Jacques

From: "David E Jones" <jo...@hotwaxmedia.com>
To: <us...@ofbiz.apache.org>
Sent: Thursday, January 31, 2008 8:10 PM
Subject: Re: Stale DB-connections


>
> This is an interesting find Hans.
>
> Has anyone noticed, or tested, this with other databases (ie other  than MySQL which is what Hans mentions testing with)?
>
> The big question in my mind is do we turn it off altogether, or make  it a configurable option with recommended settings for
> different  databases?
>
> If anyone can take a peek at their system(s) and offer feedback that  would be great.
>
> -David
>
>
> On Jan 31, 2008, at 12:37 AM, Hans Holmlund wrote:
>
>> I have just upgraded to the latest version of Entity Engine and  stumbled upon a problem. The problem I had was that
>> db-connections  were dropped after awhile but without actually closing the TCP  session with the database. So when I checked with
>> netstat I had a  lot of connections in a CLOSE_WAIT state. I'm using MySQL but I  guess this may happen with other databases too.
>> I had a look in the code and come up with a fix. In  DBCPConnectionFactory (row 96) there is a line saying:
>>   pool.setTimeBetweenEvictionRunsMillis(600000);
>>
>> In GenericPool to set this parameter has the effect of creating an  eviction thread, so every 10 minutes the pool will be checked
>> if  there exist any unused objects. The problem seems to be when the  object is evicted, I'm not sure what is happening but the
>> object is  not correctly removed.
>> I don't think that this cleaning procedure is necessary, if I have  set the pool-maxsize to 200 I can probably live with that the
>> actual  pool-size never shrinks.
>> So I made this change:
>>   pool.setTimeBetweenEvictionRunsMillis(-1);
>> The eviction thread will not be created. And after I made this  change I have not had any problems with stale DB-connections.
>>
>> / Hans Holmlund
>
>



RE: Stale DB-connections

Posted by "LECOCQ Michel (CAMPUS)" <mi...@decathlon.com>.
Hello

I've tested  with the two connection factory classes (minerva and dbcp)
on mysql and oracle databases.
With minerva, no problem occured.
With DBCP, the limit of pool-maxsize value  from the datasource is not
respected and the connections increase until reaching the connections
max value defined on the database.
The db-connections are not correctly removed too.

Regards.

Michael.

-----Original Message-----
From: David E Jones [mailto:jonesde@hotwaxmedia.com] 
Sent: Thursday, January 31, 2008 7:10 PM
To: user@ofbiz.apache.org
Subject: Re: Stale DB-connections


This is an interesting find Hans.

Has anyone noticed, or tested, this with other databases (ie other than
MySQL which is what Hans mentions testing with)?

The big question in my mind is do we turn it off altogether, or make it
a configurable option with recommended settings for different databases?

If anyone can take a peek at their system(s) and offer feedback that
would be great.

-David


On Jan 31, 2008, at 12:37 AM, Hans Holmlund wrote:

> I have just upgraded to the latest version of Entity Engine and 
> stumbled upon a problem. The problem I had was that db-connections 
> were dropped after awhile but without actually closing the TCP session

> with the database. So when I checked with netstat I had a lot of 
> connections in a CLOSE_WAIT state. I'm using MySQL but I guess this 
> may happen with other databases too.
> I had a look in the code and come up with a fix. In 
> DBCPConnectionFactory (row 96) there is a line saying:
>   pool.setTimeBetweenEvictionRunsMillis(600000);
>
> In GenericPool to set this parameter has the effect of creating an 
> eviction thread, so every 10 minutes the pool will be checked if there

> exist any unused objects. The problem seems to be when the object is 
> evicted, I'm not sure what is happening but the object is not 
> correctly removed.
> I don't think that this cleaning procedure is necessary, if I have set

> the pool-maxsize to 200 I can probably live with that the actual 
> pool-size never shrinks.
> So I made this change:
>   pool.setTimeBetweenEvictionRunsMillis(-1);
> The eviction thread will not be created. And after I made this change 
> I have not had any problems with stale DB-connections.
>
> / Hans Holmlund

Re: Stale DB-connections

Posted by David E Jones <jo...@hotwaxmedia.com>.
This is an interesting find Hans.

Has anyone noticed, or tested, this with other databases (ie other  
than MySQL which is what Hans mentions testing with)?

The big question in my mind is do we turn it off altogether, or make  
it a configurable option with recommended settings for different  
databases?

If anyone can take a peek at their system(s) and offer feedback that  
would be great.

-David


On Jan 31, 2008, at 12:37 AM, Hans Holmlund wrote:

> I have just upgraded to the latest version of Entity Engine and  
> stumbled upon a problem. The problem I had was that db-connections  
> were dropped after awhile but without actually closing the TCP  
> session with the database. So when I checked with netstat I had a  
> lot of connections in a CLOSE_WAIT state. I'm using MySQL but I  
> guess this may happen with other databases too.
> I had a look in the code and come up with a fix. In  
> DBCPConnectionFactory (row 96) there is a line saying:
>   pool.setTimeBetweenEvictionRunsMillis(600000);
>
> In GenericPool to set this parameter has the effect of creating an  
> eviction thread, so every 10 minutes the pool will be checked if  
> there exist any unused objects. The problem seems to be when the  
> object is evicted, I'm not sure what is happening but the object is  
> not correctly removed.
> I don't think that this cleaning procedure is necessary, if I have  
> set the pool-maxsize to 200 I can probably live with that the actual  
> pool-size never shrinks.
> So I made this change:
>   pool.setTimeBetweenEvictionRunsMillis(-1);
> The eviction thread will not be created. And after I made this  
> change I have not had any problems with stale DB-connections.
>
> / Hans Holmlund