[MDEV-32852] Assertion `is_prepared_xa(thd) || ((thd->lex->sql_command == SQLCOM_XA_ROLLBACK && thd->transaction->xid_state.get_state_code() == XA_IDLE) || thd->lex->xa_opt == XA_ONE_PHASE)' failed in TC_LOG::run_commit_ordered Created: 2023-11-21  Updated: 2023-12-28  Resolved: 2023-11-21

Status: Closed
Project: MariaDB Server
Component/s: Binary Protocol, XA
Affects Version/s: N/A
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Roel Van de Paar Assignee: Andrei Elkin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-31949 slow parallel replication of user xa In Review
blocks MDEV-32830 refactor XA binlogging for better int... In Review
Problem/Incident
is caused by MDEV-32830 refactor XA binlogging for better int... In Review
Relates

 Description   

Fails in bb-10.6-andrei at commit 88b0738b7c61a25eaffc66dda0a5a7f850c89918 (MDEV-32830 patch), but not at the commit prior to that (pre-MDEV-32830)

--source include/have_innodb.inc
XA START 'a';
CREATE TEMPORARY TABLE t1 (a INT) ENGINE=InnoDB;
SELECT * FROM t1;

Please execute testcase as follows:

./mysql-test-run --mysqld=--log-bin test

Leads to

10.6.17 88b0738b7c61a25eaffc66dda0a5a7f850c89918

mariadbd: /test/bb-10.6-andrei_dbg/sql/log.cc:9430: void TC_LOG::run_commit_ordered(THD*, bool, THD*): Assertion `is_prepared_xa(thd) || ((thd->lex->sql_command == SQLCOM_XA_ROLLBACK && thd->transaction->xid_state.get_state_code() == XA_IDLE) || thd->lex->xa_opt == XA_ONE_PHASE)' failed.

10.6.17 88b0738b7c61a25eaffc66dda0a5a7f850c89918

