Bug #90640 `head->variables.gtid_next.type != UNDEFINED_GTID'
Submitted: 26 Apr 2018 4:20 Modified: 16 Oct 2018 11:28
Reporter: Roel Van de Paar (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S1 (Critical)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any
Tags: debug build

[26 Apr 2018 4:20] Roel Van de Paar
Description:
mysqld: /git/mysql-server_dbg/sql/binlog.cc:1343: bool MYSQL_BIN_LOG::assign_automatic_gtids_to_flush_group(THD*): Assertion `head->variables.gtid_next.type != UNDEFINED_GTID' failed.
03:24:14 UTC - mysqld got signal 6 ;

(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x000055f0ed8744a5 in my_write_core (sig=6) at /git/mysql-server_dbg/mysys/stacktrace.cc:278
#2  0x000055f0ec5fb18c in handle_fatal_signal (sig=6) at /git/mysql-server_dbg/sql/signal_handler.cc:249
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x00007fec2b3d4801 in __GI_abort () at abort.c:79
#6  0x00007fec2b3c439a in __assert_fail_base (fmt=0x7fec2b54b7d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x55f0eece0a70 "head->variables.gtid_next.type != UNDEFINED_GTID", 
    file=file@entry=0x55f0eece04b8 "/git/mysql-server_dbg/sql/binlog.cc", line=line@entry=1343, 
    function=function@entry=0x55f0eece5360 <MYSQL_BIN_LOG::assign_automatic_gtids_to_flush_group(THD*)::__PRETTY_FUNCTION__> "bool MYSQL_BIN_LOG::assign_automatic_gtids_to_flush_group(THD*)") at assert.c:92
#7  0x00007fec2b3c4412 in __GI___assert_fail (assertion=0x55f0eece0a70 "head->variables.gtid_next.type != UNDEFINED_GTID", 
    file=0x55f0eece04b8 "/git/mysql-server_dbg/sql/binlog.cc", line=1343, 
    function=0x55f0eece5360 <MYSQL_BIN_LOG::assign_automatic_gtids_to_flush_group(THD*)::__PRETTY_FUNCTION__> "bool MYSQL_BIN_LOG::assign_automatic_gtids_to_flush_group(THD*)") at assert.c:101
#8  0x000055f0ed489a77 in MYSQL_BIN_LOG::assign_automatic_gtids_to_flush_group (this=0x55f0efedf6c0 <mysql_bin_log>, first_seen=
    0x7febfd823000) at /git/mysql-server_dbg/sql/binlog.cc:1343
#9  0x000055f0ed4a1a08 in MYSQL_BIN_LOG::process_flush_stage_queue (this=0x55f0efedf6c0 <mysql_bin_log>, 
    total_bytes_var=0x7fec2b38fbf0, rotate_var=0x7fec2b38fbe2, out_queue_var=0x7fec2b38fbf8)
    at /git/mysql-server_dbg/sql/binlog.cc:8196
#10 0x000055f0ed4a31e5 in MYSQL_BIN_LOG::ordered_commit (this=0x55f0efedf6c0 <mysql_bin_log>, thd=0x7febfd823000, all=true, 
    skip_commit=false) at /git/mysql-server_dbg/sql/binlog.cc:8759
#11 0x000055f0ed4a1661 in MYSQL_BIN_LOG::commit (this=0x55f0efedf6c0 <mysql_bin_log>, thd=0x7febfd823000, all=true)
    at /git/mysql-server_dbg/sql/binlog.cc:8104
#12 0x000055f0ec773219 in ha_commit_trans (thd=0x7febfd823000, all=true, ignore_global_read_lock=false)
    at /git/mysql-server_dbg/sql/handler.cc:1684
#13 0x000055f0ec5a6fc4 in trans_commit (thd=0x7febfd823000, ignore_global_read_lock=false)
    at /git/mysql-server_dbg/sql/transaction.cc:251
#14 0x000055f0ec563c61 in fix_autocommit (self=0x55f0efeb74c0 <Sys_autocommit>, thd=0x7febfd823000, type=OPT_SESSION)
    at /git/mysql-server_dbg/sql/sys_vars.cc:4506
#15 0x000055f0ec380c23 in sys_var::update (this=0x55f0efeb74c0 <Sys_autocommit>, thd=0x7febfd823000, var=0x7febe0875aa8)
    at /git/mysql-server_dbg/sql/set_var.cc:259
#16 0x000055f0ec381317 in sys_var::set_default (this=0x55f0efeb74c0 <Sys_autocommit>, thd=0x7febfd823000, var=0x7febe0875aa8)
    at /git/mysql-server_dbg/sql/set_var.cc:344
#17 0x000055f0ec383284 in set_var::update (this=0x7febe0875aa8, thd=0x7febfd823000) at /git/mysql-server_dbg/sql/set_var.cc:1008
#18 0x000055f0ec382681 in sql_set_variables (thd=0x7febfd823000, var_list=0x7febfd828a80, opened=true)
    at /git/mysql-server_dbg/sql/set_var.cc:771
#19 0x000055f0ec45949f in mysql_execute_command (thd=0x7febfd823000, first_level=true) at /git/mysql-server_dbg/sql/sql_parse.cc:3268
#20 0x000055f0ec45ebb2 in mysql_parse (thd=0x7febfd823000, parser_state=0x7fec2b392330) at /git/mysql-server_dbg/sql/sql_parse.cc:4935
#21 0x000055f0ec454713 in dispatch_command (thd=0x7febfd823000, com_data=0x7fec2b392c90, command=COM_QUERY)
    at /git/mysql-server_dbg/sql/sql_parse.cc:1589
#22 0x000055f0ec452fee in do_command (thd=0x7febfd823000) at /git/mysql-server_dbg/sql/sql_parse.cc:1214
#23 0x000055f0ec5e8a70 in handle_connection (arg=0x7febdfc6e420)
    at /git/mysql-server_dbg/sql/conn_handler/connection_handler_per_thread.cc:308
#24 0x000055f0edf08cf8 in pfs_spawn_thread (arg=0x7fec1efe7820) at /git/mysql-server_dbg/storage/perfschema/pfs.cc:2814
#25 0x00007fec2cdbe6db in start_thread (arg=0x7fec2b393700) at pthread_create.c:463
#26 0x00007fec2b4b588f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

How to repeat:
# mysqld options required for replay:  --binlog_format=STATEMENT
SOURCE file.sql  # Attached
[26 Apr 2018 4:24] Roel Van de Paar
file.sql

Attachment: file.sql (application/sql, text), 332 bytes.

[26 Apr 2018 4:51] Umesh Shastry
Hello Roel,

Thank you for the report and test case.
Observed that 8.0.11 debug build is affected.

Thanks,
Umesh
[27 Apr 2018 11:21] Erlend Dahl
Posted by developer:
 
The problem actually reproduces on 5.7 if you turn on binlogging (which is default on in 8.0): --log-bin=1. It doesn't reproduce on 5.6 though.
[16 Oct 2018 11:28] Margaret Fisher
Posted by developer:
 
Changelog entry added for MySQL 5.7.25 and 8.0.14:

An assertion was raised in debug builds if an XA ROLLBACK statement was issued for an unknown transaction identifier when the gtid_next value had been set manually. The server now does not attempt to update the GTID state if an XA ROLLBACK statement fails with an error.
[21 Dec 2018 12:15] Margaret Fisher
Posted by developer:
 
Test case fix, no change needed to existing changelog entry.