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

DML committed within XA transaction block after deadlock error and implicit rollback

    XMLWordPrintable

Details

    • Unexpected results
    • Q3/2025 Maintenance

    Description

      This issue was identified while analyzing MDEV-37117. After a deadlock and rollback error within an XA transaction, we are allowing DML like INSERT to be executed successfully. This is derived from the same testcase from the other bug.

      --source include/have_innodb.inc
       
      CREATE TABLE t1 (a INT) ENGINE=InnoDB;
      INSERT INTO t1 VALUES (1),(2) ;
      CREATE TABLE t2 (b INT) ENGINE=InnoDB;
      CREATE TABLE t3 (c INT) ENGINE=InnoDB;
       
      INSERT INTO t3 VALUES (1),(2);
       
      --connect (con1,localhost,root,,)
      XA BEGIN 'x1';
       
      --connection default
      XA BEGIN 'x2';
       
      DELETE FROM t1;
      --connection con1
       
      DELETE FROM t3 WHERE c = 2;
      --connection default
       
      --send
      DELETE FROM t3;
       
      --connection con1
      --error ER_LOCK_DEADLOCK
      DELETE FROM t1;
      INSERT INTO t2 VALUES (1);
      SELECT * FROM t2;
       
      # Cleanup
      --error ER_XA_RBDEADLOCK
      XA END 'x1';
       
      --disconnect con1
      --connection default
       
      --reap
       
      XA END 'x2';
      XA ROLLBACK 'x2';
       
      SELECT * FROM t2;
       
      DROP TABLE t1, t2, t3;
      

      Here, the INSERT statement after a deadlock error runs successfully and is also committed when the XA transaction block is rolled back. This is a functional issue. The INSERT and any other DML should report ER_XA_RBDEADLOCK.

      This is not any regression and is inherited from MySQL 5.6 Somewhat similar issue is fixed in MySQL 5.7 by following commit.

      commit 5708f0b18f1f724fe1ef6ab5aaf35dea100d8ae7
      Author: Karthik Kamath <karthik.kamath@oracle.com>
      Date:   Tue Apr 6 21:48:10 2021 +0530
       
          BUG#32707060: INCONSISTENT BINLOG CAUSES ON REPLICA ERROR
                       'XAER_RMFAIL: THE COMMAND CANNOT BE EXECUTED
                       WHEN GLOBAL TRANSACTION IS IN THE ACTIVE STATE'
      

      We might want to fix this in 12.x versions and backport to any lower version on need.

      Attachments

        Issue Links

          Activity

            People

              debarun Debarun Banerjee (Inactive)
              debarun Debarun Banerjee (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.