Bug #94901 Crash with use of SECONDARY_ENGINE
Submitted: 4 Apr 2019 7:42 Modified: 5 Apr 2019 4:45
Reporter: Krunal Bauskar Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Storage Engines Severity:S6 (Debug Builds)
Version:8.0.15 OS:Any
Assigned to: CPU Architecture:Any

[4 Apr 2019 7:42] Krunal Bauskar
Description:
Tried a simple secondary_engine command and it resulted in debug assert.

mysqld: /opt/projects/percona/non-forked-oracle/nfp-mysql-80/mysql-server/sql/handler.cc:8629: void handler::ha_set_primary_handler(handler*): Assertion `(ht->flags & (1 << 14)) != 0' failed.
07:40:10 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 = 67884 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7fe730000e40
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 = 7fe7c7e6ecd8 thread_stack 0x46000
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(my_print_stacktrace(unsigned char*, unsigned long)+0x55) [0x561e94a817fa]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(handle_fatal_signal+0x3f2) [0x561e93714041]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890) [0x7fe7dc537890]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7) [0x7fe7da938e97]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141) [0x7fe7da93a801]
/lib/x86_64-linux-gnu/libc.so.6(+0x3039a) [0x7fe7da92a39a]
/lib/x86_64-linux-gnu/libc.so.6(+0x30412) [0x7fe7da92a412]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(handler::ha_set_primary_handler(handler*)+0x46) [0x561e938ad1c4]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(+0x2bdd0b4) [0x561e934a10b4]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(open_tables_for_query(THD*, TABLE_LIST*, unsigned int)+0xea) [0x561e934a1215]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(Sql_cmd_dml::prepare(THD*)+0x19b) [0x561e935b7e63]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(Sql_cmd_dml::execute(THD*)+0x151) [0x561e935b85a9]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(mysql_execute_command(THD*, bool)+0x584c) [0x561e93553f7c]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(mysql_parse(THD*, Parser_state*, bool)+0x69c) [0x561e935566d1]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x14d6) [0x561e9354bee3]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(do_command(THD*)+0x487) [0x561e9354a439]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(+0x2e3b363) [0x561e936ff363]
/opt/projects/percona/non-forked-oracle/nfp-mysql-80/installed/bin/mysqld(+0x490fd96) [0x561e951d3d96]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76db) [0x7fe7dc52c6db]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7fe7daa1b88f]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (7fe7301881b8): select * from t
Connection ID (thread ID): 7
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

How to repeat:
create database test;
use test;
create table t (i int, c char(100), primary key pk(i)) engine=heap SECONDARY_ENGINE=MEMORY;
select * from t;

Suggested fix:
* I don't see any documentation about secondary engine so if this feature is still work in progress would be good to completely disable it.
[4 Apr 2019 13:19] MySQL Verification Team
Hi,

Thank you for your bug report.

Can you provide us with the exact test case and we shall be happy to verify this bug, if we repeat it.

Are you using our 8.0.15 source tarball, or are you using git repository ???
[5 Apr 2019 2:23] Krunal Bauskar
1. You need debug build. I am using 8.0.15 debug build.

2. simply start server with default params

3. Run following test-case

<test-case>
create database test;
use test;
create table t (i int, c char(100), primary key pk(i)) SECONDARY_ENGINE=MEMORY;
select * from t;
</test-case>

4. Last "select *" from will result in given assert.
[5 Apr 2019 4:45] MySQL Verification Team
Verified as described.

[Server] mysqld-debug.exe: Version: '8.0.15-debug' MySQL Community Server - GPL - Debug.

Assertion failed: (ht->flags & (1 << 14)) != 0, file g:\ade\build\sb_0-32399779-1548461704.49\mysql-8.0.15\sql\handler.cc, line 8629

mysqld-debug.exe!my_sigabrt_handler()[my_thr_init.cc:372]
  ucrtbased.dll!raise()
  ucrtbased.dll!abort()
  ucrtbased.dll!_get_wide_winmain_command_line()
  ucrtbased.dll!_get_wide_winmain_command_line()
  ucrtbased.dll!_get_wide_winmain_command_line()
  ucrtbased.dll!_wassert()
mysqld-debug.exe!handler::ha_set_primary_handler()[handler.cc:8629]
mysqld-debug.exe!open_secondary_engine_tables()[sql_base.cc:6484]
mysqld-debug.exe!open_tables_for_query()[sql_base.cc:6526]
mysqld-debug.exe!Sql_cmd_dml::prepare()[sql_select.cc:384]
mysqld-debug.exe!Sql_cmd_dml::execute()[sql_select.cc:533]
mysqld-debug.exe!mysql_execute_command()[sql_parse.cc:4354]
mysqld-debug.exe!mysql_parse()[sql_parse.cc:5105]
mysqld-debug.exe!dispatch_command()[sql_parse.cc:1720]
mysqld-debug.exe!do_command()[sql_parse.cc:1263]
mysqld-debug.exe!handle_connection()[connection_handler_per_thread.cc:305]
mysqld-debug.exe!pfs_spawn_thread()[pfs.cc:2838]
mysqld-debug.exe!win_thread_start()[my_thread.cc:51]
[5 Apr 2019 5:12] MySQL Verification Team
(gdb) bt
#0  0x00000000092f45d7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00000000092f5cc8 in __GI_abort () at abort.c:90
#2  0x00000000092ed546 in __assert_fail_base (fmt=0x943b128 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x50ff053 "(ht->flags & (1 << 14)) != 0", fil                                e=file@entry=0x50fc640 "../../mysql-8.0.15/sql/handler.cc", line=line@entry=8629, function=function@entry=0x5101e60 <handler::ha_set_primary_handler(handler*)::__PRETTY_FUNCTIO                                N__> "void handler::ha_set_primary_handler(handler*)") at assert.c:92
#3  0x00000000092ed5f2 in __GI___assert_fail (assertion=0x50ff053 "(ht->flags & (1 << 14)) != 0", file=0x50fc640 "../../mysql-8.0.15/sql/handler.cc", line=8629, function=0x5101                                e60 <handler::ha_set_primary_handler(handler*)::__PRETTY_FUNCTION__> "void handler::ha_set_primary_handler(handler*)") at assert.c:101
#4  0x0000000002e87cb2 in handler::ha_set_primary_handler (this=0x258ef878, primary_handler=0x335c6a48) at ../../mysql-8.0.15/sql/handler.cc:8629
#5  0x0000000002ab7637 in open_secondary_engine_tables (thd=0x25911130, tables=0x32b55c40, flags=0) at ../../mysql-8.0.15/sql/sql_base.cc:6483
#6  0x0000000002ab7775 in open_tables_for_query (thd=0x25911130, tables=0x32b55c40, flags=0) at ../../mysql-8.0.15/sql/sql_base.cc:6526
#7  0x0000000002bbf2fe in Sql_cmd_dml::prepare (this=0x32b561f8, thd=0x25911130) at ../../mysql-8.0.15/sql/sql_select.cc:384
#8  0x0000000002bbf9fe in Sql_cmd_dml::execute (this=0x32b561f8, thd=0x25911130) at ../../mysql-8.0.15/sql/sql_select.cc:533
#9  0x0000000002b61533 in mysql_execute_command (thd=0x25911130, first_level=true) at ../../mysql-8.0.15/sql/sql_parse.cc:4354
#10 0x0000000002b63a90 in mysql_parse (thd=0x25911130, parser_state=0x39176c60, force_primary_storage_engine=false) at ../../mysql-8.0.15/sql/sql_parse.cc:5105
#11 0x0000000002b59b90 in dispatch_command (thd=0x25911130, com_data=0x39177cd0, command=COM_QUERY) at ../../mysql-8.0.15/sql/sql_parse.cc:1715
#12 0x0000000002b58174 in do_command (thd=0x25911130) at ../../mysql-8.0.15/sql/sql_parse.cc:1263
#13 0x0000000002cf3546 in handle_connection (arg=0x25916a50) at ../../mysql-8.0.15/sql/conn_handler/connection_handler_per_thread.cc:305
#14 0x00000000040c4dc0 in pfs_spawn_thread (arg=0x3361f670) at ../../../mysql-8.0.15/storage/perfschema/pfs.cc:2836
#15 0x00000000076bcdf5 in start_thread (arg=0x39178700) at pthread_create.c:308
#16 0x00000000093b560d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113
(

(gdb) f 4
#4  0x0000000002e87cb2 in handler::ha_set_primary_handler (this=0x258ef878, primary_handler=0x335c6a48) at ../../mysql-8.0.15/sql/handler.cc:8629

(gdb) p ht->flags
$3 = 4
[5 Apr 2019 12:39] MySQL Verification Team
Hi,

This bug is verified now.