Bug #85552 Assertion `head->owned_gtid.sidno == THD::OWNED_SIDNO_ANONYMOUS' failed.
Submitted: 21 Mar 2017 0:44 Modified: 21 Mar 2017 5:50
Reporter: Roel Van de Paar Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S6 (Debug Builds)
Version:5.7.17 OS:Any
Assigned to: CPU Architecture:Any

[21 Mar 2017 0:44] Roel Van de Paar
Description:
2017-03-21T00:41:03.685710Z 0 [Note] /sda/MS200317-mysql-5.7.17-linux-x86_64-debug/bin/mysqld: ready for connections.
Version: '5.7.17-debug-log'  socket: '/sda/MS200317-mysql-5.7.17-linux-x86_64-debug/socket.sock'  port: 19236  MySQL Community Server (GPL)
mysqld: /git/MS57_dbg/sql/binlog.cc:1155: bool MYSQL_BIN_LOG::assign_automatic_gtids_to_flush_group(THD*): Assertion `head->owned_gtid.sidno == THD::OWNED_SIDNO_ANONYMOUS' failed.
00:42:29 UTC - mysqld got signal 6 ;

Core was generated by `/sda/MS200317-mysql-5.7.17-linux-x86_64-debug/bin/mysqld --no-defaults --log-bi'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimised out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62
62	../sysdeps/unix/sysv/linux/pthread_kill.c: No such file or directory.
[Current thread is 1 (Thread 0x7f20e2ca4700 (LWP 5360))]
(gdb) bt
#0  __pthread_kill (threadid=<optimised out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62
#1  0x0000564223a8bcb4 in my_write_core (sig=6) at /git/MS57_dbg/mysys/stacktrace.c:249
#2  0x000056422303978f in handle_fatal_signal (sig=6) at /git/MS57_dbg/sql/signal_handler.cc:220
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
#5  0x00007f20e09693ea in __GI_abort () at abort.c:89
#6  0x00007f20e095fbb7 in __assert_fail_base (fmt=<optimised out>, 
    assertion=assertion@entry=0x5642242e6090 "head->owned_gtid.sidno == THD::OWNED_SIDNO_ANONYMOUS", 
    file=file@entry=0x5642242e5a59 "/git/MS57_dbg/sql/binlog.cc", line=line@entry=1155, 
    function=function@entry=0x5642242eb900 <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  0x00007f20e095fc62 in __GI___assert_fail (assertion=0x5642242e6090 "head->owned_gtid.sidno == THD::OWNED_SIDNO_ANONYMOUS", 
    file=0x5642242e5a59 "/git/MS57_dbg/sql/binlog.cc", line=1155, 
    function=0x5642242eb900 <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  0x00005642239e2bb7 in MYSQL_BIN_LOG::assign_automatic_gtids_to_flush_group (this=0x564224e168c0 <mysql_bin_log>, first_seen=0x7f20bb019000)
    at /git/MS57_dbg/sql/binlog.cc:1155
#9  0x00005642239f502e in MYSQL_BIN_LOG::process_flush_stage_queue (this=0x564224e168c0 <mysql_bin_log>, total_bytes_var=0x7f20e2ca1410, 
    rotate_var=0x7f20e2ca13fe, out_queue_var=0x7f20e2ca1418) at /git/MS57_dbg/sql/binlog.cc:8359
#10 0x00005642239f666f in MYSQL_BIN_LOG::ordered_commit (this=0x564224e168c0 <mysql_bin_log>, thd=0x7f20bb019000, all=false, skip_commit=false)
    at /git/MS57_dbg/sql/binlog.cc:8996
#11 0x00005642239f4c7a in MYSQL_BIN_LOG::commit (this=0x564224e168c0 <mysql_bin_log>, thd=0x7f20bb019000, all=false) at /git/MS57_dbg/sql/binlog.cc:8257
#12 0x0000564223834198 in trans_commit_stmt (thd=0x7f20bb019000) at /git/MS57_dbg/sql/transaction.cc:463
#13 0x000056422372fe83 in mysql_execute_command (thd=0x7f20bb019000, first_level=true) at /git/MS57_dbg/sql/sql_parse.cc:5043
#14 0x00005642237315d2 in mysql_parse (thd=0x7f20bb019000, parser_state=0x7f20e2ca3510) at /git/MS57_dbg/sql/sql_parse.cc:5611
#15 0x00005642237260dc in dispatch_command (thd=0x7f20bb019000, com_data=0x7f20e2ca3dc0, command=COM_QUERY) at /git/MS57_dbg/sql/sql_parse.cc:1461
#16 0x0000564223724e5a in do_command (thd=0x7f20bb019000) at /git/MS57_dbg/sql/sql_parse.cc:999
#17 0x00005642238667a2 in handle_connection (arg=0x7f20c577ea40) at /git/MS57_dbg/sql/conn_handler/connection_handler_per_thread.cc:300
#18 0x0000564223f5661d in pfs_spawn_thread (arg=0x7f20ce7f0d20) at /git/MS57_dbg/storage/perfschema/pfs.cc:2188
#19 0x00007f20e15a86ca in start_thread (arg=0x7f20e2ca4700) at pthread_create.c:333
#20 0x00007f20e0a3a0af in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:105

