[MDEV-33155] Assertion `!thd->transaction->xid_state.is_explicit_XA() || thd->lex->xa_opt == XA_ONE_PHASE' failed in ha_commit_trans Created: 2024-01-02  Updated: 2024-01-02

Status: Open
Project: MariaDB Server
Component/s: Binary Protocol
Affects Version/s: 10.11, 11.0, 11.1, 11.2, 11.3, 11.4
Fix Version/s: 10.11, 11.0, 11.1, 11.2, 11.3

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Andrei Elkin
Resolution: Unresolved Votes: 0
Labels: regression-10.11


 Description   

# mysqld options required for replay: --log-bin
CREATE TABLE t (c INT);
XA START 'a';
INSERT INTO t VALUES (0);
CHANGE MASTER TO master_host='a',master_port=1,master_user='a',master_demote_to_slave=1;

Leads to:

11.4.0 9bd95e914f3f12d0d9d93e7a1f2c49e6e8841f17 (Debug)

mariadbd: /test/11.4_dbg/sql/handler.cc:1932: int ha_commit_trans(THD*, bool): Assertion `!thd->transaction->xid_state.is_explicit_XA() || thd->lex->xa_opt == XA_ONE_PHASE' failed.

11.4.0 9bd95e914f3f12d0d9d93e7a1f2c49e6e8841f17 (Debug)

Core was generated by `/test/MD271223-mariadb-11.4.0-linux-x86_64-dbg/bin/mariadbd --no-defaults --cor'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22603542234688)
    at ./nptl/pthread_kill.c:44
[Current thread is 1 (Thread 0x148ecc1b0640 (LWP 4036442))]
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22603542234688) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=22603542234688) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=22603542234688, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x0000148ee1c42476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x0000148ee1c287f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x0000148ee1c2871b in __assert_fail_base (fmt=0x148ee1ddd130 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5571a5a2ade8 "!thd->transaction->xid_state.is_explicit_XA() || thd->lex->xa_opt == XA_ONE_PHASE", file=0x5571a5a298cb "/test/11.4_dbg/sql/handler.cc", line=1932, function=<optimized out>) at ./assert/assert.c:92
#6  0x0000148ee1c39e96 in __GI___assert_fail (assertion=0x5571a5a2ade8 "!thd->transaction->xid_state.is_explicit_XA() || thd->lex->xa_opt == XA_ONE_PHASE", file=0x5571a5a298cb "/test/11.4_dbg/sql/handler.cc", line=1932, function=0x5571a5a2acf0 "int ha_commit_trans(THD*, bool)") at ./assert/assert.c:101
#7  0x00005571a4f97053 in ha_commit_trans (thd=thd@entry=0x148e98000d58, all=all@entry=true) at /test/11.4_dbg/sql/handler.cc:1932
#8  0x00005571a4e8f539 in rpl_slave_state::truncate_state_table (this=this@entry=0x5571a811fa70, thd=thd@entry=0x148e98000d58) at /test/11.4_dbg/sql/rpl_gtid.cc:464
#9  0x00005571a4e91954 in rpl_slave_state::load (this=0x5571a811fa70, thd=thd@entry=0x148e98000d58, state_from_master=<optimized out>, len=<optimized out>, reset=reset@entry=true, in_statement=in_statement@entry=true) at /test/11.4_dbg/sql/rpl_gtid.cc:1431
#10 0x00005571a4cce459 in change_master (thd=thd@entry=0x148e98000d58, mi=mi@entry=0x5571a88ccc60, master_info_added=master_info_added@entry=0x148ecc1aed60) at /test/11.4_dbg/sql/sql_repl.cc:3972
#11 0x00005571a4c8f685 in mysql_execute_command (thd=thd@entry=0x148e98000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.4_dbg/sql/sql_parse.cc:4108
#12 0x00005571a4c954bb in mysql_parse (thd=thd@entry=0x148e98000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x148ecc1af1e0) at /test/11.4_dbg/sql/sql_parse.cc:7748
#13 0x00005571a4c97831 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x148e98000d58, packet=packet@entry=0x148e9800b269 "CHANGE MASTER TO master_host='a',master_port=1,master_user='a',master_demote_to_slave=1", packet_length=packet_length@entry=87, blocking=blocking@entry=true) at /test/11.4_dbg/sql/sql_class.h:253
#14 0x00005571a4c99956 in do_command (thd=0x148e98000d58, blocking=blocking@entry=true) at /test/11.4_dbg/sql/sql_parse.cc:1406
#15 0x00005571a4dfe8b7 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5571a888c0d8, put_in_cache=put_in_cache@entry=true) at /test/11.4_dbg/sql/sql_connect.cc:1418
#16 0x00005571a4dfebac in handle_one_connection (arg=arg@entry=0x5571a888c0d8) at /test/11.4_dbg/sql/sql_connect.cc:1320
#17 0x00005571a524373a in pfs_spawn_thread (arg=0x5571a8810128) at /test/11.4_dbg/storage/perfschema/pfs.cc:2201
#18 0x0000148ee1c94ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#19 0x0000148ee1d26660 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Bug confirmed present in:
MariaDB: 10.11.7 (dbg), 11.0.5 (dbg), 11.1.4 (dbg), 11.2.3 (dbg), 11.3.2 (dbg), 11.4.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.4.33 (dbg), 10.4.33 (opt), 10.5.24 (dbg), 10.5.24 (opt), 10.6.17 (dbg), 10.6.17 (opt), 10.11.7 (opt), 11.0.5 (opt), 11.1.4 (opt), 11.2.3 (opt), 11.3.2 (opt), 11.4.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.40 (dbg), 8.0.33 (dbg), 8.0.33 (opt)



 Comments   
Comment by Roel Van de Paar [ 2024-01-02 ]

Issue reproduces readily in the CLI, but not in MTR. In MTR, we see a passing testcase:

--source include/have_binlog_format_mixed.inc
CREATE TABLE t (c INT);
XA START 'a';
INSERT INTO t VALUES (0);
CHANGE MASTER TO master_host='a',master_port=1,master_user='a',master_demote_to_slave=1;

11.4.0 9bd95e914f3f12d0d9d93e7a1f2c49e6e8841f17 (debug)

main.test                                [ pass ]    129

Comment by Roel Van de Paar [ 2024-01-02 ]

Not a recent regression: 10.11.3 @ 50c8ef01fc63e32acd38788107ae4029d0f1b9ce (29/3/23) crashes in the same way.

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