'Can "maxAge" of "org.apache.tomcat.jdbc.pool.DataSourceFactory" impact active database connection
This is what is our PROD scenario:
- We are using
org.apache.tomcat.jdbc.pool.DataSourceFactoryand having maxAge of900000andmaxActiveof100. - 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
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharman |
