We're updating the issue view to help you get more done. 

Server crashes in part_of_refkey or assertion `!created && key_to_save < (int)s->keys' failed in TABLE::use_index(int) or with join_cache_level>2

Description

Test case

1 2 3 4 5 6 7 8 9 10 11 --source include/have_innodb.inc SET join_cache_level=3; CREATE TABLE t1 (f1 VARCHAR(1024)) ENGINE=InnoDB; CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; CREATE TABLE t2 (f2 VARCHAR(4)) ENGINE=InnoDB; INSERT INTO t2 VALUES ('foo'),('bar'); SELECT * FROM v1, t2 WHERE ( f1, f2 ) IN ( SELECT f1, f1 FROM t1 );

Stack trace from 5.5 debug commit ceba41c0951d1d8c9b4961772b4a088769814a66

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 mysqld: /src/5.5/sql/table.cc:6154: void TABLE::use_index(int): Assertion `!created && key_to_save < (int)s->keys' failed. 160225 16:30:57 [ERROR] mysqld got signal 6 ; #7 0x00007f35d75f11d2 in __assert_fail () from /lib64/libc.so.6 #8 0x00000000006f1a9d in TABLE::use_index (this=0x7f35c9653478, key_to_save=64) at /src/5.5/sql/table.cc:6154 #9 0x0000000000669ca6 in JOIN::drop_unused_derived_keys (this=0x7f35c97b9a00) at /src/5.5/sql/sql_select.cc:9407 #10 0x0000000000652c7b in JOIN::optimize (this=0x7f35c97b9a00) at /src/5.5/sql/sql_select.cc:1237 #11 0x00000000006595a0 in mysql_select (thd=0x7f35ce1cc0e0, rref_pointer_array=0x7f35ce1cfd60, tables=0x7f35c96832c8, wild_num=1, fields=..., conds=0x7f35c9684ea8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f35c9687580, unit=0x7f35ce1cf410, select_lex=0x7f35ce1cfaf0) at /src/5.5/sql/sql_select.cc:3080 #12 0x000000000064fed1 in handle_select (thd=0x7f35ce1cc0e0, lex=0x7f35ce1cf360, result=0x7f35c9687580, setup_tables_done_option=0) at /src/5.5/sql/sql_select.cc:319 #13 0x0000000000629364 in execute_sqlcom_select (thd=0x7f35ce1cc0e0, all_tables=0x7f35c96832c8) at /src/5.5/sql/sql_parse.cc:4689 #14 0x0000000000622697 in mysql_execute_command (thd=0x7f35ce1cc0e0) at /src/5.5/sql/sql_parse.cc:2234 #15 0x000000000062be44 in mysql_parse (thd=0x7f35ce1cc0e0, rawbuf=0x7f35c9683078 "SELECT * FROM v1, t2 WHERE ( f1, f2 ) IN ( SELECT f1, f1 FROM t1 )", length=66, parser_state=0x7f35d903f650) at /src/5.5/sql/sql_parse.cc:5914 #16 0x000000000061fc36 in dispatch_command (command=COM_QUERY, thd=0x7f35ce1cc0e0, packet=0x7f35d19a1521 "SELECT * FROM v1, t2 WHERE ( f1, f2 ) IN ( SELECT f1, f1 FROM t1 )", packet_length=66) at /src/5.5/sql/sql_parse.cc:1079 #17 0x000000000061edc9 in do_command (thd=0x7f35ce1cc0e0) at /src/5.5/sql/sql_parse.cc:793 #18 0x000000000072185f in do_handle_one_connection (thd_arg=0x7f35ce1cc0e0) at /src/5.5/sql/sql_connect.cc:1269 #19 0x00000000007215ec in handle_one_connection (arg=0x7f35ce1cc0e0) at /src/5.5/sql/sql_connect.cc:1185 #20 0x0000000000c8b271 in pfs_spawn_thread (arg=0x7f35ce36bcc0) at /src/5.5/storage/perfschema/pfs.cc:1015 #21 0x00007f35d8cb90a4 in start_thread () from /lib64/libpthread.so.0 #22 0x00007f35d76a804d in clone () from /lib64/libc.so.6

