commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Wingert" <martin.wing...@gmail.com>
Subject [DBCP] connections not properly closed
Date Tue, 30 Sep 2008 15:01:12 GMT
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_EXHAUSTED_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,validation_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


Mime
View raw message