Core was generated by `/test/PATCH_MD201123-mariadb-10.6.17-linux-x86_64-dbg/bin/mariadbd --defaults-g'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=23020890179136)
    at ./nptl/pthread_kill.c:44
[Current thread is 1 (Thread 0x14eff7fb4640 (LWP 2767903))]
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=23020890179136) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=23020890179136) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=23020890179136, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x000014f002642476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x000014f0026287f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x000014f00262871b in __assert_fail_base (fmt=0x14f0027dd150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x557224143ca0 "is_prepared_xa(thd) || ((thd->lex->sql_command == SQLCOM_XA_ROLLBACK && thd->transaction->xid_state.get_state_code() == XA_IDLE) || thd->lex->xa_opt == XA_ONE_PHASE)", file=0x557224141ae8 "/test/bb-10.6-andrei_dbg/sql/log.cc", line=9430, function=<optimized out>) at ./assert/assert.c:92
#6  0x000014f002639e96 in __GI___assert_fail (assertion=0x557224143ca0 "is_prepared_xa(thd) || ((thd->lex->sql_command == SQLCOM_XA_ROLLBACK && thd->transaction->xid_state.get_state_code() == XA_IDLE) || thd->lex->xa_opt == XA_ONE_PHASE)", file=0x557224141ae8 "/test/bb-10.6-andrei_dbg/sql/log.cc", line=9430, function=0x557224143ba8 "void TC_LOG::run_commit_ordered(THD*, bool, THD*)") at ./assert/assert.c:101
#7  0x00005572237bf61f in TC_LOG::run_commit_ordered (this=this@entry=0x557224915960 <mysql_bin_log>, thd=0x14efc4000d58, all=true, leader_thd=0x14efc4000d58) at /test/bb-10.6-andrei_dbg/sql/log.cc:9430
#8  0x00005572237c8a6e in MYSQL_BIN_LOG::trx_group_commit_leader (this=this@entry=0x557224915960 <mysql_bin_log>, leader=leader@entry=0x14eff7fb3580) at /test/bb-10.6-andrei_dbg/sql/log.cc:8616
#9  0x00005572237c907a in MYSQL_BIN_LOG::write_transaction_to_binlog_events (this=this@entry=0x557224915960 <mysql_bin_log>, entry=entry@entry=0x14eff7fb3580) at /test/bb-10.6-andrei_dbg/sql/log.cc:8194
#10 0x00005572237c96a5 in MYSQL_BIN_LOG::write_transaction_to_binlog (this=this@entry=0x557224915960 <mysql_bin_log>, thd=thd@entry=0x14efc4000d58, cache_mngr=cache_mngr@entry=0x14efc40fe8c8, end_ev=end_ev@entry=0x14eff7fb3860, all=all@entry=true, using_stmt_cache=using_stmt_cache@entry=false, using_trx_cache=true, is_ro_1pc=false) at /test/bb-10.6-andrei_dbg/sql/log.cc:7791
#11 0x00005572237c988e in binlog_flush_cache (thd=thd@entry=0x14efc4000d58, cache_mngr=cache_mngr@entry=0x14efc40fe8c8, end_ev=end_ev@entry=0x14eff7fb3860, all=all@entry=true, using_stmt=using_stmt@entry=false, using_trx=using_trx@entry=true, is_ro_1pc=false) at /test/bb-10.6-andrei_dbg/sql/log.cc:1771
#12 0x00005572237c9cf9 in binlog_rollback_flush_trx_cache (thd=thd@entry=0x14efc4000d58, all=all@entry=true, cache_mngr=cache_mngr@entry=0x14efc40fe8c8) at /test/bb-10.6-andrei_dbg/sql/log.cc:1907
#13 0x00005572237ca259 in binlog_rollback (hton=<optimized out>, thd=0x14efc4000d58, all=<optimized out>) at /test/bb-10.6-andrei_dbg/sql/log.cc:2326
#14 0x000055722367a8fd in ha_rollback_trans (thd=thd@entry=0x14efc4000d58, all=all@entry=true) at /test/bb-10.6-andrei_dbg/sql/handler.cc:2278
#15 0x00005572235e9f72 in xa_trans_force_rollback (thd=thd@entry=0x14efc4000d58) at /test/bb-10.6-andrei_dbg/sql/xa.cc:428
#16 0x00005572235eb215 in trans_xa_detach (thd=thd@entry=0x14efc4000d58) at /test/bb-10.6-andrei_dbg/sql/xa.cc:874
#17 0x000055722335ba4b in THD::cleanup (this=this@entry=0x14efc4000d58) at /test/bb-10.6-andrei_dbg/sql/sql_class.cc:1561
#18 0x00005572232c5faa in unlink_thd (thd=0x14efc4000d58) at /test/bb-10.6-andrei_dbg/sql/mysqld.cc:2733
#19 0x000055722350c1bc in do_handle_one_connection (connect=<optimized out>, connect@entry=0x557226f9b918, put_in_cache=put_in_cache@entry=true) at /test/bb-10.6-andrei_dbg/sql/sql_connect.cc:1427
#20 0x000055722350c452 in handle_one_connection (arg=arg@entry=0x557226f9b918) at /test/bb-10.6-andrei_dbg/sql/sql_connect.cc:1318
#21 0x000055722395a628 in pfs_spawn_thread (arg=0x557226f25c18) at /test/bb-10.6-andrei_dbg/storage/perfschema/pfs.cc:2201
#22 0x000014f002694ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#23 0x000014f002726a40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81



 Comments   
Comment by Roel Van de Paar [ 2023-11-21 ]

Equally present in 803e496ad0fecf5ec674f91fed3749bdfa05e40d

Comment by Andrei Elkin [ 2023-11-21 ]

The issue was in an incorrect assert that did not expect execution branch from
the description.

A fixes commit is pushed into MDEV-31949 branch at bb-10.6-andrei.

Generated at Thu Feb 08 10:34:31 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.