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

Assertion `!xid_state.xid_cache_element' failed in trans_xa_rollback

    XMLWordPrintable

Details

    • Not for Release Notes

    Description

      Notes: The test case is non-deterministic, run with --repeat=N. It usually fails within ~5-10 attempts on my debug builds.
      I've set --error suppressions based on the de-facto behavior pre- and post-guilty commit. Maybe not of them are expected (which would mean there is a problem other than the assertion failure), please revise.

      --source include/have_innodb.inc
       
      CREATE TABLE t1 (b INT, KEY(b)) ENGINE=InnoDB;
      CREATE TABLE t2 (c INT, KEY(c)) ENGINE=InnoDB;
      CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
       
      call mtr.add_suppression("Found 1 prepared XA transactions");
       
      XA START 'x1';
      INSERT INTO t2 VALUES (1);
      XA END 'x1';
      XA PREPARE 'x1';
       
      --source include/restart_mysqld.inc
       
      XA START 'x2';
      UPDATE t1 SET b = 1;
       
      --connect (con1,localhost,root,,)
      SET lock_wait_timeout= 2;
      --send
      ALTER TABLE t1 ADD FOREIGN KEY s (b) REFERENCES t2 (c), ALGORITHM=COPY;
      --connection default
      --error 0,ER_LOCK_DEADLOCK
      INSERT INTO v2 (c) VALUES(1),(2),(3);
      --error ER_XAER_OUTSIDE
      XA ROLLBACK 'x1';
       
      --connection con1
      --error 0,ER_LOCK_WAIT_TIMEOUT
      --reap
      --disconnect con1
      --connection default
      --error 0,ER_XA_RBDEADLOCK
      XA END 'x2';
      XA ROLLBACK 'x2';
      XA ROLLBACK 'x1';
      DROP VIEW v2;
      DROP TABLE t1, t2;
      

      bb-10.11-release e2aafd5b0094d27dbd4ddb8b0e216e0ccebd2e7b

      mariadbd: /data/bld/bb-10.11-release/sql/xa.cc:838: bool trans_xa_rollback(THD*): Assertion `!xid_state.xid_cache_element' failed.
      250726 16:52:42 [ERROR] /share8t/bld/bb-10.11-release/sql/mariadbd got signal 6 ;
       
      #8  0x00007f2f6ba45395 in __assert_fail_base (fmt=0x7f2f6bbb9a90 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55c079fb9760 "!xid_state.xid_cache_element", file=file@entry=0x55c079fb8ac0 "/data/bld/bb-10.11-release/sql/xa.cc", line=line@entry=838, function=function@entry=0x55c079fb9960 "bool trans_xa_rollback(THD*)") at ./assert/assert.c:92
      #9  0x00007f2f6ba53eb2 in __GI___assert_fail (assertion=0x55c079fb9760 "!xid_state.xid_cache_element", file=0x55c079fb8ac0 "/data/bld/bb-10.11-release/sql/xa.cc", line=838, function=0x55c079fb9960 "bool trans_xa_rollback(THD*)") at ./assert/assert.c:101
      #10 0x000055c07813d5f5 in trans_xa_rollback (thd=0x62c000200218) at /data/bld/bb-10.11-release/sql/xa.cc:838
      #11 0x000055c0779d6fc8 in mysql_execute_command (thd=0x62c000200218, is_called_from_prepared_stmt=false) at /data/bld/bb-10.11-release/sql/sql_parse.cc:6046
      #12 0x000055c0779e4a84 in mysql_parse (thd=0x62c000200218, rawbuf=0x62d0000b4438 "XA ROLLBACK 'x1'", length=16, parser_state=0x7f2f5c36ba80) at /data/bld/bb-10.11-release/sql/sql_parse.cc:8178
      #13 0x000055c0779ba0ca in dispatch_command (command=COM_QUERY, thd=0x62c000200218, packet=0x62900010e219 "XA ROLLBACK 'x1'", packet_length=16, blocking=true) at /data/bld/bb-10.11-release/sql/sql_parse.cc:1906
      #14 0x000055c0779b6df7 in do_command (thd=0x62c000200218, blocking=true) at /data/bld/bb-10.11-release/sql/sql_parse.cc:1419
      #15 0x000055c077e855bd in do_handle_one_connection (connect=0x60800001d6b8, put_in_cache=true) at /data/bld/bb-10.11-release/sql/sql_connect.cc:1386
      #16 0x000055c077e8511c in handle_one_connection (arg=0x60800001d6b8) at /data/bld/bb-10.11-release/sql/sql_connect.cc:1298
      #17 0x000055c078abab52 in pfs_spawn_thread (arg=0x617000007e98) at /data/bld/bb-10.11-release/storage/perfschema/pfs.cc:2201
      #18 0x00007f2f6baa81c4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #19 0x00007f2f6bb2885c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      The failure apparently started happening after this commit in 10.11:

      commit 0680e31737a79959a69f3c2cb90458834359ece3
      Author: mariadb-DebarunBanerjee
      Date:   Tue Jun 17 18:19:27 2025 +0530
       
          MDEV-36959 Deadlock does not rollback transaction fully
          
          A deadlock forces the on going transaction to rollback implicitly.
      

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.