Bug #62366 Repeatable crash in MySQL 5.5.15
Submitted: 6 Sep 2011 18:17 Modified: 7 Sep 2011 6:50
Reporter: Antonio Covelli Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:5.5.15 OS:Linux
Assigned to: CPU Architecture:Any

[6 Sep 2011 18:17] Antonio Covelli
Description:
Recently I noticed that MySQL was crashing and upon further investigation discovered that a database was upgraded to use Magento 1.6.

Details of the error:

len 232; hex c821d40700000000b1c05895ad7f000030322a6bad7f0000000000000000 000000000000000000000000000000000000030000000000000001000000 000000000000000000000000030000000000000001000000000000000300 000000000000000000000000000000000000000000000000000000000000 ffffffffffffffff00000000000000000100000000000000834451070000 00009d33be07000000000200000000000000010000000000000030322a6b ad7f0000000000000000000060e111770000000002000000000000000000 0000000000009833be07000000001000000000000000; asc ! X 02*k DQ 3 02*k ` w 3 ;
110906 15:30:55 InnoDB: Assertion failure in thread 140382468241152 in file btr0pcur.c line 242
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recove ry.html
InnoDB: about forcing recovery.
110906 15:30:55 - mysqld got signal 6 ;
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=536870912
read_buffer_size=262144
max_used_connections=1
max_threads=200
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 = 987531 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7b27400
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 = 0x7fad5726ee48 thread_stack 0x60000
/usr/local/mysql55/bin/mysqld(my_print_stacktrace+0x35)[0x8e 31b6]
/usr/local/mysql55/bin/mysqld(handle_segfault+0x321)[0x55a8d 8]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xfc60)[0x7fae19c02c6 0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x35)[0x7fae180b0d05 ]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x186)[0x7fae180b4ab6]
/usr/local/mysql55/bin/mysqld[0xa2446c]
/usr/local/mysql55/bin/mysqld[0x9af264]
/usr/local/mysql55/bin/mysqld[0x9b0c62]
/usr/local/mysql55/bin/mysqld[0x971705]
/usr/local/mysql55/bin/mysqld[0x9718dd]
/usr/local/mysql55/bin/mysqld[0x85fdda]
/usr/local/mysql55/bin/mysqld(_ZN26QUICK_GROUP_MIN_MAX_SELEC T11next_prefixEv+0x171)[0x85ffc3]
/usr/local/mysql55/bin/mysqld(_ZN26QUICK_GROUP_MIN_MAX_SELEC T8get_nextEv+0x4d)[0x85f7f3]
/usr/local/mysql55/bin/mysqld[0x8677b9]
/usr/local/mysql55/bin/mysqld[0x64891a]
/usr/local/mysql55/bin/mysqld(_Z10sub_selectP4JOINP13st_join _tableb+0xc1)[0x646d60]
/usr/local/mysql55/bin/mysqld[0x646950]
/usr/local/mysql55/bin/mysqld(_ZN4JOIN4execEv+0x23d5)[0x62fe 91]
/usr/local/mysql55/bin/mysqld(_Z12mysql_selectP3THDPPP4ItemP 10TABLE_LISTjR4ListIS1_ES2_jP8st_orderSB_S2_SB_yP13select_re sultP18st_select_lex_unitP13st_select_lex+0x368)[0x630630]
/usr/local/mysql55/bin/mysqld(_Z13handle_selectP3THDP3LEXP13 select_resultm+0x1e5)[0x62887b]
/usr/local/mysql55/bin/mysqld[0x602ba5]
/usr/local/mysql55/bin/mysqld(_Z21mysql_execute_commandP3THD +0x98a)[0x5fb7d5]
/usr/local/mysql55/bin/mysqld(_Z11mysql_parseP3THDPcjP12Pars er_state+0x340)[0x604fac]
/usr/local/mysql55/bin/mysqld(_Z16dispatch_command19enum_ser ver_commandP3THDPcj+0xaf7)[0x5f87e1]
/usr/local/mysql55/bin/mysqld(_Z10do_commandP3THD+0x2f0)[0x5 f7ad7]
/usr/local/mysql55/bin/mysqld(_Z24do_handle_one_connectionP3 THD+0x1a1)[0x6e16c8]
/usr/local/mysql55/bin/mysqld(handle_one_connection+0x33)[0x 6e1176]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x6d8c)[0x7fae19bf9d8 c]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7fae1816304d]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7bd8ab0): SELECT COUNT(DISTINCT parent_id) FROM `catalog_product_relation` WHERE (child_id IN('17'))
Connection ID (thread ID): 1
Status: NOT_KILLED

Server was compiled from source and I can reproduce on both Ubuntu 11.04 and Centos 5.6, both 64bit. All tables have been checked and are ok.

If I enter the above query the crash happens every time. Have tried the following versions:

Percona-Server-5.5.13-rel20.4
Percona-Server-5.5.14-rel20.5
Percona-Server-5.5.15-rel21.0
Oracle MySQL 5.5.15

All the above fail.

Using MariaDB 5.2.8 the query works perfectly.

Compile line:

cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1

Also fault occurs with the following compile line:

cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55 -DWITH_INNOBASE_STORAGE_ENGINE=1

How to repeat:
Install Magento 1.6, insert some data and run a query similar to the following:

SELECT COUNT(DISTINCT parent_id) FROM `catalog_product_relation` WHERE (child_id IN('17'));

Table: catalog_product_relation

CREATE TABLE `catalog_product_relation` (
  `parent_id` int(10) unsigned NOT NULL COMMENT 'Parent ID',
  `child_id` int(10) unsigned NOT NULL COMMENT 'Child ID',
  PRIMARY KEY (`parent_id`,`child_id`),
  KEY `IDX_CATALOG_PRODUCT_RELATION_CHILD_ID` (`child_id`),
  CONSTRAINT `FK_CAT_PRD_RELATION_CHILD_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`child_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_CAT_PRD_RELATION_PARENT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`parent_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Catalog Product Relation Table'$$

