Bug #66513 Debug build fails assertion in records_in_range()
Submitted: 23 Aug 2012 10:14 Modified: 31 Aug 2012 15:37
Reporter: Sergey Petrunya Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.1.65, 5.1.66 OS:Any
Assigned to: CPU Architecture:Any

[23 Aug 2012 10:14] Sergey Petrunya
Description:
Debug build of the server fails assertion in records_in_range().

How to repeat:
Executing the following commands 

create table t1 (a char(2) charset utf8,b double, primary key (a(1)),key (b)) engine=innodb;
insert into t1 values ('',1);
select 1 from t1 where b <= 1 and a <> '';

on a stock mysqld-debug binary of 5.1.65 causes the server to abort like this:

mysqld-debug: handler/ha_innodb.cc:6383: virtual ha_rows ha_innobase::records_in_range(uint, key_range*, key_range*): Assertion `min_key || max_key' failed.
Aborted

Release binary executes the query normally. So, does the failing assert mean something is going wrong?
[23 Aug 2012 10:43] Valeriy Kravchuk
Thank you for the bug report. Same with 5.1.66 on Mac OS X:

macbook-pro:5.1 openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.66-debug Source distribution

Copyright (c) 2000, 2011, 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> create table t1 (a char(2) charset utf8,b double, primary key (a(1)),key (b)) engine=innodb;
Query OK, 0 rows affected (0.12 sec)

mysql> insert into t1 values ('',1);
Query OK, 1 row affected (0.00 sec)

mysql> select 1 from t1 where b <= 1 and a <> '';
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> 120823 13:41:16 mysqld_safe mysqld restarted

mysql> exit
Bye
macbook-pro:5.1 openxs$ tail -80 var/macbook-pro.err 
...
120823 13:41:03 [Note] /Users/openxs/dbs/5.1/libexec/mysqld: ready for connections.
Version: '5.1.66-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
Assertion failed: (min_key || max_key), function unknown function, file handler/ha_innodb.cc, line 6383.
10:41:16 UTC - mysqld got signal 6 ;
...

5.5.28 is not affected as far as I can see.
[28 Aug 2012 6:31] Jørgen Løland
Sergey: Thanks for the bug report. This assert does not prevent errors. It is there to prevent slightly non-optimal execution.
[31 Aug 2012 15:37] Paul DuBois
Noted in 5.1.66, 5.5.29, 5.6.7, 5.7.0 changelogs.

In debug builds, an InnoDB assertion was overly aggressive about
prohibiting an open range.