TomcatExpert

Tomcat-jdbc pooling not detecting dead connections

We recently migrated to using the apache tomcat jdbc connection pooling.

We are using v1.1.0.1 of the connection pooling mechanism with tomcat 6.0.33 on Oracle 10g

Our connection pools are configured as follows:

<Resource name="jdbc/testPool" auth="Container"
              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
          factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
          url="jdbc:oracle:thin:@192.168.1.11:1521:TESTDB"
              username="user" password="xxx" initialSize="2" maxActive="5" minIdle="1" maxIdle="2"
              maxWait="1" removeAbandoned="true" removeAbandonedTimeout="15"  logAbandoned="true"    abandonWhenPercentageFull="100"  jdbcInterceptors="ResetAbandonedTimer"/>

The application works fine in normal situations but we noticed the following problems:-

a) When the ResetAbandonedTimer kicks in the connection itself does not get discarded and the app when it requests a new connection gets handed the connection that was already killed by the ResetAbandonedTimer mechanism .

b) We were also able to easily reproduce the above issue by running the application and then killing the idle connection from the oracle end. I would expect that if a connection gets killed from the oracle end the connection pool should detect it and log and discard the connection. However the apache-tomcat-jdbc pooling mechanism as configured in my setup does not seem to detect this condition at all. It waits silently till the app requests another connection and returns the dead connection to the app which of course fails as soon as the app tries to use the connection.

asked by san9jay

question

add

testOnBorrow="true"

validationQuery="select 1 from dual"

in order to validate your connections

answer

answered by fhanik on May 10, 2012 08:39 AM

Filip Hanik is a Senior Software Engineer for the SpringSource Division of VMware, Inc. (NYSE: VMW) and a key participant in the company's Apache Tomcat initiatives. Filip brings 15 years of extensive experience in architecture, design and development of distributed application frameworks and containers and is recognized for his top-quality system development skills and continuous participation of Open Source development projects. Filip is an Apache Software Foundation member and a committer to the Apache Tomcat project where he is a leading authority on Tomcat clustering and a key contributor to the core of the platform. Filip has made contributions to software initiatives for Walmart.com, Sony Music, France Telecom and has held a variety of senior software engineering positions with technology companies in both the United States and Sweden. He received his education at Chalmers University of Technology in Gothenburg, Sweden where he majored in Computer Science and Computer Engineering.

Comments

workaround

adding the following to the connection pool config is a workaround but I would think a dead connection should be detected out of the box. the

testOnBorrow="true" validationQuery="SELECT 1 from dual" validationInterval="30000"

Regards

/sanjay

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.