We have an application that's using the Tomcat JDBC Connection Pool, configured along with Spring Boot and Hibernate. The connection pool itself is working well (I've been able to verify that through the JMX MBean the pool provides), but a specific parameter doesn't seem to be working.
According to the Tomcat documentation, if "removeAbandoned" is set to true a connection is considered abandoned and eligible for removal if it has been in use longer than the removeAbandonedTimeout. Thus, I've set "removeAbandoned" to true and "removeAbandonedTimeout" to 20 (seconds). I've been able to verify that the two parameters have been properly set as well using the JMX MBean.
In order to test if the abandoned connections were really being removed, I locked one of my database tables manually and opened pages that accessed such a table on several browser tabs. Each one opened a new connection to my database, as I was able to verify both using the JMX MBean and using show status where `variable_name` = 'Threads_connected';
. However, after the 20 seconds had elapsed, none of those connections were removed. I even waited for longer and nothing happened to them until I unlocked the table.
From what I understood from the Tomcat documentation, those connections should all have been eligible for removal since they were both in use and lasted for more than 20 seconds. So what's going on here?
My other parameters are maxActive="75", minIdle="5", maxIdle="5", initialSize="3", validationQuery="SELECT 1" and testWhileIdle="true". I should clarify that all those connections remained active while the table was locked (none became idle again and none were removed from the pool).
EDIT: A correction. Actually, the first connection is being removed, just not the subsequent ones. "logAbandoned" shows all the suspect connections correctly when "suspectTimeout" is set to 20 and "removeAbandoned" is set to false.