Stack trace from 5.5.48 release build

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #2 <signal handler called> #3 0x00000000005da8cc in part_of_refkey (field=0x7f983d432418, table=<optimized out>) at /home/buildbot/buildbot/build/sql/sql_select.cc:18923 #4 test_if_ref (root_cond=root_cond@entry=0x7f983d59b9a8, left_item=left_item@entry=0x7f983d41ae78, right_item=right_item@entry=0x7f983d41bbc0) at /home/buildbot/buildbot/build/sql/sql_select.cc:18554 #5 0x00000000005db02f in make_cond_for_table_from_pred (thd=thd@entry=0x7f984086e000, root_cond=root_cond@entry=0x7f983d59b9a8, cond=0x7f983d651da0, tables=tables@entry=13835058055282163719, used_table=used_table@entry=13835058055282163713, join_tab_idx_arg=join_tab_idx_arg@entry=2, exclude_expensive_cond=exclude_expensive_cond@entry=false, retain_ref_cond=retain_ref_cond@entry=false) at /home/buildbot/buildbot/build/sql/sql_select.cc:18746 #6 0x00000000005daf6f in make_cond_for_table_from_pred (thd=thd@entry=0x7f984086e000, root_cond=root_cond@entry=0x7f983d59b9a8, cond=cond@entry=0x7f983d59b9a8, tables=tables@entry=13835058055282163719, used_table=used_table@entry=13835058055282163713, join_tab_idx_arg=join_tab_idx_arg@entry=2, exclude_expensive_cond=exclude_expensive_cond@entry=false, retain_ref_cond=retain_ref_cond@entry=false) at /home/buildbot/buildbot/build/sql/sql_select.cc:18673 #7 0x0000000000507a50 in make_cond_for_table (retain_ref_cond=false, join_tab_idx_arg=2, used_table=13835058055282163713, tables=13835058055282163719, cond=0x7f983d59b9a8, thd=0x7f984086e000, exclude_expensive_cond=<optimized out>) at /home/buildbot/buildbot/build/sql/sql_select.cc:18641 #8 make_join_select (join=join@entry=0x7f983d5989a0, select=0x7f983d651c30, cond=0x7f983d59b9a8) at /home/buildbot/buildbot/build/sql/sql_select.cc:8818 #9 0x00000000005e7f6e in JOIN::optimize (this=this@entry=0x7f983d5989a0) at /home/buildbot/buildbot/build/sql/sql_select.cc:1425 #10 0x00000000005e9a34 in mysql_select (thd=thd@entry=0x7f984086e000, rref_pointer_array=rref_pointer_array@entry=0x7f9840871ae0, tables=0x7f983d41a268, wild_num=<optimized out>, fields=..., conds=<optimized out>, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=result@entry=0x7f983d595d20, unit=0x7f9840871190, select_lex=select_lex@entry=0x7f9840871870) at /home/buildbot/buildbot/build/sql/sql_select.cc:3080 #11 0x00000000005f06c3 in handle_select (thd=thd@entry=0x7f984086e000, lex=lex@entry=0x7f98408710e0, result=result@entry=0x7f983d595d20, setup_tables_done_option=setup_tables_done_option@entry=0) at /home/buildbot/buildbot/build/sql/sql_select.cc:319 #12 0x000000000059abc8 in execute_sqlcom_select (thd=thd@entry=0x7f984086e000, all_tables=0x7f983d41a268) at /home/buildbot/buildbot/build/sql/sql_parse.cc:4689 #13 0x00000000005a2a13 in mysql_execute_command (thd=thd@entry=0x7f984086e000) at /home/buildbot/buildbot/build/sql/sql_parse.cc:2234 #14 0x00000000005a6354 in mysql_parse (thd=thd@entry=0x7f984086e000, parser_state=parser_state@entry=0x7f984aeed6e0, length=<optimized out>, rawbuf=<optimized out>) at /home/buildbot/buildbot/build/sql/sql_parse.cc:5914 #15 0x00000000005a8813 in dispatch_command (command=COM_QUERY, thd=0x7f984086e000, packet=<optimized out>, packet_length=66) at /home/buildbot/buildbot/build/sql/sql_parse.cc:1245 #16 0x00000000005a898e in do_command (thd=<optimized out>) at /home/buildbot/buildbot/build/sql/sql_parse.cc:793 #17 0x000000000065af0b in do_handle_one_connection (thd_arg=thd_arg@entry=0x7f984086e000) at /home/buildbot/buildbot/build/sql/sql_connect.cc:1269 #18 0x000000000065af8c in handle_one_connection (arg=arg@entry=0x7f984086e000) at /home/buildbot/buildbot/build/sql/sql_connect.cc:1185 #19 0x0000000000978ee8 in pfs_spawn_thread (arg=0x7f9847f80730) at /home/buildbot/buildbot/build/storage/perfschema/pfs.cc:1015 #20 0x00007f984a51f0a4 in start_thread () from /lib64/libpthread.so.0 #21 0x00007f9849bd204d in clone () from /lib64/libc.so.6

Environment

None

Status

Assignee

Sergei Petrunia

Reporter

Elena Stepanova

Labels

None

External issue ID

None

External issue ID

None

Components

Fix versions

Affects versions

10.0
10.1
5.5

Priority

Major