Bug #80168 Assertion `get_state() >= 0' failed in sql/rpl_gtid.h:535
Submitted: 27 Jan 2016 8:21 Modified: 27 Jan 2016 9:22
Reporter: Ramesh Sivaraman Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.7.10, 5.7.12 OS:CentOS
Assigned to: CPU Architecture:Any
Tags: debug

[27 Jan 2016 8:21] Ramesh Sivaraman
Description:
#0  0x00007fde58691741 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  0x00007fde5681e5f7 in raise () from /lib64/libc.so.6
#5  0x00007fde5681fce8 in abort () from /lib64/libc.so.6
#6  0x00007fde56817566 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007fde56817612 in __assert_fail () from /lib64/libc.so.6
#8  0x0000000000e4f7e7 in Checkable_rwlock::assert_no_wrlock (this=0x7fde544369c0) at /sda/mysql-server_dbg/sql/rpl_gtid.h:535
#9  0x0000000000e4f546 in Checkable_rwlock::rdlock (this=0x7fde544369c0) at /sda/mysql-server_dbg/sql/rpl_gtid.h:471
#10 0x0000000001714208 in Gtid_state::update_gtids_impl (this=0x7fde4cfcb400, thd=0x7fde17419000, is_commit=false) at /sda/mysql-server_dbg/sql/rpl_gtid_state.cc:248
#11 0x000000000171405d in Gtid_state::update_on_rollback (this=0x7fde4cfcb400, thd=0x7fde17419000) at /sda/mysql-server_dbg/sql/rpl_gtid_state.cc:177
#12 0x0000000000ed1881 in ha_rollback_trans (thd=0x7fde17419000, all=false) at /sda/mysql-server_dbg/sql/handler.cc:1959
#13 0x000000000177c1e0 in System_table_access::close_table (this=0x7fde58c46200, thd=0x7fde17419000, table=0x7fde1745ba20, backup=0x7fde58c46220, error=true, need_commit=true) at /sda/mysql-server_dbg/sql/rpl_table_access.cc:105
#14 0x000000000171a525 in Gtid_table_access_context::deinit (this=0x7fde58c46200, thd=0x7fde17419000, table=0x7fde1745ba20, error=true, need_commit=true) at /sda/mysql-server_dbg/sql/rpl_gtid_persist.cc:132
#15 0x000000000171bd6e in Gtid_table_persistor::reset (this=0x7fde5441d0f0, thd=0x7fde17419000) at /sda/mysql-server_dbg/sql/rpl_gtid_persist.cc:613
#16 0x0000000001713b6c in Gtid_state::clear (this=0x7fde4cfcb400, thd=0x7fde17419000) at /sda/mysql-server_dbg/sql/rpl_gtid_state.cc:36
#17 0x000000000177f1f5 in reset_master (thd=0x7fde17419000) at /sda/mysql-server_dbg/sql/rpl_master.cc:556
#18 0x00000000015269ce in reload_acl_and_cache (thd=0x7fde17419000, options=128, tables=0x0, write_to_binlog=0x7fde58c4708c) at /sda/mysql-server_dbg/sql/sql_reload.cc:311
#19 0x00000000014e79f8 in mysql_execute_command (thd=0x7fde17419000, first_level=true) at /sda/mysql-server_dbg/sql/sql_parse.cc:4113
#20 0x00000000014eb3dd in mysql_parse (thd=0x7fde17419000, parser_state=0x7fde58c47560) at /sda/mysql-server_dbg/sql/sql_parse.cc:5508
#21 0x00000000014e0d17 in dispatch_command (thd=0x7fde17419000, com_data=0x7fde58c47cb0, command=COM_QUERY) at /sda/mysql-server_dbg/sql/sql_parse.cc:1425
#22 0x00000000014dfbe1 in do_command (thd=0x7fde17419000) at /sda/mysql-server_dbg/sql/sql_parse.cc:993
#23 0x000000000160adc7 in handle_connection (arg=0x7fde427ff8c0) at /sda/mysql-server_dbg/sql/conn_handler/connection_handler_per_thread.cc:301
#24 0x000000000188e1b8 in pfs_spawn_thread (arg=0x7fde403ec220) at /sda/mysql-server_dbg/storage/perfschema/pfs.cc:2192
#25 0x00007fde5868cdc5 in start_thread () from /lib64/libpthread.so.0
#26 0x00007fde568df21d in clone () from /lib64/libc.so.6

How to repeat:
Testcase

DROP DATABASE test;
SET @@global.gtid_purged='11111111-1111-1111-1111-111111111111:2';
BINLOG ' SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8=';
SET @@global.innodb_trx_rseg_n_slots_debug=1;
reset master;

The attached tarball (1453711833_bug_bundle.tar.gz) gives the testcase as an exact match of our system, including some handy utilities

$ vi 1453711833_mybase     # STEP1: Update the base path in this file (usually the only change required!). If you use a non-binary distribution, please update SOURCE_DIR location also
$ ./1453711833_init        # STEP2: Initializes the data dir
$ ./1453711833_start       # STEP3: Starts mysqld
$ ./1453711833_cl          # STEP4: To check mysqld is up
$ ./1453711833_run_pquery  # STEP5: Run the testcase with the pquery binary
$ ./1453711833_run         # OPTIONAL: Run the testcase with the mysql CLI (may not reproduce the issue, as the pquery binary was used for the original testcase reduction)
$ vi /dev/shm/1453711833/error.log.out  # STEP6: Verify the error log
$ ./1453711833_gdb         # OPTIONAL: Brings you to a gdb prompt with gdb attached to the used mysqld and attached to the generated core
$ ./1453711833_parse_core  # STEP7: Creates 1453711833_STD.gdb and 1453711833_FULL.gdb; standard and full variables gdb stack traces
[27 Jan 2016 8:22] Ramesh Sivaraman
Testcase bundle

Attachment: 1453711833_bug_bundle.tar.gz (application/gzip, text), 2.02 MiB.

[27 Jan 2016 9:22] MySQL Verification Team
Hello Ramesh,

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

Thanks,
Umesh
[21 May 2018 1:44] Roel Van de Paar
See also bug 90946