Bug #80782 Assertion `refkey_rows_estimate >= 1.0' failed in sql/sql_select.cc:4092
Submitted: 17 Mar 2016 16:23 Modified: 11 Dec 2019 22:36
Reporter: Ramesh Sivaraman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S6 (Debug Builds)
Version:5.7.11 OS:CentOS (CentOS7)
Assigned to: CPU Architecture:Any
Tags: debug

[17 Mar 2016 16:23] Ramesh Sivaraman
Description:
Error Info

Version: '5.7.11-debug'  socket: '/dev/shm/1458228381/socket.sock'  port: 38384  MySQL Community Server (GPL)
mysqld: /sda/ps57/mysql-server_dbg/sql/sql_select.cc:4092: bool test_if_cheaper_ordering(const JOIN_TAB*, ORDER*, TABLE*, key_map, int, ha_rows, int*, int*, 
ha_rows*, uint*, uint*): Assertion `refkey_rows_estimate >= 1.0' failed.
15:59:32 UTC - mysqld got signal 6 ;

GDB info

#0  0x00007f2aed130771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x000000000180fa8c in my_write_core (sig=6) at /sda/ps57/mysql-server_dbg/mysys/stacktrace.c:247
#2  0x0000000000e6af64 in handle_fatal_signal (sig=6) at /sda/ps57/mysql-server_dbg/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x00007f2aeb2bc5c9 in raise () from /lib64/libc.so.6
#5  0x00007f2aeb2bdcd8 in abort () from /lib64/libc.so.6
#6  0x00007f2aeb2b5536 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f2aeb2b55e2 in __assert_fail () from /lib64/libc.so.6
#8  0x0000000001540c02 in test_if_cheaper_ordering (tab=0x7f2a94893b88, order=0x7f2a948912e0, table=0x7f2a9485ba20, usable_keys=..., ref_key=2, select_limit=18446744073709551615, new_key=0x7f2aed6e3da0, new_key_direction=0x7f2aed6e3d6c, new_select_limit=0x7f2aed6e3c38, new_used_key_parts=0x7f2aed6e3d74, saved_best_key_parts=0x7f2aed6e3d70) at /sda/ps57/mysql-server_dbg/sql/sql_select.cc:4092
#9  0x00000000014c5e2b in test_if_skip_sort_order (tab=0x7f2a94893b88, order=0x7f2a948912e0, select_limit=18446744073709551615, no_changes=false, map=0x7f2a9485bab8, clause_type=0x1f12b2a "ORDER BY") at /sda/ps57/mysql-server_dbg/sql/sql_optimizer.cc:2088
#10 0x00000000014c492f in JOIN::test_skip_sort (this=0x7f2a948935e8) at /sda/ps57/mysql-server_dbg/sql/sql_optimizer.cc:1368
#11 0x00000000014c23bd in JOIN::optimize (this=0x7f2a948935e8) at /sda/ps57/mysql-server_dbg/sql/sql_optimizer.cc:658
#12 0x00000000015380d2 in st_select_lex::optimize (this=0x7f2a9482b0f0, thd=0x7f2a94819000) at /sda/ps57/mysql-server_dbg/sql/sql_select.cc:1009
#13 0x000000000153682e in handle_query (thd=0x7f2a94819000, lex=0x7f2a9481b2f0, result=0x7f2a94892ed0, added_options=0, removed_options=0) at /sda/ps57/mysql-server_dbg/sql/sql_select.cc:164
#14 0x00000000014ed194 in execute_sqlcom_select (thd=0x7f2a94819000, all_tables=0x7f2a94891428) at /sda/ps57/mysql-server_dbg/sql/sql_parse.cc:5108
#15 0x00000000014e6aaa in mysql_execute_command (thd=0x7f2a94819000, first_level=true) at /sda/ps57/mysql-server_dbg/sql/sql_parse.cc:2757
#16 0x00000000014ee081 in mysql_parse (thd=0x7f2a94819000, parser_state=0x7f2aed6e5560) at /sda/ps57/mysql-server_dbg/sql/sql_parse.cc:5518
#17 0x00000000014e393b in dispatch_command (thd=0x7f2a94819000, com_data=0x7f2aed6e5cb0, command=COM_QUERY) at /sda/ps57/mysql-server_dbg/sql/sql_parse.cc:1428
#18 0x00000000014e2805 in do_command (thd=0x7f2a94819000) at /sda/ps57/mysql-server_dbg/sql/sql_parse.cc:996
#19 0x000000000160ecc7 in handle_connection (arg=0x7f2ab7bff8c0) at /sda/ps57/mysql-server_dbg/sql/conn_handler/connection_handler_per_thread.cc:301
#20 0x0000000001845888 in pfs_spawn_thread (arg=0x7f2ab8bf4120) at /sda/ps57/mysql-server_dbg/storage/perfschema/pfs.cc:2192
#21 0x00007f2aed12bdf3 in start_thread () from /lib64/libpthread.so.0
#22 0x00007f2aeb37d1ad in clone () from /lib64/libc.so.6

How to repeat:
Testcase

DROP DATABASE test;CREATE DATABASE test;USE test;
SET @@session.default_storage_engine=MERGE;
CREATE TABLE t1(a int,b int,c int,key(b),key(c),key(a,b),key(c,a));
select * FROM t1 where a=0 and((b>0 and b<3)or (b>5 and b<10) or (b>22 and b<50)) order by c;
[17 Mar 2016 16:29] MySQL Verification Team
C:\dbs>c:\dbs\5.7\bin\mysql -uroot -p --port=3570 --prompt="mysql 5.7 > "
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.13-debug Source distribution PULL: 2016-MAR-05

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.7 > DROP DATABASE test;CREATE DATABASE test;USE test;
Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Database changed
mysql 5.7 > SET @@session.default_storage_engine=MERGE;
Query OK, 0 rows affected (0.00 sec)

mysql 5.7 > CREATE TABLE t1(a int,b int,c int,key(b),key(c),key(a,b),key(c,a));
Query OK, 0 rows affected (0.02 sec)

mysql 5.7 > select * FROM t1 where a=0 and((b>0 and b<3)or (b>5 and b<10) or (b>22 and b<50)) order by c;
ERROR 2013 (HY000): Lost connection to MySQL server during query
[17 Mar 2016 16:31] MySQL Verification Team
for connections.
Version: '5.7.13-debug'  socket: ''  port: 3570  Source distribution PULL: 2016-MAR-05
Assertion failed: refkey_rows_estimate >= 1.0, file C:\build\2016MAR05\mysql-5.7\sql\sql_select.cc, line 4092
16:28:17 UTC - mysqld got exception 0x80000003 ;
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=1
connection_count=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68071 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x149ba67f050
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...
7ff605bc56e5    mysqld.exe!my_sigabrt_handler()[my_thr_init.c:449]
7ff6063bf63f    mysqld.exe!raise()[winsig.c:594]
7ff6063bc550    mysqld.exe!abort()[abort.c:82]
7ff6063a5c0b    mysqld.exe!_wassert()[assert.c:380]
7ff60522edce    mysqld.exe!test_if_cheaper_ordering()[sql_select.cc:4092]
7ff6051a697c    mysqld.exe!test_if_skip_sort_order()[sql_optimizer.cc:2090]
7ff60519a4aa    mysqld.exe!JOIN::test_skip_sort()[sql_optimizer.cc:1370]
7ff60518d1db    mysqld.exe!JOIN::optimize()[sql_optimizer.cc:661]
7ff605228798    mysqld.exe!st_select_lex::optimize()[sql_select.cc:1009]
7ff60522ad9b    mysqld.exe!handle_query()[sql_select.cc:164]
7ff604f165be    mysqld.exe!execute_sqlcom_select()[sql_parse.cc:5109]
7ff604f06888    mysqld.exe!mysql_execute_command()[sql_parse.cc:2758]
7ff604f04f1f    mysqld.exe!mysql_parse()[sql_parse.cc:5519]
7ff604f0f654    mysqld.exe!dispatch_command()[sql_parse.cc:1432]
7ff604f0e533    mysqld.exe!do_command()[sql_parse.cc:997]
7ff604ec1ad2    mysqld.exe!handle_connection()[connection_handler_per_thread.cc:301]
7ff6062327f2    mysqld.exe!pfs_spawn_thread()[pfs.cc:2190]
7ff605bc3f86    mysqld.exe!win_thread_start()[my_thread.c:37]
7ff6063bee55    mysqld.exe!_callthreadstartex()[threadex.c:376]
7ff6063bf0a7    mysqld.exe!_threadstartex()[threadex.c:359]
7fffcb858102    KERNEL32.DLL!BaseThreadInitThunk()
7fffcb94c2e4    ntdll.dll!RtlUserThreadStart()

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (149ba69d5b0): select * FROM t1 where a=0 and((b>0 and b<3)or (b>5 and b<10) or (b>22 and b<50)) order by c
Connection ID (thread ID): 2
[17 Mar 2016 16:35] MySQL Verification Team
Thank you for the bug report.
[11 Dec 2019 22:36] Roy Lyseng
Posted by developer:
 
Fixed in 8.0.18