How to debug transactions in WildFly

This article will guide you through the configuration of a Logger that enables you to debug the Narayana Transactions running in WildFly. By the end of it, you will be able to inspect the full lifecycle of a JTA transaction.

Default Transaction Logger

Firstly, the default Transaction Logger available in WildFly will let you output the WARN Messages about the com.arjuna namespace:

 <logger category="com.arjuna">
      <level name="WARN"/>
 </logger>

What is Arjuna? in a nutshell, it is a powerful, stand-alone transaction engine designed for constructing fault-tolerant applications using objects and atomic transactions, ensuring crucial ACID properties (Atomic, Consistent, Isolated, Durable). It forms the core foundation for various HP products and their Arjuna Technologies equivalents, providing a highly optimized, configurable, and extensible framework primarily focused on local transactions, while offering flexibility for potential distribution in varied environments.

Debugging Transactions

In order to debug your Transactions, you need to increase the verbosity of the above Logger. You can apply the change in the XML file setting to TRACE the logger. Or, better, use the CLI for this purpose:

  /subsystem=logging/logger=com.arjuna:write-attribute(name=level,value=TRACE)

When you enable to TRACE the Arjuna logs, you will be able to see the full lifecycle of a JTA Transaction, including the Transaction UID:

023-11-07 12:43:12,923 TRACE [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 14) BasicAction::actionInitialise() for action-id 0:ffff7f000001:6a5566d1:654a229e:38
2023-11-07 12:43:12,923 TRACE [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 91) ActionHierarchy::add(0:ffff7f000001:6a5566d1:654a229e:37, 1)
2023-11-07 12:43:12,923 TRACE [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 14) ActionHierarchy::ActionHierarchy(1)
2023-11-07 12:43:12,923 TRACE [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 89) TransactionReaper::insert ( BasicAction: 0:ffff7f000001:6a5566d1:654a229e:36 status: ActionStatus.RUNNING, 300 )
2023-11-07 12:43:12,924 TRACE [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 91) BasicAction::addChildThread () action 0:ffff7f000001:6a5566d1:654a229e:37 adding Thread[ServerService Thread Pool -- 91,5,ServerService ThreadGroup]
2023-11-07 12:43:12,923 TRACE [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 88) BasicAction::addChildThread () action 0:ffff7f000001:6a5566d1:654a229e:39 adding Thread[ServerService Thread Pool -- 88,5,ServerService ThreadGroup]
2023-11-07 12:43:12,924 TRACE [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 89) ReaperElement::ReaperElement ( BasicAction: 0:ffff7f000001:6a5566d1:654a229e:36 status: ActionStatus.RUNNING, 300 )
2023-11-07 12:43:12,924 TRACE [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 91) BasicAction::addChildThread () action 0:ffff7f000001:6a5566d1:654a229e:37 adding Thread[ServerService Thread Pool -- 91,5,ServerService ThreadGroup] result = true
2023-11-07 12:43:12,924 TRACE [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 14) ActionHierarchy::add(0:ffff7f000001:6a5566d1:654a229e:38, 1)
2023-11-07 12:43:12,924 TRACE [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 88) BasicAction::addChildThread () action 0:ffff7f000001:6a5566d1:654a229e:39 adding Thread[ServerService Thread Pool -- 88,5,ServerService ThreadGroup] result = true

Please note that you can also use the CLI to retrieve the Transaction UID of running transactions. For this purpose, we recommend checking this article: How can I retrieve the id of a Transaction started by JBoss ?

Conclusion

In conclusion, configuring com.arjuna logging to TRACE level within WildFly is a powerful technique for debugging and gaining deeper insights into transaction behaviors. By enabling this verbose logging, administrators and developers can trace transaction activities, identify potential issues, and comprehend the intricate flow of transactions within the server. The detailed logs, covering the transaction lifecycle events and associated components, offer a clearer perspective on transaction execution, aiding in the diagnosis of problems and performance optimization. However, it’s crucial to exercise caution, as TRACE-level logging might generate a substantial volume of logs, potentially impacting system performance. Therefore, it’s advisable to use this configuration judiciously and selectively in diagnosing specific transaction-related issues within WildFly.

Found the article helpful? if so please follow us on Socials