Bug #88272 Assertion `new_value >= 0' failed.
Submitted: 28 Oct 2017 4:04 Modified: 11 Jan 15:16
Reporter: Roel Van de Paar (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: XA transactions Severity:S6 (Debug Builds)
Version:8.0.3 RC OS:Any
Assigned to: CPU Architecture:Any
Tags: debug

[28 Oct 2017 4:04] Roel Van de Paar
Description:
2017-10-28T03:35:09.281048Z 0 [Note] /sda/MS201017-mysql-8.0.3-rc-linux-x86_64-debug/bin/mysqld: ready for connections. Version: '8.0.3-rc-debug-log'  socket: '/sda/MS201017-mysql-8.0.3-rc-linux-x86_64-debug/socket.sock'  port: 16654  MySQL Community Server (GPL)
mysqld: /git/mysql-server_dbg/sql/rpl_gtid.h:2806: void Gtid_state::end_anonymous_gtid_violating_transaction(): Assertion `new_value >= 0' failed.
03:35:24 UTC - mysqld got signal 6 ;

Core was generated by `/sda/MS201017-mysql-8.0.3-rc-linux-x86_64-debug/bin/mysqld --no-defaults --core'.
Program terminated with signal 6, Aborted.
#0  0x00007f05f76449b1 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
61	  val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
(gdb) bt
#0  0x00007f05f76449b1 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
#1  0x000000000369e428 in my_write_core (sig=6) at /git/mysql-server_dbg/mysys/stacktrace.cc:291
#2  0x000000000286b8f6 in handle_fatal_signal (sig=6) at /git/mysql-server_dbg/sql/signal_handler.cc:234
#3  <signal handler called>
#4  0x00007f05f595c1f7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#5  0x00007f05f595d8e8 in __GI_abort () at abort.c:90
#6  0x00007f05f5955266 in __assert_fail_base (fmt=0x7f05f5aa7e68 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x476ed94 "new_value >= 0", file=file@entry=0x476eb20 "/git/mysql-server_dbg/sql/rpl_gtid.h", 
    line=line@entry=2806, 
    function=function@entry=0x4770560 <Gtid_state::end_anonymous_gtid_violating_transaction()::__PRETTY_FUNCTION__> "void Gtid_state::end_anonymous_gtid_violating_transaction()") at assert.c:92
#7  0x00007f05f5955312 in __GI___assert_fail (assertion=0x476ed94 "new_value >= 0", 
    file=0x476eb20 "/git/mysql-server_dbg/sql/rpl_gtid.h", line=2806, 
    function=0x4770560 <Gtid_state::end_anonymous_gtid_violating_transaction()::__PRETTY_FUNCTION__> "void Gtid_state::end_anonymous_gtid_violating_transaction()") at assert.c:101
#8  0x000000000359b52f in Gtid_state::end_anonymous_gtid_violating_transaction (this=0x7f05f3837600)
    at /git/mysql-server_dbg/sql/rpl_gtid.h:2806
#9  0x00000000035986e0 in Gtid_state::end_gtid_violating_transaction (this=0x7f05f3837600, thd=0x7f05afc19000)
    at /git/mysql-server_dbg/sql/rpl_gtid_state.cc:296
#10 0x000000000359aaf9 in Gtid_state::update_gtids_impl_end (this=0x7f05f3837600, thd=0x7f05afc19000, more_trx=false)
    at /git/mysql-server_dbg/sql/rpl_gtid_state.cc:1059
#11 0x0000000003598615 in Gtid_state::update_gtids_impl (this=0x7f05f3837600, thd=0x7f05afc19000, is_commit=false)
    at /git/mysql-server_dbg/sql/rpl_gtid_state.cc:277
#12 0x0000000003598427 in Gtid_state::update_on_rollback (this=0x7f05f3837600, thd=0x7f05afc19000)
    at /git/mysql-server_dbg/sql/rpl_gtid_state.cc:236
#13 0x000000000241a46c in close_temporary_tables (thd=0x7f05afc19000) at /git/mysql-server_dbg/sql/sql_base.cc:1960
#14 0x000000000243daed in THD::cleanup (this=0x7f05afc19000) at /git/mysql-server_dbg/sql/sql_class.cc:1011
#15 0x000000000243ddff in THD::release_resources (this=0x7f05afc19000) at /git/mysql-server_dbg/sql/sql_class.cc:1079
#16 0x000000000285b333 in handle_connection (arg=0x7f05e3aeb3c0)
    at /git/mysql-server_dbg/sql/conn_handler/connection_handler_per_thread.cc:336
#17 0x00000000036ec54d in pfs_spawn_thread (arg=0x7f05e3b87520) at /git/mysql-server_dbg/storage/perfschema/pfs.cc:2985
#18 0x00007f05f763fe25 in start_thread (arg=0x7f05f7beb700) at pthread_create.c:308
#19 0x00007f05f5a1f34d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

How to repeat:
CREATE DATABASE test;
USE test;
XA START 'test2';
CREATE TEMPORARY TABLE t1(a INT);
XA END 'test2';
XA PREPARE 'test2';
SET @@SESSION.GTID_NEXT = 'ANONYMOUS';
# Then attempt to shutdown server using: mysqladmin shutdown, then check log
[28 Oct 2017 18:30] Miguel Solorzano
Thank you for the bug report. Verified as described.
[11 Jan 15:16] Margaret Fisher
Posted by developer:
 
Changelog entry added for MySQL 8.0.5:

Attempts to set a GTID for an unsafe or empty XA transaction using a SET @@SESSION.GTID_NEXT statement were not being handled correctly. On a server with gtid_mode set to OFF or OFF_PERMISSIVE, and enforce_gtid_consistency set to OFF, setting a GTID for an unsafe XA transaction (creating or dropping a temporary table) caused an inconsistency in the server's GTID violation counter and raised an assertion. Testing also showed that setting a GTID for an empty XA transaction caused an incorrect sequence of events to be written to the binary log. Both these situations are now handled correctly.