Bug #91976 class.cc:2604: void THD::send_statement_status(): Assertion `0' failed.
Submitted: 11 Aug 2018 0:55 Modified: 7 Jun 2019 17:18
Reporter: Roel Van de Paar Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Archive storage engine Severity:S6 (Debug Builds)
Version:8.0.12 OS:Any
Assigned to: Georgi Kodinov CPU Architecture:Any
Tags: debug, optimized

[11 Aug 2018 0:55] Roel Van de Paar
Description:
mysqld: /git/MS-8.0.12_dbg/sql/sql_class.cc:2604: void THD::send_statement_status(): Assertion `0' failed.
00:53:23 UTC - mysqld got signal 6 ;

Core was generated by `/sda/MS300718-mysql-8.0.12-linux-x86_64-debug/bin/mysqld --no-defaults --core-f'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
57	../sysdeps/unix/sysv/linux/pthread_kill.c: No such file or directory.
[Current thread is 1 (Thread 0x7f263c8da700 (LWP 11761))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x000055b62b96278d in my_write_core (sig=6) at /git/MS-8.0.12_dbg/mysys/stacktrace.cc:278
#2  0x000055b62a6b6d94 in handle_fatal_signal (sig=6) at /git/MS-8.0.12_dbg/sql/signal_handler.cc:249
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x00007f263c91b801 in __GI_abort () at abort.c:79
#6  0x00007f263c90b39a in __assert_fail_base (fmt=0x7f263ca927d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x55b62c97e723 "0", file=file@entry=0x55b62c97ee50 "/git/MS-8.0.12_dbg/sql/sql_class.cc", 
    line=line@entry=2604, 
    function=function@entry=0x55b62c981100 <THD::send_statement_status()::__PRETTY_FUNCTION__> "void THD::send_statement_status()")
    at assert.c:92
#7  0x00007f263c90b412 in __GI___assert_fail (assertion=0x55b62c97e723 "0", file=0x55b62c97ee50 "/git/MS-8.0.12_dbg/sql/sql_class.cc", 
    line=2604, function=0x55b62c981100 <THD::send_statement_status()::__PRETTY_FUNCTION__> "void THD::send_statement_status()")
    at assert.c:101
#8  0x000055b62a49cd19 in THD::send_statement_status (this=0x7f2611c23000) at /git/MS-8.0.12_dbg/sql/sql_class.cc:2604
#9  0x000055b62a50706e in dispatch_command (thd=0x7f2611c23000, com_data=0x7f263c8d9c90, command=COM_QUERY)
    at /git/MS-8.0.12_dbg/sql/sql_parse.cc:1959
#10 0x000055b62a5043c6 in do_command (thd=0x7f2611c23000) at /git/MS-8.0.12_dbg/sql/sql_parse.cc:1232
#11 0x000055b62a6a4678 in handle_connection (arg=0x7f262a3a5480)
    at /git/MS-8.0.12_dbg/sql/conn_handler/connection_handler_per_thread.cc:308
#12 0x000055b62c013422 in pfs_spawn_thread (arg=0x7f26303e7720) at /git/MS-8.0.12_dbg/storage/perfschema/pfs.cc:2836
#13 0x00007f263e3076db in start_thread (arg=0x7f263c8da700) at pthread_create.c:463
#14 0x00007f263c9fc88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

