Bug #90547 [MySQL 8.0 GA Debug Build] Assertion `gtid_next_type == ANONYMOUS_GTID' failed.
Submitted: 21 Apr 2018 3:07 Modified: 12 Nov 2018 15:00
Reporter: Roel Van de Paar (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S1 (Critical)
Version:8.0.11 GA OS:Any
Assigned to: CPU Architecture:Any
Tags: debug build

[21 Apr 2018 3:07] Roel Van de Paar
Description:
2018-04-21T03:05:49.196250Z 9 [System] [MY-010035] [Server] Changed GTID_MODE from OFF to OFF_PERMISSIVE.
mysqld: /git/mysql-server_dbg/sql/binlog.cc:10296: bool handle_gtid_consistency_violation(THD*, int, int): Assertion `gtid_next_type == ANONYMOUS_GTID' failed.
03:05:49 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  0x0000557ad3e1c4a5 in my_write_core (sig=6) at /git/mysql-server_dbg/mysys/stacktrace.cc:278
#2  0x0000557ad2ba318c 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  0x00007f44d6d0b801 in __GI_abort () at abort.c:79
#6  0x00007f44d6cfb39a in __assert_fail_base (fmt=0x7f44d6e827d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x557ad528cac8 "gtid_next_type == ANONYMOUS_GTID", file=file@entry=0x557ad52884b8 "/git/mysql-server_dbg/sql/binlog.cc", 
    line=line@entry=10296, 
    function=function@entry=0x557ad528f760 <handle_gtid_consistency_violation(THD*, int, int)::__PRETTY_FUNCTION__> "bool handle_gtid_consistency_violation(THD*, int, int)") at assert.c:92
#7  0x00007f44d6cfb412 in __GI___assert_fail (assertion=0x557ad528cac8 "gtid_next_type == ANONYMOUS_GTID", 
    file=0x557ad52884b8 "/git/mysql-server_dbg/sql/binlog.cc", line=10296, 
    function=0x557ad528f760 <handle_gtid_consistency_violation(THD*, int, int)::__PRETTY_FUNCTION__> "bool handle_gtid_consistency_violation(THD*, int, int)")
    at assert.c:101
#8  0x0000557ad3a4eeea in handle_gtid_consistency_violation (thd=0x7f44b6b0f000, error_code=1785, log_error_code=13098)
    at /git/mysql-server_dbg/sql/binlog.cc:10296
#9  0x0000557ad3a4f4f8 in THD::is_dml_gtid_compatible (this=0x7f44b6b0f000, some_transactional_table=true, some_non_transactional_table=true, 
    non_transactional_tables_are_tmp=false) at /git/mysql-server_dbg/sql/binlog.cc:10421
#10 0x0000557ad3a4e765 in THD::decide_logging_format (this=0x7f44b6b0f000, tables=0x7f448bca5ff8) at /git/mysql-server_dbg/sql/binlog.cc:10133
#11 0x0000557ad295bcfa in lock_tables (thd=0x7f44b6b0f000, tables=0x7f448bca5ff8, count=2, flags=0) at /git/mysql-server_dbg/sql/sql_base.cc:6569
#12 0x0000557ad2a61cc4 in Sql_cmd_dml::execute (this=0x7f448bca6b40, thd=0x7f44b6b0f000) at /git/mysql-server_dbg/sql/sql_select.cc:550
#13 0x0000557ad2a0463c in mysql_execute_command (thd=0x7f44b6b0f000, first_level=true) at /git/mysql-server_dbg/sql/sql_parse.cc:4220
#14 0x0000557ad2a06bb2 in mysql_parse (thd=0x7f44b6b0f000, parser_state=0x7f44d6cc9330) at /git/mysql-server_dbg/sql/sql_parse.cc:4935
#15 0x0000557ad29fc713 in dispatch_command (thd=0x7f44b6b0f000, com_data=0x7f44d6cc9c90, command=COM_QUERY) at /git/mysql-server_dbg/sql/sql_parse.cc:1589
#16 0x0000557ad29fafee in do_command (thd=0x7f44b6b0f000) at /git/mysql-server_dbg/sql/sql_parse.cc:1214
#17 0x0000557ad2b90a70 in handle_connection (arg=0x7f448b86e420) at /git/mysql-server_dbg/sql/conn_handler/connection_handler_per_thread.cc:308
#18 0x0000557ad44b0cf8 in pfs_spawn_thread (arg=0x7f44cabe7820) at /git/mysql-server_dbg/storage/perfschema/pfs.cc:2814
#19 0x00007f44d86f56db in start_thread (arg=0x7f44d6cca700) at pthread_create.c:463
#20 0x00007f44d6dec88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

How to repeat:
DROP DATABASE test; CREATE DATABASE test; USE test;
SET @@GLOBAL.GTID_MODE=OFF_PERMISSIVE;
CREATE TABLE t1(c1 INT,c2 CHAR) ENCRYPTION="Y" ENGINE=MEMORY;
CREATE TABLE t2(c1 INT) ENGINE=InnoDB PACK_KEYS=1;
SET GTID_NEXT='aaaaaaaa-aaaa-aaaa-aaaa-bbbbbbbbbbbb:1';
CREATE TABLE t1(a CHAR CHARACTER SET utf16,INDEX a (a)) ENGINE=InnoDB;
SELECT * FROM t1,t2 FOR UPDATE OF t1,t2 SKIP LOCKED;
[21 Apr 2018 4:38] Miguel Solorzano
Thank you for the bug report.
2018-04-21T04:35:11.100454Z 0 [System] [MY-010931] [Server] /home/miguel/dbsd/8.0/bin/mysqld: ready for connections. Version: '8.0.12-debug'  socket: '/tmp/mysql80.sock'  port: 3380  Source distribution 2018-APR-18.
2018-04-21T04:35:24.420884Z 8 [System] [MY-010035] [Server] Changed GTID_MODE from OFF to OFF_PERMISSIVE.
mysqld: /home/miguel/buildd/2018APR18/mysql-8.0/sql/binlog.cc:10296: bool handle_gtid_consistency_violation(THD*, int, int): Assertion `gtid_next_type == ANONYMOUS_GTID' failed.
04:35:25 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=1
max_threads=151
thread_count=2
connection_count=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 67877 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7f609c000be0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7f6145901d38 thread_stack 0x46000
/home/miguel/dbsd/8.0/bin/mysqld(my_print_stacktrace(unsigned char*, unsigned long)+0x55) [0x411be4d]
/home/miguel/dbsd/8.0/bin/mysqld(handle_fatal_signal+0x424) [0x2e53f77]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390) [0x7f6159bbf390]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38) [0x7f61582bd428]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7f61582bf02a]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7) [0x7f61582b5bd7]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dc82) [0x7f61582b5c82]
/home/miguel/dbsd/8.0/bin/mysqld() [0x3d32d17]
/home/miguel/dbsd/8.0/bin/mysqld(THD::is_dml_gtid_compatible(bool, bool, bool)+0x189) [0x3d33341]
/home/miguel/dbsd/8.0/bin/mysqld(THD::decide_logging_format(TABLE_LIST*)+0x153a) [0x3d32576]
/home/miguel/dbsd/8.0/bin/mysqld(lock_tables(THD*, TABLE_LIST*, unsigned int, unsigned int)+0x6b1) [0x2c19f65]
/home/miguel/dbsd/8.0/bin/mysqld(Sql_cmd_dml::execute(THD*)+0x401) [0x2d0bdf5]
/home/miguel/dbsd/8.0/bin/mysqld(mysql_execute_command(THD*, bool)+0x5797) [0x2cad639]
/home/miguel/dbsd/8.0/bin/mysqld(mysql_parse(THD*, Parser_state*)+0x65e) [0x2cafbd0]
/home/miguel/dbsd/8.0/bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x13a7) [0x2ca570c]
/home/miguel/dbsd/8.0/bin/mysqld(do_command(THD*)+0x484) [0x2ca3fc5]
/home/miguel/dbsd/8.0/bin/mysqld() [0x2e4174b]
/home/miguel/dbsd/8.0/bin/mysqld() [0x47eef1a]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7f6159bb56ba]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f615838f41d]

Trying to get some variables.
[12 Nov 2018 15:00] Margaret Fisher
Posted by developer:
 
An assertion was raised in debug builds if a SELECT... FOR UPDATE statement was issued immediately after a transaction was committed or rolled back, and the transaction had been assigned a GTID manually using the gtid_next session system variable.  After gtid_next has been used to set a GTID for a transaction, and the transaction has been committed or rolled back, another explicit SET GTID_NEXT statement must be issued before any other statement, otherwise the gtid_next value is left undefined. The SELECT... FOR UPDATE statement caused a GTID consistency violation in this situation because it acquired write locks, although it did not make any changes.  SELECT... FOR UPDATE statements that acquire write locks now return an error in this situation.