tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Cheshire <yahoono...@gmail.com>
Subject tomcat connection pool not closing properly
Date Thu, 26 Apr 2018 14:23:42 GMT
[ tomcat 8.5.30, mysql server 5.7.22, connector/j 5.1.46, centos 6, debian 8. ]

I recently upgraded my sandboxes from 8.5.24 to 8.5.28 and now .30 and
I have noticed that when a webapp is reloaded via the host manager,
the associated connection pool is not getting closed down properly in
the database.

I am not getting abandoned connection warnings in tomcat, rather mysql
eventually complains because its max connections has been exceeded. If
I run "show full processlist" in mysql after every reload, there are
now an extra 5 open connections for the webapp user. It seems that the
connection pools are still active, because the connection time column
cycles between 0 and timeBetweenEvictionRunsMillis (in seconds). The
connections themselves are not showing anything running on them
however.

Once I shutdown the tomcat process entirely, everything closes and
there are no errors in the tomcat logs about abandoned connections.

This wasn't the case sometime around 8.5.24. I'm not sure if this is a
problem in mysql or tomcat as I have upgraded mysql, the connector and
tomcat. I don't know where to look so I'll start here.

I have the following in my context.xml for my webapp's connection pool

  <Resource name="jdbc/mysql"
            auth="Container"
            type="javax.sql.DataSource"
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://$dbHost$:3306/$dbSchema$?useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false"
            factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
            username="$dbUser$"
            password="$dbPassword$"
            initialSize="5"
            minIdle="5"
            maxActive="25"
            maxIdle="10"
            maxWait="30000"
            removeAbandoned="true"
            removeAbandonedTimeout="60"
            logAbandoned="true"
            validationQuery="/* ping */"
            testOnBorrow="true"
            testWhileIdle="true"
            timeBetweenEvictionRunsMillis="30000"
            defaultAutoCommit="false"
            rollbackOnReturn="true" />

I start tomcat via a systemd service unit.

# /etc/systemd/system/tomcat1.service
[Unit]
Description=Apache Tomcat Web Application Container (sandbox1)
Wants=network.target
After=syslog.target network.target

[Service]
Type=forking

EnvironmentFile=-/etc/default/tomcat1

ExecStart=/opt/apache-tomcat-8.5.30/bin/catalina.sh start
ExecStop=/opt/apache-tomcat-8.5.30/bin/catalina.sh stop

User=sandbox1
Group=sandbox1
UMask=0007

[Install]
WantedBy=multi-user.target

# /etc/default/tomcat1
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
CATALINA_HOME=/opt/apache-tomcat-8.5.30
CATALINA_BASE=/home/sandbox1/tomcat
CATALINA_OUT=/home/sandbox1/tomcat/logs/catalina.out
CATALINA_PID=/home/sandbox1/tomcat/tomcat.pid

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message