Bug #80663 Assertion `thd->owned_gtid.is_empty()' failed in sql/rpl_gtid_state.cc:613
Submitted: 9 Mar 2016 4:54 Modified: 24 Nov 2018 15:24
Reporter: Ramesh Sivaraman (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.7.10, 5.7.11, 8.0.13 OS:CentOS
Assigned to: CPU Architecture:Any
Tags: debug

[9 Mar 2016 4:54] Ramesh Sivaraman
Description:
Error info :

Version: '5.7.10-debug-log'  socket: '/dev/shm/1452850231/socket.sock'  port: 31962  MySQL Community Server (GPL)
mysqld: /sda/mysql-server_dbg/sql/rpl_gtid_state.cc:613: enum_return_status Gtid_state::generate_automatic_gtid(THD*, rpl_sidno, rpl_gno): Assertion `thd->ow
ned_gtid.is_empty()' failed.

GDB info :

#0  0x00007f5d49a1a741 in pthread_kill () from /lib64/libpthread.so.0
#1  0x00000000017ef51c in my_write_core (sig=6) at /sda/mysql-server_dbg/mysys/stacktrace.c:247
#2  0x0000000000e583e4 in handle_fatal_signal (sig=6) at /sda/mysql-server_dbg/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x00007f5d47ba65f7 in raise () from /lib64/libc.so.6
#5  0x00007f5d47ba7ce8 in abort () from /lib64/libc.so.6
#6  0x00007f5d47b9f566 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f5d47b9f612 in __assert_fail () from /lib64/libc.so.6
#8  0x000000000171504e in Gtid_state::generate_automatic_gtid (this=0x7f5d3e3cb400, thd=0x7f5d08419000, specified_sidno=0, specified_gno=0) at /sda/mysql-server_dbg/sql/rpl_gtid_state.cc:613
#9  0x0000000001754ee7 in MYSQL_BIN_LOG::write_gtid (this=0x2b0d6c0 <mysql_bin_log>, thd=0x7f5d08419000, cache_data=0x7f5d085422a0, writer=0x7f5d49fccf70) at /sda/mysql-server_dbg/sql/binlog.cc:1142
#10 0x0000000001755ad7 in binlog_cache_data::flush (this=0x7f5d085422a0, thd=0x7f5d08419000, bytes_written=0x7f5d49fccfe0, wrote_xid=0x7f5d49fcd017) at /sda/mysql-server_dbg/sql/binlog.cc:1427
#11 0x000000000176e737 in binlog_cache_mngr::flush (this=0x7f5d085422a0, thd=0x7f5d08419000, bytes_written=0x7f5d49fcd018, wrote_xid=0x7f5d49fcd017) at /sda/mysql-server_dbg/sql/binlog.cc:725
#12 0x0000000001765483 in MYSQL_BIN_LOG::flush_thread_caches (this=0x2b0d6c0 <mysql_bin_log>, thd=0x7f5d08419000) at /sda/mysql-server_dbg/sql/binlog.cc:8097
#13 0x000000000176568d in MYSQL_BIN_LOG::process_flush_stage_queue (this=0x2b0d6c0 <mysql_bin_log>, total_bytes_var=0x7f5d49fcd158, rotate_var=0x7f5d49fcd157, out_queue_var=0x7f5d49fcd148) at /sda/mysql-server_dbg/sql/binlog.cc:8159
#14 0x0000000001766bca in MYSQL_BIN_LOG::ordered_commit (this=0x2b0d6c0 <mysql_bin_log>, thd=0x7f5d08419000, all=true, skip_commit=false) at /sda/mysql-server_dbg/sql/binlog.cc:8789
#15 0x000000000176534c in MYSQL_BIN_LOG::commit (this=0x2b0d6c0 <mysql_bin_log>, thd=0x7f5d08419000, all=true) at /sda/mysql-server_dbg/sql/binlog.cc:8061
#16 0x000000000145d6e1 in close_temporary_tables (thd=0x7f5d08419000) at /sda/mysql-server_dbg/sql/sql_base.cc:1975
#17 0x0000000001729004 in Start_log_event_v3::do_apply_event (this=0x7f5d08531660, rli=0x7f5d0847a000) at /sda/mysql-server_dbg/sql/log_event.cc:5135
#18 0x0000000001729cda in Format_description_log_event::do_apply_event (this=0x7f5d08531620, rli=0x7f5d0847a000) at /sda/mysql-server_dbg/sql/log_event.cc:5376
#19 0x00000000017237c8 in Log_event::apply_event (this=0x7f5d08531660, rli=0x7f5d0847a000) at /sda/mysql-server_dbg/sql/log_event.cc:3324
#20 0x00000000017713ef in mysql_client_binlog_statement (thd=0x7f5d08419000) at /sda/mysql-server_dbg/sql/sql_binlog.cc:275
#21 0x00000000014e9563 in mysql_execute_command (thd=0x7f5d08419000, first_level=true) at /sda/mysql-server_dbg/sql/sql_parse.cc:4756
#22 0x00000000014eb3dd in mysql_parse (thd=0x7f5d08419000, parser_state=0x7f5d49fd0560) at /sda/mysql-server_dbg/sql/sql_parse.cc:5508
#23 0x00000000014e0d17 in dispatch_command (thd=0x7f5d08419000, com_data=0x7f5d49fd0cb0, command=COM_QUERY) at /sda/mysql-server_dbg/sql/sql_parse.cc:1425
#24 0x00000000014dfbe1 in do_command (thd=0x7f5d08419000) at /sda/mysql-server_dbg/sql/sql_parse.cc:993
#25 0x000000000160adc7 in handle_connection (arg=0x7f5d333ff9c0) at /sda/mysql-server_dbg/sql/conn_handler/connection_handler_per_thread.cc:301
#26 0x000000000188e1b8 in pfs_spawn_thread (arg=0x7f5d317f0120) at /sda/mysql-server_dbg/storage/perfschema/pfs.cc:2192
#27 0x00007f5d49a15dc5 in start_thread () from /lib64/libpthread.so.0
#28 0x00007f5d47c6721d in clone () from /lib64/libc.so.6

How to repeat:
Testcase

DROP DATABASE test;CREATE DATABASE test;USE test;
CREATE TABLE t1(c1 INT UNSIGNED);
set session gtid_next="ANONYMOUS";
CREATE TEMPORARY TABLE `t2`(`a` char)DEFAULT CHARSET=utf8 engine=MEMORY;
xa start 'test-bad';
UPDATE t1 SET c1=4;
BINLOG ' O1ZVRw8BAAAAZgAAAGoAAAAAAAQANS4xLjIzLXJjLWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAA7VlVHEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC ';
[9 Mar 2016 6:13] Ramesh Sivaraman
Startup options:

--server-id=100  --log-bin=binlog --binlog_format=MIXED
[9 Mar 2016 7:05] MySQL Verification Team
Hello Ramesh,

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

Thanks,
Umesh
[24 Nov 2018 5:16] Roel Van de Paar
Please add 8.0.13 as affected

# mysqld options required for replay: --log-bin --server-id=0 --binlog_format=STATEMENT
CREATE DATABASE test;
USE test;
BINLOG ' SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8=';
XA START 'test3','',5;
CREATE TEMPORARY TABLE t1(c1 INT)UNION=(t4,t5);
BINLOG ' SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8=';
[24 Nov 2018 5:20] Roel Van de Paar
Similar stack.

#6  0x00007f7e2eefe39a in __assert_fail_base (fmt=0x7f7e2f0857d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x565461113cc0 "thd->owned_gtid.is_empty()", 
    file=file@entry=0x5654611137d0 "/git/MS-8.0-trunk_dbg/sql/rpl_gtid_state.cc", line=line@entry=466, 
    function=function@entry=0x565461114f20 <Gtid_state::generate_automatic_gtid(THD*, int, long long, int*)::__PRETTY_FUNCTION__> "enum_return_status Gtid_state::generate_automatic_gtid(THD*, rpl_sidno, rpl_gno, rpl_sidno*)") at assert.c:92
#7  0x00007f7e2eefe412 in __GI___assert_fail (assertion=0x565461113cc0 "thd->owned_gtid.is_empty()", 
    file=0x5654611137d0 "/git/MS-8.0-trunk_dbg/sql/rpl_gtid_state.cc", line=466, 
    function=0x565461114f20 <Gtid_state::generate_automatic_gtid(THD*, int, long long, int*)::__PRETTY_FUNCTION__> "enum_return_status Gtid_state::generate_automatic_gtid(THD*, rpl_sidno, rpl_gno, rpl_sidno*)") at assert.c:101
#8  0x000056545f7d03de in Gtid_state::generate_automatic_gtid (this=0x7f7e2e469600, thd=0x7f7e07c23000, specified_sidno=0, 
    specified_gno=0, locked_sidno=0x7f7e2eec8ba4) at /git/MS-8.0-trunk_dbg/sql/rpl_gtid_state.cc:466
#9  0x000056545f811eb2 in MYSQL_BIN_LOG::assign_automatic_gtids_to_flush_group (this=0x5654623ca3a0 <mysql_bin_log>, 
    first_seen=0x7f7e07c23000) at /git/MS-8.0-trunk_dbg/sql/binlog.cc:1370

etc.
[24 Nov 2018 15:24] Ramesh Sivaraman
Reproduced with 8.0.13