Have you came accross issues with your application which is deployed in Jboss EAP trying to find answers for the following questions.
-
How can I detect leaked datasource connections ??
-
How can I identify code which leaks datasource connections ??
If the server log contains error messages with error codes IJ000453 , IJ000655 it means that there is a connection leak at the code, this can give rise to problems such as application not able to fetch any free connections from the pool whereas the INACTIVE connections in the database keeps increasing.
Resolution
In order to identify the source of the connection leak, we need to enable the cached connection manager (CCM), to do this, we need to:
- Enable the
CCMfor the datasource. It’s default value is true, if it is not explicitly specified we can set use-ccm=”true” explicitly.
<subsystem xmlns="urn:jboss:domain:datasources:1.1">
<datasources>
<datasource ... enabled="true" use-ccm="true">
...
</datasource>
</datasources>
</subsystem>
- Verify that
exists in the jca subsystem and set **debug="true".**
<subsystem xmlns="urn:jboss:domain:jca:1.1">
...
<cached-connection-manager debug="true" error="false"/>
...
</subsystem>
The same can be also implemented using the CLI tool, if you are running the commands onto a running server, please note that these attributes are not dynamic in nature and needs a server restart in order to be applied to the connection pool.
CLI commands
- Standalone Mode
- /subsystem=jca/cached-connection-manager=cached-connection-manager/:write-attribute(name=debug,value=true)
- Domain Mode
- /profile=<your_profile_here>/subsystem=jca/cached-connection-manager=cached-connection-manager/:write-attribute(name=debug,value=true)`
Setting debug="true" will:
-
Log an
INFOmessage saying Closing a connection for you. Please close them yourself -
Generate a stacktrace for the code where the leaked connection was first opened.
-
Close the leaked connection.
-
The additional property error may be used to raise a
RuntimeExceptionand generate anERRORmessage in the log when it is set totrue.
NOTE: Set jta also to true for the datasources in order for cached connection manager debug to work in Jboss EAP releases earlier than 7.1.
Additional Notes
If leaks are believed to be present but nothing is reported by the CCM verify the following:
- The datasource must not be configured with use-ccm=”false”
- The datasource must not be configured with jta=”false”.
- In EAP 7.1 and later, the limitation of non-JTA pools that prevented use of cached connection manager debug has been removed. However, in most cases, JTA should not be disabled for production datasources.
- See this article for details on appropriate jta configuration for your datasources.
- In the EAP 6.4 release, a new connection pool implementation called
LeakDumperManagedConnectionPoolhas been added. See Using theLeakDumperManagedConnectionPoolfor additional details. This is especially useful if you must use datasource pools for which the jta property cannot be set to true - The minimum logging level must be
INFOfor org.jboss.jca