Bug #85537 Assertion `m_index_scan_type != partition_index_last' failed.
Submitted: 20 Mar 2017 10:33 Modified: 23 Jan 11:53
Reporter: Roel Van de Paar (OCA) Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: Partitions Severity:S1 (Critical)
Version:5.5.54 OS:Any
Assigned to: CPU Architecture:Any

[20 Mar 2017 10:33] Roel Van de Paar
Description:
(gdb) bt
#0  0x00007f703176f741 in __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
#1  0x00000000007e0e08 in my_write_core (sig=6) at /git/MS55_dbg/mysys/stacktrace.c:433
#2  0x00000000006a3ea7 in handle_fatal_signal (sig=6) at /git/MS55_dbg/sql/signal_handler.cc:247
#3  <signal handler called>
#4  0x00007f702ff211d7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#5  0x00007f702ff228c8 in __GI_abort () at abort.c:90
#6  0x00007f702ff1a146 in __assert_fail_base (fmt=0x7f703006b3a8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=assertion@entry=0xb410b8 "m_index_scan_type != partition_index_last", file=file@entry=0xb40038 "/git/MS55_dbg/sql/ha_partition.cc", line=line@entry=4832,
    function=function@entry=0xb41d00 <ha_partition::index_next(unsigned char*)::__PRETTY_FUNCTION__> "virtual int ha_partition::index_next(uchar*)") at assert.c:92
#7  0x00007f702ff1a1f2 in __GI___assert_fail (assertion=0xb410b8 "m_index_scan_type != partition_index_last", file=0xb40038 "/git/MS55_dbg/sql/ha_partition.cc", line=4832,
    function=0xb41d00 <ha_partition::index_next(unsigned char*)::__PRETTY_FUNCTION__> "virtual int ha_partition::index_next(uchar*)") at assert.c:101
#8  0x0000000000a094e7 in ha_partition::index_next (this=0x7f700f843c10, buf=0x7f700f843f88 "\377") at /git/MS55_dbg/sql/ha_partition.cc:4832
#9  0x0000000000777b9e in index_next_different (group_key_parts=<optimized out>, group_prefix_len=5, group_prefix=0x7f700fb2b018 "\001", record=0x7f700f843f88 "\377",
    key_part=0x7f700f886a00, file=0x7f700f843c10, is_index_scan=<optimized out>) at /git/MS55_dbg/sql/opt_range.cc:11328
#10 QUICK_GROUP_MIN_MAX_SELECT::next_prefix (this=this@entry=0x7f700f8e9140) at /git/MS55_dbg/sql/opt_range.cc:11390
#11 0x00000000007784da in QUICK_GROUP_MIN_MAX_SELECT::get_next (this=0x7f700f8e9140) at /git/MS55_dbg/sql/opt_range.cc:11113
#12 0x000000000077bc92 in rr_quick (info=0x7f700f94c098) at /git/MS55_dbg/sql/records.cc:350
#13 0x00000000005b869f in sub_select (join=join@entry=0x7f700f94c730, join_tab=join_tab@entry=0x7f700f94c010, end_of_records=end_of_records@entry=false)
    at /git/MS55_dbg/sql/sql_select.cc:11857
#14 0x00000000005c16c8 in do_select (join=join@entry=0x7f700f94c730, fields=fields@entry=0x0, table=table@entry=0x7f700f840010, procedure=procedure@entry=0x0)
    at /git/MS55_dbg/sql/sql_select.cc:11618
#15 0x00000000005d3783 in JOIN::exec (this=0x7f700f94a010) at /git/MS55_dbg/sql/sql_select.cc:2005
#16 0x0000000000714325 in subselect_single_select_engine::exec (this=0x7f700f820b58) at /git/MS55_dbg/sql/item_subselect.cc:2054
#17 0x0000000000713c3f in Item_subselect::exec (this=0x7f700f820a68) at /git/MS55_dbg/sql/item_subselect.cc:277
#18 0x0000000000713368 in Item_singlerow_subselect::val_int (this=0x7f700f820a68) at /git/MS55_dbg/sql/item_subselect.cc:591
#19 0x00000000006aef41 in Item_copy_int::copy (this=0x7f700f94f730) at /git/MS55_dbg/sql/item.cc:3772
#20 0x00000000005c40d5 in copy_fields (param=param@entry=0x7f700f9104b8) at /git/MS55_dbg/sql/sql_select.cc:15945
#21 0x00000000005c8fac in end_send_group (join=0x7f700f90f010, join_tab=<optimized out>, end_of_records=<optimized out>) at /git/MS55_dbg/sql/sql_select.cc:12981
#22 0x00000000005b8455 in evaluate_join_record (join=join@entry=0x7f700f90f010, join_tab=join_tab@entry=0x7f700f910bc0, error=<optimized out>)
    at /git/MS55_dbg/sql/sql_select.cc:12000
