commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 37926] New: - BasicDataSource.createDataSource() memory leak on SQLExceptions
Date Thu, 15 Dec 2005 23:47:53 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37926>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37926

           Summary: BasicDataSource.createDataSource() memory leak on
                    SQLExceptions
           Product: Commons
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Dbcp
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: ekaufman@infinitecampus.com


Using:
commons-dbcp-1.2.1
commons-pool-1.2

When using BasicDataSource, if the datasource is initialized while the database 
is down, or a wrong user/pass is given, each call to getConnection() results in 
a memory leak.

Here's what I've tracked down:

In the BasicDataSource.createDataSource method, if the datasource was 
previously un-initialized, a new GenericObjectPool (or AbandonedObjectPool 
depending on configuration) is always instantiated.

The GenericObjectPool constructor (and also the call to 
setTimeBetweenEvictionRunsMillis()) starts a new thread for the Evictor.  This 
thread runs until it's cancel() is called.

The problem is that if a SQLException is thrown when the 
PoolableConnectionFactory is instantiated (like with a bad user/pass), the 
exception is rethrown, but no attempt is made to clean up the Evictor thread 
that was started in the GenericObjectPool, so that thread just keeps running 
forever.  Since this happens before the datasource was created, the next call 
to getConnection() will again attempt to re-initialize the datasource in 
createDataSource(), and if the same error happens again, another Evictor thread 
will be left running, -> repeat a few thousand times and it starts to bring 
down systems.

Changing BasicDataSource to only initialize the connectionPool when it is null 
seemed resolve the issue.  Alternatively, catching the exception, and calling 
close() on the pool (which then cancel()'s the Evictor) also seemed to work.

Environment:
WinXP
SQL2000
JSQLConnect driver

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message