commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Wingert" <martin.wing...@gmail.com>
Subject Re: [DBCP] connections not properly closed
Date Wed, 01 Oct 2008 08:38:57 GMT
Thanks for the tip Wes. Saw the mail conversation from the 17 to 19
Sep about what seems to be a similar issue and your response there.

I would like to remove testOnBorrow since it seems very expensive (as
said in the mail conversation I mention above) but I'm a bit afraid of
getting "dead" connections from the pool. Since the system I have put
the db pool in is pretty big I'm not eager to go through all use of
connections and make them handle that scenario.

I'll change to testWhileIdle and run some tests.

BR // Martin



On Tue, Sep 30, 2008 at 5:16 PM, Wes Clark <wclark@guidewire.com> wrote:
> Set the "testWhileIdle" to test a few connections every so often.  It
> will eject dead connections from the pool.
>
> -----Original Message-----
> From: Martin Wingert [mailto:martin.wingert@gmail.com]
> Sent: Tuesday, September 30, 2008 8:01 AM
> To: user@commons.apache.org
> Subject: [DBCP] connections not properly closed
>
> I'm running dbcp 1.2.2 and mysql-connector-java-5.1.6 on a test system.
>
> Just found that the system after running a couple of hours got an
> exception in the log files when trying to create a new database
> connection:
> java.net.SocketException: Too many open files
>
> Checked the list of open files (lsof) and got a long list:
> java 10659 admin 6u sock 0,4 1555102 can't identify protocol
>
> The PID is the jvm running our system.
>
> Found that the MySQL setting wait_timeout (that closes idle connections
> after the configured time) was set to 60 seconds by accident. So it
> seems that when MySQL closes an idle connection somehow the JDBC
> connection in the database pool isn't closed properly leaving the file
> descriptor open (this is a test system so there are many idle
> connections).
>
>
> This is the code I use to setup my pool:
>
> GenericObjectPool m_generic_objectpool = new GenericObjectPool();
> m_generic_objectpool.setMaxActive(connection_timeout);
> m_generic_objectpool.setMaxWait(max_wait);
> m_generic_objectpool.setTestOnBorrow(true);
> m_generic_objectpool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAU
> STED_BLOCK);
>
> ConnectionFactory connectionFactory = new
> DriverManagerConnectionFactory(full_url,conProp);
>
> AbandonedConfig ab_conf = new AbandonedConfig();
> ab_conf.setRemoveAbandonedTimeout(m_dbpool_abandoned_timeout);
> ab_conf.setRemoveAbandoned(m_dbpool_close_abandoned);
>
> String validation_query = new String("SELECT 1"); new
> PoolableConnectionFactory(connectionFactory,m_generic_objectpool,null,va
> lidation_query,false,true,ab_conf);
>
> PoolingDataSource data_source = new
> PoolingDataSource(m_generic_objectpool);
>
>
> Thankful for any help
>
> BR // Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Mime
View raw message