How to repeat:
# mysqld options required for replay: --log-bin --server-id=0
DROP DATABASE test;CREATE DATABASE test;USE test;
DROP TABLE mysql.event;
SET GTID_NEXT='ANONYMOUS';
DROP DATABASE test;
[21 Mar 2017 0:52] Roel Van de Paar
security issue?
[21 Mar 2017 5:50] MySQL Verification Team
Hello Roel,

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

Thanks,
Umesh
[21 Mar 2017 5:51] MySQL Verification Team
-- 5.7.17 Only debug build affected

rm -rf 85500
bin/mysqld --initialize-insecure --basedir=$PWD --datadir=$PWD/85500 -v
bin/mysqld-debug --no-defaults --log-bin --server-id=0 --basedir=$PWD --datadir=$PWD/85500 --core-file --socket=/tmp/mysql_ushastry.sock --port=3306 --log-error=$PWD/85500/log.err 2>&1 &

(gdb) bt
#0  0x00007fb2b6d7d771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x00000000018bfe19 in my_write_core (sig=6) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/mysys/stacktrace.c:249
#2  0x0000000000ecba80 in handle_fatal_signal (sig=6) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x00007fb2b59835d7 in raise () from /lib64/libc.so.6
#5  0x00007fb2b5984cc8 in abort () from /lib64/libc.so.6
#6  0x00007fb2b597c546 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007fb2b597c5f2 in __assert_fail () from /lib64/libc.so.6
#8  0x0000000001821897 in MYSQL_BIN_LOG::assign_automatic_gtids_to_flush_group (this=0x2e3e640 <mysql_bin_log>, first_seen=0x7fb250000b70)
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/binlog.cc:1155
#9  0x000000000183262f in MYSQL_BIN_LOG::process_flush_stage_queue (this=0x2e3e640 <mysql_bin_log>, total_bytes_var=0x7fb2ac242ed8, rotate_var=0x7fb2ac242ed7, out_queue_var=0x7fb2ac242ec8)
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/binlog.cc:8359
#10 0x0000000001833bbb in MYSQL_BIN_LOG::ordered_commit (this=0x2e3e640 <mysql_bin_log>, thd=0x7fb250000b70, all=false, skip_commit=false)
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/binlog.cc:8996
#11 0x000000000183230a in MYSQL_BIN_LOG::commit (this=0x2e3e640 <mysql_bin_log>, thd=0x7fb250000b70, all=false)
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/binlog.cc:8257
#12 0x000000000167f51b in trans_commit_stmt (thd=0x7fb250000b70) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/transaction.cc:463
#13 0x000000000158176e in mysql_execute_command (thd=0x7fb250000b70, first_level=true) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/sql_parse.cc:5043
#14 0x0000000001582c75 in mysql_parse (thd=0x7fb250000b70, parser_state=0x7fb2ac245690) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/sql_parse.cc:5611
#15 0x00000000015774f6 in dispatch_command (thd=0x7fb250000b70, com_data=0x7fb2ac245e00, command=COM_QUERY)
    at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/sql_parse.cc:1461
#16 0x00000000015762f9 in do_command (thd=0x7fb250000b70) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/sql_parse.cc:999
#17 0x00000000016abfc4 in handle_connection (arg=0x469fbc0) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/sql/conn_handler/connection_handler_per_thread.cc:300
#18 0x000000000194c420 in pfs_spawn_thread (arg=0x468ec90) at /export/home/pb2/build/sb_0-21378219-1480347226.17/mysql-5.7.17/storage/perfschema/pfs.cc:2188
#19 0x00007fb2b6d78df5 in start_thread () from /lib64/libpthread.so.0
#20 0x00007fb2b5a4460d in clone () from /lib64/libc.so.6
(gdb)

-- 5.7.17 release build not affected

rm -rf 85500
bin/mysqld --initialize-insecure --basedir=$PWD --datadir=$PWD/85500 -v
bin/mysqld --no-defaults --log-bin --server-id=0 --basedir=$PWD --datadir=$PWD/85500 --core-file --socket=/tmp/mysql_ushastry.sock --port=3306 --log-error=$PWD/85500/log.err 2>&1 &

[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.17: bin/mysql -uroot -S /tmp/mysql_ushastry.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@localhost [(none)]> DROP DATABASE test;CREATE DATABASE test;USE test;
ERROR 1008 (HY000): Can't drop database 'test'; database doesn't exist
Query OK, 1 row affected (0.00 sec)

Database changed
root@localhost [test]> DROP TABLE mysql.event;
Query OK, 0 rows affected (0.00 sec)

root@localhost [test]> SET GTID_NEXT='ANONYMOUS';
Query OK, 0 rows affected (0.00 sec)

root@localhost [test]> DROP DATABASE test;
Query OK, 0 rows affected, 1 warning (0.00 sec)