#23 0x00000000005b8692 in sub_select (join=join@entry=0x7f700f90f010, join_tab=join_tab@entry=0x7f700f910bc0, end_of_records=end_of_records@entry=false)
    at /git/MS55_dbg/sql/sql_select.cc:11853
#24 0x00000000005c16c8 in do_select (join=join@entry=0x7f700f90f010, fields=fields@entry=0x7f700f910678, table=table@entry=0x0, procedure=0x0)
    at /git/MS55_dbg/sql/sql_select.cc:11618
#25 0x00000000005d541d in JOIN::exec (this=this@entry=0x7f700f90f010) at /git/MS55_dbg/sql/sql_select.cc:2400
#26 0x00000000005cf44d in mysql_select (thd=thd@entry=0x7f7022779000, rref_pointer_array=rref_pointer_array@entry=0x7f702277b260, tables=0x7f700f81f1f8, wild_num=0, fields=...,
    conds=<optimized out>, og_num=1, order=0x0, group=0x7f700f820b98, having=0x0, proc_param=0x0, select_options=select_options@entry=2147748608,
    result=result@entry=0x7f700f820c68, unit=unit@entry=0x7f702277aa58, select_lex=select_lex@entry=0x7f702277b078) at /git/MS55_dbg/sql/sql_select.cc:2619
#27 0x00000000005cf645 in handle_select (thd=thd@entry=0x7f7022779000, lex=lex@entry=0x7f702277a9a8, result=result@entry=0x7f700f820c68,
    setup_tables_done_option=setup_tables_done_option@entry=0) at /git/MS55_dbg/sql/sql_select.cc:297
#28 0x00000000005865e7 in execute_sqlcom_select (thd=thd@entry=0x7f7022779000, all_tables=<optimized out>) at /git/MS55_dbg/sql/sql_parse.cc:4672
#29 0x000000000058c486 in mysql_execute_command (thd=thd@entry=0x7f7022779000) at /git/MS55_dbg/sql/sql_parse.cc:2209
#30 0x0000000000593b5a in mysql_parse (thd=thd@entry=0x7f7022779000, rawbuf=<optimized out>, length=77, parser_state=parser_state@entry=0x7f7031d61580)
    at /git/MS55_dbg/sql/sql_parse.cc:5827
#31 0x0000000000595486 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7f7022779000, packet=packet@entry=0x7f7022774001 "",
    packet_length=packet_length@entry=77) at /git/MS55_dbg/sql/sql_parse.cc:1071
#32 0x00000000005972e6 in do_command (thd=0x7f7022779000) at /git/MS55_dbg/sql/sql_parse.cc:776
#33 0x000000000063f65e in do_handle_one_connection (thd_arg=thd_arg@entry=0x7f7022779000) at /git/MS55_dbg/sql/sql_connect.cc:870
#34 0x000000000063f71b in handle_one_connection (arg=0x7f7022779000) at /git/MS55_dbg/sql/sql_connect.cc:789
#35 0x00007f703176adc5 in start_thread (arg=0x7f7031d62700) at pthread_create.c:308
#36 0x00007f702ffe373d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

How to repeat:
DROP DATABASE test;CREATE DATABASE test;USE test;
CREATE TABLE t1(a INT,b INT,KEY(b)) ENGINE=InnoDB /*!50100 PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (2),PARTITION p1 VALUES LESS THAN (20),PARTITION p2 VALUES LESS THAN (100)) */;
create index inx on t1(a);
INSERT INTO t1 VALUES(0,REPEAT("d",0));
SELECT 1 FROM t1 GROUP BY(SELECT SLEEP(0.01)FROM t1 ORDER BY AVG(DISTINCT a));
[20 Mar 2017 11:30] Umesh Shastry
Hello Roel,

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

Thanks,
Umesh
[20 Mar 2017 11:31] Umesh Shastry
test results

Attachment: 85537.results (application/octet-stream, text), 17.80 KiB.

[20 Mar 2017 11:31] Umesh Shastry
-- 5.6.35 release/debug not affected
[23 Jan 11:53] Erlend Dahl
5.5 is covered under Oracle Lifetime Sustaining Support and will no longer be supported with updates. See

https://www.mysql.com/support/eol-notice.html

The problem is not present on 5.6+.