Bug 29497

Summary: Connection pool, redeployment
Product: Tomcat 5 Reporter: dima <cactus>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 5.0.9   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description dima 2004-06-10 14:11:17 UTC
My application uses database for storing information, particularly mysql.

During it's work it takes 4 connections from the connection pool.
At this moment number number of physical connections to database increases by 4.
Then connection are being closed from inside the application.
Number of physical connections does not decrease. As I suspect these connections
are in pool.
When application takes those 4 connections again number of physical connections
stays the same, i.e. everything is ok.
But when I redeploy application connection pool does not release physical
connections, i.e. each time after application is being redeployed, number of
physical connections increases by 4 until I get exception: too many opened
connections.

This problem occurs with Tomcat 5.0.9 on WinXP with DBCP 1.1 / 1.2
and Tomcat 5.0.25 on FreeBSD. Mysql is run on FreeBSD
Comment 1 Albert Tumanov 2005-05-19 10:44:12 UTC
I have the same problem on Tomcat 5.0.28, WinXP and Oracle (different versions).

Steps to reproduce:
1) set up a datasource under some specific context, 
   setting parameter maxIdle to 1 or more
2) create an application (servlet) that uses the datasource to open (and close)
a connection
3) run the servlet once
4) check that there is a connection created 
   (e.g. by using Oracle query "select * from v$session")
5) reload the application (using Tomcat Manager or automatic reloading)
6) check that the connection is still open
   (e.g. by using Oracle query "select * from v$session")
7) run the servlet once
8) check that there is a NEW connection created 
   (e.g. by using Oracle query "select * from v$session")

Expected result: 
when reloading the application, the connection pool associated with its context
should be closed and all its connections also closed (step 6).

Remarks:
1) if on step 5 I restart Tomcat server instead of reloading one application,
the connection pool's connections are closed as expected
2) if I set maxIdle to 0 when configuring the datasource (step 1),
then connections are closed immediately when the application releases them.
This indicates that the application closes the used connections correctly.

See also:
http://mail-archives.apache.org/mod_mbox/jakarta-commons-user/200307.mbox/%3CODENKBKODJNAIPLEPKHHKEAACDAA.mholly@talisentech.com%3E
Comment 2 VickyKak 2006-06-15 04:51:38 UTC
Can you guys test setting this 
<parameter>
  <name>removeAbandoned</name>
  <value>true</value>
</parameter>

in the Resource tag as explained here 
http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html

Regards
Vicky
Comment 3 Mark Thomas 2006-08-01 02:16:09 UTC

*** This bug has been marked as a duplicate of 37262 ***