Connection still active when session is closed

2,625 views
Skip to first unread message

Matte

unread,
Nov 8, 2017, 4:11:56 AM11/8/17
to HikariCP
I have a spring mvc+hibernate application that uses hikaricp as connection-pool, database is mysql. This is my configuration (quite standard):

<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<property name="poolName" value="springHikariCP" />
<property name="maximumPoolSize" value="100" />
<property name="jdbcUrl" value="${tomcat.jdbc.url}"/>
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="username" value="${tomcat.jdbc.username}"/>
<property name="password" value="${tomcat.jdbc.password}"/>
<property name="idleTimeout" value="600000"/>
<property name="maxLifetime" value="1800000"/>
<property name="dataSourceProperties">
<props>
<prop key="cachePrepStmts">true</prop>
<prop key="prepStmtCacheSize">250</prop>
<prop key="prepStmtCacheSqlLimit">2048</prop>
<prop key="useServerPrepStmts">true</prop>
<prop key="useLocalSessionState">true</prop>
<prop key="useLocalTransactionState">true</prop>
<prop key="rewriteBatchedStatements">true</prop>
<prop key="cacheResultSetMetadata">true</prop>
<prop key="cacheServerConfiguration">true</prop>
<prop key="elideSetAutoCommits">true</prop>
<prop key="maintainTimeStats">false</prop>
</props>
</property>
</bean>

<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"> <constructor-arg ref="hikariConfig" /> </bean>

It works fine but I noticed that when the application session is expired (session-timeout by web.xml) or invalidated by explicit logout, the connections remain active so their number is increasing. And hikaricp 
doesn't close that connection used by application even after the maxLifetime time.

03/11 16:34:20.312 DEBUG [springHikariCP connection closer][PoolBase] springHikariCP - Closing connection com.mysql.jdbc.JDBC4Connection@4bf3cc97: (connection has passed maxLifetime) 
03/11 16:34:20.396 DEBUG [springHikariCP connection adder][HikariPool] springHikariCP - Added connection com.mysql.jdbc.JDBC4Connection@69b86e55 
03/11 16:34:49.101 DEBUG [springHikariCP housekeeper][HikariPool] springHikariCP - Pool stats (total=100, active=4, idle=96, waiting=0)


Am I missing something? How do I change my code or configuration?

Thanks in advance

Cheers

Matteo

Brett Wooldridge

unread,
Nov 8, 2017, 6:36:06 AM11/8/17
to HikariCP
Sounds like a Connection leak. Set the leakDetectionThreshold to something like 1 minute (60000ms) and watch your logs.

Matte

unread,
Nov 8, 2017, 11:54:54 AM11/8/17
to HikariCP
Yes, it's a connection leak issue. Now I'm going to investigate on it.
Thanks

ankit patel

unread,
Feb 8, 2018, 7:54:34 AM2/8/18
to HikariCP
Hi Matte,

Did you found any root cause?
Reply all
Reply to author
Forward
0 new messages