Project: Tomcat
Bug 25060 Reloading context orphans currently open jndi datasource connections
Reported: 2003-11-27 21:15:10 | Status: resolved fixed

I fiddled around with this a while and have determined to the best of my ability that this is a real bug. I have a jndi datasource connected to a postgresql server. I have two jndi resources (a reader and writer) so that later I can implement a system with replication etc and deal with writes and reads to different connections. To summarize, after using the system, there are two connections to postgres that get reused -- one reader and writer. Under load, this number increases and will slowly go back down. I usually end up with two idle connections (one reader and one writer) left under no load. If you reload the context where the datasource is at (it's a context specific datasource), the number of connections will jump by two when used. Each reload produces 2 more connections min until I restart the server. It appears that after a reload, the 'persisted connections' get abandoned / orphaned. Eventually, I hit my max connections and cannot aquire any more and the system fails. I have tried the abandond collection parameters and have added debug logging to my code to ensure that I am indeed calling close on the connections I checkout, even on exceptions and error cases. Under normal useage without reloads, no connection leakage happens. This is on a solaris 8 machine with the 4.1.27-hotfix-22096.tar.gz applied. Let me know if more information is required. I have this in a development environment and can let somone attach in jdb and hammer on the thing since it's not a production system -- if that will help in getting a repro. Wayne

Files changed in fix:
java/org/apache/catalina/core/StandardContext.java java/org/apache/catalina/deploy/NamingResources.java