2 Replies Latest reply on Jul 14, 2015 3:50 PM by maxant

    XA Transaction not being recovered

    maxant

      Hello,

       

      I have the following test scenario:

       

      1) Start a distributed XA transaction (in JBoss by simply using a Mysql XA Driver in the same transaction as using another XA compatible connector)

      2) Insert data into the database (from say a Servlet using JDBC)

      3) Set a breakpoint in the class MysqlXAConnector (Mysql Driver 5.1.36), at the start of the method "commit(...)"

      4) When the debugger stops at the breakpoint, before the "XA COMMIT xyz" command has been sent to Mysql, stop Mysqld (server). Using the debugger, allow the process continue.

       

       

      I expected that the transaction would remain in an incomplete state until the transaction manager can run the recovery process, at which point the app server would call "recover" on the XA resource which would tell the driver to issue the "XA RECOVER" command to the database, which would return a list of incomplete transactions needing recovery.  The database did after all vote to commit during the "PREPARE" stage.

       

      But I have found several problems.

       

      A) The driver (5.1.36) throws an XAException with the code XAException.XAER_RMFAIL (-7).

      B) Mysql is not persisting the fact that a transaction has not been complete, and upon restarting Mysql, it always reports an empty list of Xids during recovery.

      C) JBoss logs "...WARN  [com.arjuna.ats.jta] (Periodic Recovery) ARJUNA016037: Could not find new XAResource to use for recovering non-serializable XAResourceXAResourceRecord < resource:null, txid: <...eis_name=unknown eis name >, heuristic: TwoPhaseOutcome.FINISH_OK ...>"

       

      Are these problems purely Mysql issues, or is there a problem with JBoss?


      1) Is it correct that JBoss does not retry committing the prepared transaction after the connector returns XAER_RMFAIL? After all, the connector voted to commit during the prepare stage.

      2) Is it correct that it is up to Mysql to persist knowledge of open connections, and return these during recovery, or should JBoss be tracking these itself and re-attempting commit/rollback if there is a failure after all resources successfully vote to commit / rollback after the prepare stage?

      3) Why is JBoss logging "unknown eis name" for the incompleted transaction on the mysql resource?


      Testing on a Thinkpad using Linux Fedora Core 20

      MySQL Command line client: mysql  Ver 14.14 Distrib 5.6.24, for Linux (x86_64) using  EditLine wrapper

      Server version: 5.6.24 MySQL Community Server (GPL)

      Java 1.8 (Oracle)

      JBoss Wildfly 8.2


      server.xml:


                      <xa-datasource jndi-name="java:/jdbc/MyXaDS" pool-name="MyXaDSPool" enabled="true" use-ccm="false">

                          <xa-datasource-property name="URL">

                              jdbc:mysql://localhost:3306/temp?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF-8

                          </xa-datasource-property>

                          <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>

                          <driver>mysql</driver>

                          <xa-pool>

                              <min-pool-size>10</min-pool-size>

                              <max-pool-size>20</max-pool-size>

                              <is-same-rm-override>false</is-same-rm-override>

                              <interleaving>false</interleaving>

                              <pad-xid>false</pad-xid>

                              <wrap-xa-resource>false</wrap-xa-resource>

                          </xa-pool>

                          <security>

                              <user-name>tom</user-name>

                              <password>j0nes</password>

                          </security>

                          <validation>

                              <validate-on-match>false</validate-on-match>

                              <background-validation>false</background-validation>

                              <background-validation-millis>1000</background-validation-millis>

                          </validation>

                          <statement>

                              <prepared-statement-cache-size>0</prepared-statement-cache-size>

                              <share-prepared-statements>false</share-prepared-statements>

                          </statement>

                      </xa-datasource>

                      <drivers>

                          <driver name="mysql" module="com.mysql">

                              <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>

                          </driver>

                      </drivers>

       

       

       

      Thanks for any help :-)

       

       

      Ant