On 10/15/2012 2:16 PM, g. rgar wrote:
Thanks for the attention
No I am not leaking connections - definitely. I don't use a single
connection to the DB in the scenario posted. I just undeploy and deploy the
application via Eclipse.
I do think it may be related to the thread issue - you know better of
course. Tomcat kills the thread and this thread is responsible for cleaning
abandoned connections. Does it make sense ? The threads name is :
[Abandoned connection cleanup thread]
SEVERE: The web application [/ted2012] appears to have started a thread
named [Abandoned connection cleanup thread] but has failed to stop it. This
is very likely to create a memory leak.
@Shultz ; what do yu mean by "While it is possible, your connection pool
should be complaining about that. "
"Have you enabled removeAbandoned and logAbandoned for your
connections" see my first post : remove abandoned is true - I may add log
abandoned
On Mon, Oct 15, 2012 at 10:16 PM, Christopher Schultz <
[email protected]> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
g rgar,
On 10/14/12 6:00 PM, g. rgar wrote:
maybe this is related also :
http://bugs.mysql.com/bug.php?id=65909
If true then a workaround must be made available
I've looked at this bug and it has nothing to do with connections
remaining open. That bug is about a thread with the webapp's context
class loader causing the webapp's ClassLoader to be pinned in memory
after a webapp stop.
Unfortunately, this mailing list thread has been picked-up as a
symptom of the threading bug which is entirely untrue.
- -chris
Warning - War and Peace ahead. Proceed at your own risk.
This is long again, but hopefully illuminating.
My environment of the day:
OS: Windows 7 Home Premium 64 bit
JDK/JRE: 1.7.0_7
IDE 1: Eclipse Juno - latest updates
IDE 2: NetBeans 7.2 - latest updates
Project: A small Maven-based J2EE 5 application
Tomcat: 7.0.30 with tcnative
MySQL: 5.5.22
MySQL JDBC: 5.1.18
MySQL WorkBench: 5.2.44 CE
The following occurs regardless of how I launch the application:
1. From Eclipse IDE
2. From NetBeans IDE
3. From Manager application
In the past I've stress-tested this application with JMeter for 8 hours
with no errors generated by running out of database connections.
Using the following context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/LeakRS">
<Resource auth="Container"
description="Beer Store"
driverClassName="com.mysql.jdbc.Driver"
maxActive="10"
maxIdle="3"
maxWait="10000"
name="jdbc/leakrs"
password="XXXXX"
testOnBorrow="true"
removeAbandoned="true"
logAbandoned="true"
type="javax.sql.DataSource"
url="jdbc:mysql://localhost/leakrs"
username="XXXXX"
validationQuery="SELECT 1"/>
</Context>
When watching the number of connections with MySQL Workbench, I only see
one connection. I didn't really stress the application in this series of
tests.
Once the application is unloaded, the connection goes away. The Tomcat
manager application reports no memory leaks.
I've seen the maximum number of connections during the stress test,
which then tapers off to maxIdle.
With the following context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/LeakRS">
<Resource auth="Container"
description="Beer Store"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
maxActive="10"
maxIdle="3"
maxWait="10000"
name="jdbc/leakrs"
password="XXXXX"
testOnBorrow="true"
removeAbandoned="true"
logAbandoned="true"
type="javax.sql.DataSource"
url="jdbc:mysql://localhost/leakrs"
username="XXXXX"
validationQuery="SELECT 1"/>
</Context>
I get 10 connections immediately.
I also get the following complaint in catalina.DATE.log:
Oct 15, 2012 4:14:43 PM org.apache.tomcat.jdbc.pool.ConnectionPool init
WARNING: maxIdle is smaller than minIdle, setting maxIdle to: 10
These 10 connections will never go away, and will never be reused
(according to MySQL WorkBench). Reloading the application will generate
another 10 connections, etc., etc., etc.
After unloading the web application and checking for leaks with the
Tomcat manager, I get a complaint about a leaking web application.
A quick search through the heap dump didn't reveal anything, but I
wasn't very thorough.
If I use the following context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/LeakRS">
<Resource auth="Container"
description="Beer Store"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
maxActive="10"
maxIdle="3"
minIdle="1"
maxWait="10000"
name="jdbc/leakrs"
password="XXXXXX"
testOnBorrow="true"
removeAbandoned="true"
logAbandoned="true"
type="javax.sql.DataSource"
url="jdbc:mysql://localhost/leakrs"
username="XXXXXX"
validationQuery="SELECT 1"/>
</Context>
I get 10 connections immediately.
However, after sitting around for maxWait (which appears to be in
milliseconds?), the idle connections get closed with the exception of
the one as specified by minIdle.
The remaining idle connection is never closed, even when the web
application is unloaded.
Interestingly enough, with this configuration the Tomcat manager does
not complain about a leaking application.
At no point in any of these tests do I see any log messages concerning
abandoned connections. Since the maxWait time (100 sec) is quite a bit
shorter than the default removeAbandoned time (300 sec), the closing of
the idle connections cannot be attributed to removeAbandoned.
In short, there appears to be at least three issues when using
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory".
1. minIdle is set to maxActive rather than maxIdle when minIdle not
configured?
2. memory leak as reported by Tomcat manager when minIdle not
explicitly set?
3. Database connection not removed when web application unloaded?
The short fix to minimize the impact seems to be to configure minIdle
when using factory="org.apache.tomcat.jdbc.pool.DataSourceFactory".
. . . . just my long-winded 2 cents.
/mde/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]