In my Java spring boot READ ONLY application (no write happens from the application), the DB connection is not closed in many methods. So when we deployed the application in Jboss and configured the CCM and DB connection logging in standalone.xml as below
<logger category="org.jboss.jca">
<level name="DEBUG"/>
</logger>
<cached-connection-manager debug="true" error="true"/>
The DB Connection leakage is showed in the logs,
14:44:59,620 INFO [org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager] (default task-19) IJ000100: Closing a connection for you. Please close them yourself: org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8@2e62903a: java.lang.Throwable: STACKTRACE
at org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManagerImpl.registerConnection(CachedConnectionManagerImpl.java:308)
at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:819)
at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:151)
at org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:64)
...
at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1280)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.resource.ResourceException: IJ000151: Some connections were not closed, see the log for the allocation stacktraces
at org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManagerImpl.popMetaAwareObject(CachedConnectionManagerImpl.java:289)
at org.jboss.as.connector.deployers.ra.processors.CachedConnectionManagerSetupProcessor$CachedConnectionManagerSetupAction.teardown(CachedConnectionManagerSetupProcessor.java:116)
... 13 more
But when I check the getConnection and returnConnection logs, it shows that there is no Active connections (Action connection shows as '0' in the 0/100 and Total Connection in pool is '100'), so I would like to know If there is a connection leakage why still the Active connection is showing as '0' in the returnConnection method?
Return Connection logs:
15:27:42,366 DEBUG [org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory] (default task-25) java.sql.Connection#endRequest has been invoked
15:27:42,366 DEBUG [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (default task-25) XXDB: returnConnection(557f1b10, false) [0/100]
Remove Idle Connection logs:
15:27:40,833 DEBUG [org.jboss.jca.core.connectionmanager.pool.idle.IdleRemover] (IdleRemover) Notifying pools, interval: 60000
15:27:40,833 DEBUG [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (IdleRemover) XXDB: removeIdleConnections(1708269940833) [0/100]
Get Connection Logs:
15:27:41,448 DEBUG [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (default task-25) XXDB: getConnection(null, WrappedConnectionRequestInfo@5e9a45d6[userName=xxxxxx]) [0/100]
- So If the ActionConnection is '0', then it means that the connection is returned back to the pool, Is my understand correct.
- If the connection is not closed in the code and also the DB connection leakage is shown in the logs as above - How does the connection went back to the pool?
Any help on this is appreciated.
Thanks,
Harry