8

I am trying to dump leaked connections managed by a MySQL Data Source in WildFly 10.1, but I am not able to find the leak file or the leak dump.

Why is the leaks.txt file not being generated? And also, where should I look for the file?

Procedure

I registered the leak connection pool in the standalone.bat file:

"JAVA_OPTS=%JAVA_OPTS% -Dironjacamar.mcp=org.jboss.jca.core.connectionmanager.pool.mcp.LeakDumperManagedConnectionPool -Dironjacamar.leaklog=leaks.txt"

I can confirm that properties are being set in WildFly since shows in the log:

JAVA_OPTS: "-Dprogram.name=standalone.bat -Xms64M -Xmx512M -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Dironjacamar.mcp=org.jboss.jca.core.connectionmanager.pool.mcp.LeakDumperManagedConnectionPool -Dironjacamar.leaklog=leaks.txt"

After it, I leak some connections in my mock application in order to generate data. Then I run the CLI command flushing all connections getting a positive response:

[standalone@localhost:9990 /] /subsystem=datasources/data-source=mysql-ds:flush-all-connection-in-pool
{"outcome" => "success"}

But I can't find the leaks.txt file anywhere.

I am using this article and also IronJacamar leak documentation as reference.

The leak detector pool is configured using the ironjacamar.mcp system property with a value of

org.jboss.jca.core.connectionmanager.pool.mcp.LeakDumperManagedConnectionPool

This configuration applies to all connection pools used by IronJacamar.

The system property ironjacamar.leaklog can be used to have the leaks dumped out into a special file separate from the logging setup.

An example

-Dironjacamar.mcp=org.jboss.jca.core.connectionmanager.pool.mcp.LeakDumperManagedConnectionPool -Dironjacamar.leaklog=leaks.txt

Updates

Thread 969369 created in JBoss forum so they can help with it as well.

Bug reported JBJCA-1360.

Evandro Pomatti
  • 7,960
  • 11
  • 56
  • 111
  • Have you tried using an absolute path so you have control over where the file is created? Ex `-Dironjacamar.leaklog=/path/to/leaks.txt', adapt the path to your own environment and operating system. – Gimby Feb 27 '17 at 11:43
  • @Gimby yes, also tried absolute path "d:/leaks.txt" but no file was generated, no error in the logs as well. – Evandro Pomatti Feb 27 '17 at 19:51
  • Check `AllConnections` in standalone.xml file to verify that your flush strategy is present. – Atul Feb 27 '17 at 21:41
  • @Maverick no, it is not present. Should it be? – Evandro Pomatti Feb 28 '17 at 12:15
  • we use domain mode and when I specified flush strategy from admin console then wildfly added it to my data source configuration in domain.xml file. Whatever you install wildfly will add a configuration in your standalone.xml file. – Atul Feb 28 '17 at 15:25
  • @Maverick can you list the steps you took in order to specify the flush strategy? – Evandro Pomatti Feb 28 '17 at 16:39
  • In domain mode, you can access configurations and datasources via UI [link](http://imgur.com/a/IjW9h). I am not sure whether UI is available for standalone mode. One more thing, if you are using `` it will automatically close un-closed JCA connections and print a warning/stacktrace, showing exactly where the transaction was opened. In that case, I am not sure ironjacamar will be able to catch any exception. – Atul Feb 28 '17 at 16:48
  • @Maverick I found the configuration, but applying `AllConnections` didn't change the behavior of IronJacamar. The leak file was not generated. – Evandro Pomatti Feb 28 '17 at 16:52
  • @Maverick `` is already set as well. – Evandro Pomatti Feb 28 '17 at 16:55
  • you can also post your question in wildfly forums https://developer.jboss.org/en/wildfly/content . Most of the developers working on wildfly reply to posts. – Atul Feb 28 '17 at 17:02
  • Did you try after changing `` to `` – Atul Feb 28 '17 at 18:38
  • @Maverick yes, it dumps some information on the server log, but still the IronJacamar TXT file is not generated. – Evandro Pomatti Feb 28 '17 at 20:00
  • I am not sure that I can help you more. I will strongly suggest to post your question in wildfly forum. Wildfly developers monitor all posts and reply everyday. – Atul Feb 28 '17 at 20:04
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/136995/discussion-between-maverick-and-bonanzaone). – Atul Mar 01 '17 at 21:05

1 Answers1

0

Thread 969369 created in JBoss forum so they can help with it as well.

Workaround

There is an alternative approach to log leak connections, however I think it shouldn't apply as a final answer to this question.

The workaround for this is enabling debug and error modes to true for JCA Subsystem (It seems that restarting the server is not needed).

/subsystem=jca/cached-connection-manager=cached-connection-manager:write-attribute(name=debug, value=true)
/subsystem=jca/cached-connection-manager=cached-connection-manager:write-attribute(name=error, value=true)

You can check the logs as the server will dump exceptions pointing out the stacktrace that helps you find the leaks. It is not as clean, but it helped us find where the problem was in our code.

Evandro Pomatti
  • 7,960
  • 11
  • 56
  • 111
  • I found why `leaks.txt` does not appear: https://stackoverflow.com/a/67106612/1189424. You can add `mcp` option of your datatasource, and flush connections. – Alex T Apr 15 '21 at 10:21