How to repeat:
SET default_storage_engine=ARCHIVE;
CREATE TABLE mysql.slave_master_info(Number_of_lines int(10)unsigned COMMENT 'Number of lines in the file.',Master_log_name text COLLATE utf8_bin COMMENT 'The name of the master binary log currently being read from the master.',Master_log_pos INT(20) unsigned COMMENT 'The master log position of the last read event.',Host char(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT''COMMENT 'The host name of the master.',User_name text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.',User_password text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.',Port int(10) unsigned COMMENT 'The network port used to connect to the master.',Connect_retry int(10) unsigned COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.',Enabled_ssl INT(1) COMMENT 'Indicates whether the server supports SSL connections.',Ssl_ca text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.',Ssl_capath text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.',Ssl_cert text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.',Ssl_cipher text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.',Sslk text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.',Ssl_verify_server_cert INT(1) COMMENT 'Whether to verify the server certificate.',Heartbeat float,Bind text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server',Ignored_server_ids text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored,followed by the actual server IDs',Uuid text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',Retry_count INT(20) unsigned COMMENT 'Number of reconnect attempts,to the master,before giving up.',Ssl_crl text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)',Ssl_crlpath text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files',Enabled_auto_position INT(1) COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.',PRIMARY KEY (Host,Port)) DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information';
[11 Aug 2018 13:41] MySQL Verification Team
Thank you for the bug report.

2018-08-11T13:39:14.091872Z 0 [System] [MY-010931] [Server] /home/miguel/dbsd/8.0/bin/mysqld: ready for connections. Version: '8.0.13-debug'  socket: '/tmp/mysql80.sock'  port: 3380  Source distribution BUILD: 2018-JUL-20.
2018-08-11T13:39:15.344970Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of bind-address: '*' port: 33060 failed, `bind()` failed with error: Address already in use (98). Do you already have another mysqld server running with Mysqlx ?'
2018-08-11T13:39:15.345043Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/tmp/mysqlx.sock'
mysqld: /home/miguel/buildd/2018JUL20/mysql-8.0/sql/sql_class.cc:2618: void THD::send_statement_status(): Assertion `0' failed.
13:40:00 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=1
max_threads=151
thread_count=2
connection_count=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 67870 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7fc844072090
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7fc8d00cfc00 thread_stack 0x46000
/home/miguel/dbsd/8.0/bin/mysqld(my_print_stacktrace(unsigned char*, unsigned long)+0x43) [0x4148f2c]
/home/miguel/dbsd/8.0/bin/mysqld(handle_fatal_signal+0x3f5) [0x2f1d23e]
/lib64/libpthread.so.0(+0xf6d0) [0x7fc8e37776d0]
/lib64/libc.so.6(gsignal+0x37) [0x7fc8e1a8e277]
/lib64/libc.so.6(abort+0x148) [0x7fc8e1a8f968]
/lib64/libc.so.6(+0x2f096) [0x7fc8e1a87096]
/lib64/libc.so.6(+0x2f142) [0x7fc8e1a87142]
/home/miguel/dbsd/8.0/bin/mysqld(THD::send_statement_status()+0x221) [0x2cfb12f]
/home/miguel/dbsd/8.0/bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x289b) [0x2d7b201]
/home/miguel/dbsd/8.0/bin/mysqld(do_command(THD*)+0x43a) [0x2d783dc]
/home/miguel/dbsd/8.0/bin/mysqld() [0x2f09eac]
/home/miguel/dbsd/8.0/bin/mysqld() [0x4799b6d]
/lib64/libpthread.so.0(+0x7e25) [0x7fc8e376fe25]
/lib64/libc.so.6(clone+0x6d) [0x7fc8e1b56bad]

Trying to get some variables.
[19 Sep 2018 4:38] Roel Van de Paar
There is more here then originally thought. Optimized is affect to;

8.0.12>CREATE TABLE mysql.slave_master_info(Number_of_lines int(10)unsigned COMMENT 'Number of lines in the file.',Master_log_name text COLLATE utf8_bin COMMENT 'The name of the master binary log currently being read from the master.',Master_log_pos INT(20) unsigned COMMENT 'The master log position of the last read event.',Host char(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT''COMMENT 'The host name of the master.',User_name text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.',User_password text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.',Port int(10) unsigned COMMENT 'The network port used to connect to the master.',Connect_retry int(10) unsigned COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.',Enabled_ssl INT(1) COMMENT 'Indicates whether the server supports SSL connections.',Ssl_ca text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.',Ssl_capath text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.',Ssl_cert text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.',Ssl_cipher text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.',Sslk text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.',Ssl_verify_server_cert INT(1) COMMENT 'Whether to verify the server certificate.',Heartbeat float,Bind text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server',Ignored_server_ids text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored,followed by the actual server IDs',Uuid text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',Retry_count INT(20) unsigned COMMENT 'Number of reconnect attempts,to the master,before giving up.',Ssl_crl text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)',Ssl_crlpath text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files',Enabled_auto_position INT(1) COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.',PRIMARY KEY (Host,Port)) DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information';
Query OK, 0 rows affected (0.00 sec)

8.0.12>CREATE TABLE mysql.slave_master_info(Number_of_lines int(10)unsigned COMMENT 'Number of lines in the file.',Master_log_name text COLLATE utf8_bin COMMENT 'The name of the master binary log currently being read from the master.',Master_log_pos INT(20) unsigned COMMENT 'The master log position of the last read event.',Host char(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT''COMMENT 'The host name of the master.',User_name text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.',User_password text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.',Port int(10) unsigned COMMENT 'The network port used to connect to the master.',Connect_retry int(10) unsigned COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.',Enabled_ssl INT(1) COMMENT 'Indicates whether the server supports SSL connections.',Ssl_ca text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.',Ssl_capath text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.',Ssl_cert text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.',Ssl_cipher text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.',Sslk text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.',Ssl_verify_server_cert INT(1) COMMENT 'Whether to verify the server certificate.',Heartbeat float,Bind text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server',Ignored_server_ids text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored,followed by the actual server IDs',Uuid text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',Retry_count INT(20) unsigned COMMENT 'Number of reconnect attempts,to the master,before giving up.',Ssl_crl text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)',Ssl_crlpath text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files',Enabled_auto_position INT(1) COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.',PRIMARY KEY (Host,Port)) DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information';
Query OK, 0 rows affected (0.00 sec)

8.0.12>CREATE TABLE mysql.t1 (id int);
Query OK, 0 rows affected (0.12 sec)

8.0.12>CREATE TABLE mysql.t1 (id int);
ERROR 1050 (42S01): Table 't1' already exists

8.0.12>create table mysql.user (id int);
ERROR 1050 (42S01): Table 'user' already exists

8.0.12>CREATE TABLE mysql.user(Number_of_lines int(10)unsigned COMMENT 'Number of lines in the file.',Master_log_name text COLLATE utf8_bin COMMENT 'The name of the master binary log currently being read from the master.',Master_log_pos INT(20) unsigned COMMENT 'The master log position of the last read event.',Host char(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT''COMMENT 'The host name of the master.',User_name text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.',User_password text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.',Port int(10) unsigned COMMENT 'The network port used to connect to the master.',Connect_retry int(10) unsigned COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.',Enabled_ssl INT(1) COMMENT 'Indicates whether the server supports SSL connections.',Ssl_ca text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.',Ssl_capath text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.',Ssl_cert text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.',Ssl_cipher text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.',Sslk text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.',Ssl_verify_server_cert INT(1) COMMENT 'Whether to verify the server certificate.',Heartbeat float,Bind text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server',Ignored_server_ids text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored,followed by the actual server IDs',Uuid text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',Retry_count INT(20) unsigned COMMENT 'Number of reconnect attempts,to the master,before giving up.',Ssl_crl text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)',Ssl_crlpath text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files',Enabled_auto_position INT(1) COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.',PRIMARY KEY (Host,Port)) DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information';
Query OK, 0 rows affected (0.00 sec)

Note that one can keep creating the "mysql.slave_master_info" table over and over. Replacing "slave_master_info" with "user" also lets the query pass.

Btw, there are some odd client scroll issues here too. You cannot go back to one of those longer queries. Please log this as a separate bug if it is unrelated to the primary bug here.
[30 Nov 2018 12:08] Georgi Kodinov
Posted by developer:
 
Some analysis: This is a regression from the fix of bug #27338431 (commit id f75f9c5673ffe0de044196b6781bf621d816835f).

The archive table doesn't allow keys longer than 8 bytes. 
And in 5.7 you indeed get that error when trying the above sequence. 
The error handler kicks in and schmoozes away the error. So the DA state is still EMPTY.
But the function still returns failure and unwinds the stack up to mysql_execute_command.
There a rollback is performed. But since there's nothing to rollback (unlike probably the case when the innodb engine is used), the DA state keeps being EMPTY. And when it tries to end the statement it asserts on the check of the DA state. 

Hence allowing the CREATE TABLE command to pass several times with no error returned. 
The ARCHIVE engine here is important ingredient since it's not InnoDB. But the error is not in it. So changing category to DDL.
[7 Jun 2019 17:18] Paul DuBois
Posted by developer:
 
Fixed in 8.0.18.

For debug builds, improper error checking for CREATE TABLE statements
could cause an assertion to be raised.