Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-16346

Implementing two phase commit across two maria databases

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Not a Bug
    • Affects Version/s: None
    • Fix Version/s: N/A
    • Component/s: XA
    • Labels:
      None

      Description

      I hope flagging this as a bug is appropriate.

      We are having a problem trying to implement two phase commit across two mariadb databases. Ultimately we want to implement 2PC across an Active MQ queue and a mariadb database but chose this approach to text it working. We are doing this from TomEE to utilise the XA manager in that platform.

      Connections are fine, updates are fine, but when we try to rollback the transaction the rollback seems not to work.

      We have changed the database connections as follows:

      As discussed, I have got some Java code which is using JTA transactions making updates to two JDBC data sources. These are configured as normal except that I have changed the type to “javax.sql.XADataSource”, which I believe is required for XA support.

      <Resource name="jdbc/ipswichdb" auth="Container"
      type="javax.sql.XADataSource"
      factory="uk.co.diegesis.ipswich.utils.IPDataSourceFactory"
      username="ipswichdba"
      password="K4Zt5XhAjAz38MZnGgfsTg=="
      alternateUsernameAllowed="true"
      driverClassName="org.mariadb.jdbc.Driver"
      url="jdbc:mariadb://vmipswichdbdpe.diegesis.local:3306/ipswichdb?useSSL=true&trustServerCertificate=true"
      />

      <Resource name="jdbc/sessiondb" auth="Container"
      type="javax.sql.XADataSource"
      factory="uk.co.diegesis.ipswich.utils.IPDataSourceFactory"
      username="user"
      password="encryptedpassword"
      alternateUsernameAllowed="true"
      driverClassName="org.mariadb.jdbc.Driver"
      url="jdbc:mariadb://vmipswichdbdpe.diegesis.local:3306/sessiondb?useSSL=true&trustServerCertificate=true"
      />

      Note in the above we are overriding the data source factory so we can encrypt our passwords in the context file so we have no passwords in clear in files on the server.

      I am calling the EJBContext method “setRollbackOnly” in one of the update methods to cause the transaction to be rolled back, yet the DB changes in both databases are not rolled back. Turning on TomEE logging shows this call being made, and that the JTA then attempts to roll back the transaction:

      MyBean2.updatePerson; trans status: STATUS_ACTIVE Id: [Xid:globalId=344bffffff8dffffffb16310047544d4944000000000000000000000000000000000000000000000000000,length=64,branchId=0000000000000000000000000000000000000000000000000000000000000000,length=64]
      30-May-2018 15:57:17.326 FINE [http-nio-8080-exec-4] org.apache.openejb.core.transaction.JtaTransactionPolicy.setRollbackOnly TX Required: setRollbackOnly() on transaction org.apache.geronimo.transaction.manager.TransactionImpl@2dde6b39
      Trans status: STATUS_MARKED_ROLLBACK
      30-May-2018 15:57:17.331 FINE [http-nio-8080-exec-4] org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke EjbObjectProxyHandler: finished invoking method updatePerson. Return value:void
      30-May-2018 15:57:17.332 FINE [http-nio-8080-exec-4] org.apache.openejb.core.transaction.JtaTransactionPolicy.rollbackTransaction TX Required: Rolling back transaction org.apache.geronimo.transaction.manager.TransactionImpl@2dde6b39
      30-May-2018 15:57:17.334 FINE [http-nio-8080-exec-4] org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke EjbObjectProxyHandler: finished invoking method updatePerson. Return value:void

      Should this be supported in the DB? Is there a way to check whether the JTA command is reaching the DB, and if so what is going wrong?

      we are using MariaDB Java Client v2.2.2.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            nick.denning@diegesis.co.uk Nicholas Denning
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration