Bug #70013 select count from innodb partitioned table with compound key can crash db
Submitted: 13 Aug 2013 11:29 Modified: 13 Aug 2013 12:54
Reporter: Eldad Kohavi Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.5.23 OS:Linux (Red Hat Enterprise Linux Server release 5.8 (Tikanga) 64 bit)
Assigned to: CPU Architecture:Any
Tags: 5.5.23, compound, crash, innodb, partition, range

[13 Aug 2013 11:29] Eldad Kohavi
Description:
hey
a certain query sometime cause my server to crash. even an explain of the query can cause the server to crash.

the query is 
select count(*) into @c1 from profile_attribute where date_created >= '2013-11-29';

this can happen when i run this from within a stored procedure or just from the command line. 

table definition is 

 CREATE TABLE `profile_attribute` (
  `profile_attribute_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `x1` varchar(45) NOT NULL,
  `x2` int(10) unsigned NOT NULL,
  `date_created` timestamp NOT NULL DEFAULT '1980-01-01 02:00:00',
  `date_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `x3` int(10) unsigned NOT NULL,
  `x4` bigint(20) NOT NULL DEFAULT '0',
  `x5` int(10) DEFAULT NULL,
  `x6` int(10) unsigned DEFAULT NULL,
  `x7` int(10) NOT NULL DEFAULT '0',
  `x8` int(10) NOT NULL DEFAULT '0',
  `x9` tinyint(1) NOT NULL DEFAULT '0',
  `x10` int(10) NOT NULL,
  `x11` varchar(1024) DEFAULT NULL,
  PRIMARY KEY (`profile_attribute_id`,`date_created`),
  KEY `big45_profile_attribute_FK_partner_id` (`x2`),
  KEY `big45_profile_attribute_I_profile_id` (`x4`),
  KEY `big45_profile_attribute_I_date_created` (`date_created`),
  KEY `big45_profile_attribute_I_date_updated` (`date_updated`),
  KEY `big45_profile_attribute_I_attribute_numeric_value` (`x5`),
  KEY `big45_profile_attribute_I_user_agent_id` (`x10`),
  KEY `big45_attribute_type_I_profile_attribute` (`x3`)
) ENGINE=InnoDB AUTO_INCREMENT=1828525553 DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE ( UNIX_TIMESTAMP(date_created))
(PARTITION p20130602 VALUES LESS THAN (1374033600) ENGINE = InnoDB,
 PARTITION p20130717 VALUES LESS THAN (1377921600) ENGINE = InnoDB,
 PARTITION p20130831 VALUES LESS THAN (1381809600) ENGINE = InnoDB,
 PARTITION p20131015 VALUES LESS THAN (1385701200) ENGINE = InnoDB) ;

table has 930m records, first partition is about 69gb and 250m records, second is 180gb and has about 680m records. there is no data in the table matching this date.

this happened to me when the server was busy and also 2 minutes after the server went up when there was almost no activity. 

error log : 

10:55:34 UTC - mysqld got signal 8 ;
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.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

key_buffer_size=33554432
read_buffer_size=524288
max_used_connections=50
max_threads=500
thread_count=46
connection_count=46
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 1318475 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x2aaaf11d2900
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 = 41be30e0 thread_stack 0x30000
/usr/sbin/mysqld(my_print_stacktrace+0x35)[0x7d2a55]
/usr/sbin/mysqld(handle_fatal_signal+0x3e1)[0x68b441]
/lib64/libpthread.so.0[0x302620ebe0]
/usr/sbin/mysqld(_ZN12ha_partition21min_rows_for_estimateEv+0x5a)[0x961e9a]
/usr/sbin/mysqld[0x7628a9]
/usr/sbin/mysqld[0x763176]
/usr/sbin/mysqld[0x76342b]
/usr/sbin/mysqld(_ZN10SQL_SELECT17test_quick_selectEP3THD6BitmapILj64EEyyb+0xe49)[0x76a8b9]
/usr/sbin/mysqld[0x5ad11f]
/usr/sbin/mysqld(_ZN4JOIN8optimizeEv+0x55d)[0x5aef7d]
/usr/sbin/mysqld(_Z12mysql_selectP3THDPPP4ItemP10TABLE_LISTjR4ListIS1_ES2_jP8st_orderSB_S2_SB_yP13select_resultP18st_select_lex_unitP13st_select_lex+0xd2)[0x5b9172]
/usr/sbin/mysqld(_Z19mysql_explain_unionP3THDP18st_select_lex_unitP13select_result+0x192)[0x5b9922]
/usr/sbin/mysqld[0x573510]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x32da)[0x57adaa]
/usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x10b)[0x57dd9b]
/usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x14fb)[0x57f31b]
/usr/sbin/mysqld(_Z10do_commandP3THD+0xc4)[0x57f694]
/usr/sbin/mysqld(_Z24do_handle_one_connectionP3THD+0xef)[0x61902f]
/usr/sbin/mysqld(handle_one_connection+0x54)[0x619124]
/lib64/libpthread.so.0[0x302620677d]
/lib64/libc.so.6(clone+0x6d)[0x3025ad325d]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (2aaaadff7110): is an invalid pointer
Connection ID (thread ID): 78
Status: NOT_KILLED

How to repeat:
this does not happen every time, this query is part of a procedure to roll partitions which runs daily, and sometimes it can go a month without an error, today it happened two times in a row.
creating the table, fillling with a bit of data and running the query should reproduce it.
[13 Aug 2013 12:20] MySQL Verification Team
This is a duplicate of a known and fixed bug.
Bug 13949735 - ASSERTION FAILED: TOT_USED_PARTITIONS, FILE HA_PARTITION.CC, LINE 6691

You need to upgrade to a newer version of mysql.
Current versions are 5.5.33 and 5.6.13.
[13 Aug 2013 12:54] Eldad Kohavi
thank you very much.
why is the the details on these bug unavailabile? the link leads to "No such bug #13949735 or bug is referenced in the Oracle bug system."
[13 Aug 2013 12:59] MySQL Verification Team
because that bug number is internal.  another duplicate of this bug is
http://bugs.mysql.com/bug.php?id=68176