Bug #86250 thd->ha_data[ht_arg->slot].ha_ptr_backup == __null || (thd->is_binlog_applier()
Submitted: 10 May 2017 1:46 Modified: 25 Jul 2017 8:18
Reporter: Roel Van de Paar (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S6 (Debug Builds)
Version:5.7.17, 5.7.18 OS:Any
Assigned to: CPU Architecture:Any

[10 May 2017 1:46] Roel Van de Paar
Description:
Version: '5.7.17-debug'  socket: '/sda/MS010217-mysql-5.7.17-linux-x86_64-debug/socket.sock'  port: 18388  MySQL Community Server (GPL)
mysqld: /git/mysql-server_dbg/sql/handler.cc:1382: void trans_register_ha(THD*, bool, handlerton*, const ulonglong*): Assertion `thd->ha_data[ht_arg->slot].ha_ptr_backup == __null || (thd->is_binlog_applier() || thd->slave_thread)' failed.
01:18:13 UTC - mysqld got signal 6 ;

Core was generated by `/sda/MS010217-mysql-5.7.17-linux-x86_64-debug/bin/mysqld --no-defaults --core-f'.
Program terminated with signal 6, Aborted.
#0  0x00007ffab98f6741 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  0x00007ffab98f6741 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
#1  0x0000000001826d71 in my_write_core (sig=6) at /git/mysql-server_dbg/mysys/stacktrace.c:249
#2  0x0000000000e75574 in handle_fatal_signal (sig=6) at /git/mysql-server_dbg/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x00007ffab7c8a1d7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#5  0x00007ffab7c8b8c8 in __GI_abort () at abort.c:90
#6  0x00007ffab7c83146 in __assert_fail_base (fmt=0x7ffab7dd43a8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x1d792e8 "thd->ha_data[ht_arg->slot].ha_ptr_backup == __null || (thd->is_binlog_applier() || thd->slave_thread)", file=file@entry=0x1d78d28 "/git/mysql-server_dbg/sql/handler.cc", line=line@entry=1382, 
    function=function@entry=0x1d7b700 <trans_register_ha(THD*, bool, handlerton*, unsigned long long const*)::__PRETTY_FUNCTION__> "void trans_register_ha(THD*, bool, handlerton*, const ulonglong*)") at assert.c:92
#7  0x00007ffab7c831f2 in __GI___assert_fail (
    assertion=0x1d792e8 "thd->ha_data[ht_arg->slot].ha_ptr_backup == __null || (thd->is_binlog_applier() || thd->slave_thread)", 
    file=0x1d78d28 "/git/mysql-server_dbg/sql/handler.cc", line=1382, 
    function=0x1d7b700 <trans_register_ha(THD*, bool, handlerton*, unsigned long long const*)::__PRETTY_FUNCTION__> "void trans_register_ha(THD*, bool, handlerton*, const ulonglong*)") at assert.c:101
#8  0x0000000000eee1c9 in trans_register_ha (thd=0x7ffa7c019000, all=true, ht_arg=0x7ffab1bb74a0, trxid=0x7ffab9ee6d48)
    at /git/mysql-server_dbg/sql/handler.cc:1381
#9  0x0000000001956487 in innobase_register_trx (hton=0x7ffab1bb74a0, thd=0x7ffa7c019000, trx=0x7ffaa8c00cf8)
    at /git/mysql-server_dbg/storage/innobase/handler/ha_innodb.cc:2885
#10 0x000000000196e9c8 in ha_innobase::external_lock (this=0x7ffa7c0aa430, thd=0x7ffa7c019000, lock_type=1)
    at /git/mysql-server_dbg/storage/innobase/handler/ha_innodb.cc:15504
#11 0x0000000000efce40 in handler::ha_external_lock (this=0x7ffa7c0aa430, thd=0x7ffa7c019000, lock_type=1)
    at /git/mysql-server_dbg/sql/handler.cc:7839
