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" <jone...@hotwaxmedia.com>
To: <u...@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