Table: catalog_product_entity

CREATE TABLE `catalog_product_entity` (
  `entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity ID',
  `entity_type_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity Type ID',
  `attribute_set_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Attribute Set ID',
  `type_id` varchar(32) NOT NULL DEFAULT 'simple' COMMENT 'Type ID',
  `sku` varchar(64) DEFAULT NULL COMMENT 'SKU',
  `has_options` smallint(6) NOT NULL DEFAULT '0' COMMENT 'Has Options',
  `required_options` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Required Options',
  `created_at` timestamp NULL DEFAULT NULL COMMENT 'Creation Time',
  `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Update Time',
  PRIMARY KEY (`entity_id`),
  KEY `IDX_CATALOG_PRODUCT_ENTITY_ENTITY_TYPE_ID` (`entity_type_id`),
  KEY `IDX_CATALOG_PRODUCT_ENTITY_ATTRIBUTE_SET_ID` (`attribute_set_id`),
  KEY `IDX_CATALOG_PRODUCT_ENTITY_SKU` (`sku`),
  CONSTRAINT `FK_CAT_PRD_ENTT_ATTR_SET_ID_EAV_ATTR_SET_ATTR_SET_ID` FOREIGN KEY (`attribute_set_id`) REFERENCES `eav_attribute_set` (`attribute_set_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_CAT_PRD_ENTT_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID` FOREIGN KEY (`entity_type_id`) REFERENCES `eav_entity_type` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COMMENT='Catalog Product Table'$$

Table: eav_attribute_set

CREATE TABLE `eav_attribute_set` (
  `attribute_set_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Attribute Set Id',
  `entity_type_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity Type Id',
  `attribute_set_name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Attribute Set Name',
  `sort_order` smallint(6) NOT NULL DEFAULT '0' COMMENT 'Sort Order',
  PRIMARY KEY (`attribute_set_id`),
  UNIQUE KEY `UNQ_EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_ATTRIBUTE_SET_NAME` (`entity_type_id`,`attribute_set_name`),
  KEY `IDX_EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_SORT_ORDER` (`entity_type_id`,`sort_order`),
  CONSTRAINT `FK_EAV_ATTR_SET_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID` FOREIGN KEY (`entity_type_id`) REFERENCES `eav_entity_type` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COMMENT='Eav Attribute Set'$$

Table: eav_entity_type

CREATE TABLE `eav_entity_type` (
  `entity_type_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity Type Id',
  `entity_type_code` varchar(50) NOT NULL COMMENT 'Entity Type Code',
  `entity_model` varchar(255) NOT NULL COMMENT 'Entity Model',
  `attribute_model` varchar(255) DEFAULT NULL COMMENT 'Attribute Model',
  `entity_table` varchar(255) DEFAULT NULL COMMENT 'Entity Table',
  `value_table_prefix` varchar(255) DEFAULT NULL COMMENT 'Value Table Prefix',
  `entity_id_field` varchar(255) DEFAULT NULL COMMENT 'Entity Id Field',
  `is_data_sharing` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'Defines Is Data Sharing',
  `data_sharing_key` varchar(100) DEFAULT 'default' COMMENT 'Data Sharing Key',
  `default_attribute_set_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Default Attribute Set Id',
  `increment_model` varchar(255) DEFAULT '' COMMENT 'Increment Model',
  `increment_per_store` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Increment Per Store',
  `increment_pad_length` smallint(5) unsigned NOT NULL DEFAULT '8' COMMENT 'Increment Pad Length',
  `increment_pad_char` varchar(1) NOT NULL DEFAULT '0' COMMENT 'Increment Pad Char',
  `additional_attribute_table` varchar(255) DEFAULT '' COMMENT 'Additional Attribute Table',
  `entity_attribute_collection` varchar(255) DEFAULT '' COMMENT 'Entity Attribute Collection',
  PRIMARY KEY (`entity_type_id`),
  KEY `IDX_EAV_ENTITY_TYPE_ENTITY_TYPE_CODE` (`entity_type_code`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COMMENT='Eav Entity Type'$$
[6 Sep 2011 22:05] MySQL Verification Team
Thank you for the bug report. Are you able to provide a dump with enough data just to run the query and repeat the crash?. Thanks.
[7 Sep 2011 6:27] Antonio Covelli
Have attached a dump for the developers use only.
[7 Sep 2011 6:37] Valeriy Kravchuk
This is a duplicate of known and not yet fixed bug #61101 (that bug is private).
[7 Sep 2011 6:41] Valeriy Kravchuk
As a workaround you can try to CREATE the table affected using a UNIQUE KEY instead of a PRIMARY KEY. ALTER for existing table will NOT help.
[7 Sep 2011 6:50] Antonio Covelli
As I do not have access to the bug report (due to privacy), can you advise on when a fix is likely to appear?

I shall provide a link back to Magento so that they may attempt a workaround in their script.
[20 Sep 2011 6:27] Amr Ali
i had the same problem on magento 1.4.2 and mysql 5.5.13, had to change the "Product Price" index mode to Manual to work around this.