Can "maxAge" of "org.apache.tomcat.jdbc.pool.DataSourceFactory" impact active database connection

Viewed 527

This is what is our PROD scenario:

  • We are using org.apache.tomcat.jdbc.pool.DataSourceFactory and having maxAge of 900000 and maxActive of 100.
  • We have long database operation and it is failing because of database connection closed exception.
  • When I checked the logs then I found that this exception is occurring after ~15 minutes.

So, this makes me wonder if this is because of maxAge of 900000. I read the docs of Apache and other blogs but no where I could find a clear answer whether maxAge will impact an active database connection or not.

From the docs only thing I am 100% sure of is that maxAge is checked when moving a database connection in or out of the pool, but I not sure on what happens once database connection is in use...

Has anyone having similar experience with this or knows if maxAge impacts an active connection or not?


UPDATE 1:

I am using Tomcat 8.5

1 Answers

According to this it will not close your connection that's already in use. It rather checks for the age before returning it to the pool - after you released the connection. And closes if max age has elapsed. We went from no-max-age to 10 minutes and didn't see the issue you're reporting.

From the documentation,

When a connection is returned to the pool, the pool will check to see if the now - time-when-connected > maxAge has been reached, and if so, it closes the connection rather than returning it to the pool.

Related