#12 0x00000000016aa299 in lock_external (thd=0x7ffa7c019000, tables=0x7ffa7c032578, count=1) at /git/mysql-server_dbg/sql/lock.cc:389
#13 0x00000000016a9f9b in mysql_lock_tables (thd=0x7ffa7c019000, tables=0x7ffa7c02c1f8, count=1, flags=0)
    at /git/mysql-server_dbg/sql/lock.cc:326
#14 0x000000000147521d in lock_tables (thd=0x7ffa7c019000, tables=0x7ffa7c02bbc8, count=1, flags=0)
    at /git/mysql-server_dbg/sql/sql_base.cc:6631
#15 0x0000000001714794 in Sql_cmd_insert::mysql_insert (this=0x7ffa7c02c158, thd=0x7ffa7c019000, table_list=0x7ffa7c02bbc8)
    at /git/mysql-server_dbg/sql/sql_insert.cc:617
#16 0x000000000171b652 in Sql_cmd_insert::execute (this=0x7ffa7c02c158, thd=0x7ffa7c019000)
    at /git/mysql-server_dbg/sql/sql_insert.cc:3103
#17 0x00000000014f5d69 in mysql_execute_command (thd=0x7ffa7c019000, first_level=true) at /git/mysql-server_dbg/sql/sql_parse.cc:3606
#18 0x00000000014fb5f5 in mysql_parse (thd=0x7ffa7c019000, parser_state=0x7ffab9ee8550) at /git/mysql-server_dbg/sql/sql_parse.cc:5611
#19 0x00000000014f0c1d in dispatch_command (thd=0x7ffa7c019000, com_data=0x7ffab9ee8cb0, command=COM_QUERY)
    at /git/mysql-server_dbg/sql/sql_parse.cc:1461
#20 0x00000000014efa44 in do_command (thd=0x7ffa7c019000) at /git/mysql-server_dbg/sql/sql_parse.cc:999
#21 0x000000000161f9d0 in handle_connection (arg=0x7ffa8efec860)
    at /git/mysql-server_dbg/sql/conn_handler/connection_handler_per_thread.cc:300
#22 0x00000000018534f9 in pfs_spawn_thread (arg=0x7ffa9d676220) at /git/mysql-server_dbg/storage/perfschema/pfs.cc:2188
#23 0x00007ffab98f1dc5 in start_thread (arg=0x7ffab9ee9700) at pthread_create.c:308
#24 0x00007ffab7d4c73d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

How to repeat:
DROP DATABASE test;CREATE DATABASE test;USE test;
BINLOG ' O1ZVRw8BAAAAZgAAAGoAAAAAAAQANS4xLjIzLXJjLWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAA7VlVHEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC ';
SET pseudo_slave_mode=1;
CREATE TABLE t1(a BINARY (1)) ROW_FORMAT=COMPRESSED ENGINE=InnoDB;
xa start '','';
SET @@session.pseudo_slave_mode=FALSE;
INSERT INTO t1 VALUES(@aaa);

Note that --log-bin does NOT seem required.
[10 May 2017 5:23] Roel Van de Paar
DROP DATABASE test;
BINLOG ' AMqaOw8BAAAAdAAAAHgAAAAAAAQANS42LjM0LTc5LjEtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAypo7EzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAQKv XjI= ';
SET @@session.pseudo_slave_mode = ON;
XA START 0xABCDEF1234567890, 0x01, 0x02;
SET @@session.pseudo_slave_mode = FALSE;
INSERT INTO mysql.time_zone_transition_type VALUES (@tzid, 2, @offset_month_03, 1, 'b16420_2');
[10 May 2017 6:01] Umesh Shastry
Hello Roel,

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

Thanks,
Umesh
[25 Jul 2017 8:18] Margaret Fisher
Posted by developer:
 
Changelog entry added for MySQL 5.7.20 and 8.0.3:

        The system variable
        <literal role="sysvar">pseudo_slave_mode</literal>, which is for
        internal server use, sometimes raised an assertion when it was
        changed inside a transaction. The server no longer changes this
        variable inside a transaction.