Bug #54686 Assertion error in row/row0sel.c
Submitted: 22 Jun 2010 7:11 Modified: 15 Oct 2010 13:26
Reporter: Yasufumi Kinoshita Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB Plugin storage engine Severity:S3 (Non-critical)
Version:5.1, 1.0.6 OS:Any
Assigned to: Marko Mäkelä CPU Architecture:Any
Tags: Contribution crash old_alter_table

[22 Jun 2010 7:11] Yasufumi Kinoshita
Description:
"field->col->mtype == type" assertion error at row/row0sel.c

row_sel_convert_mysql_key_to_innobase() is called even when
prebuilt->index_usable == FALSE from 
ha_innobase::index_read()

I have check the newest source code, but it seems not to be fixed still.

How to repeat:
Sorry, it may be rare case and I don't have exact reproduce procedure...

Suggested fix:
at handler/ha_innodb.cc,
function ha_innobase::index_read():

Just before calling row_sel_convert_mysql_key_to_innobase(),
adding as following.
(it is same error code at row_search_for_mysql())

=================================
                /* Convert the search key value to InnoDB format into
                prebuilt->search_tuple */

+               if (UNIV_UNLIKELY(!prebuilt->index_usable)) {
+                       return(DB_MISSING_HISTORY);
+               }
+
                row_sel_convert_mysql_key_to_innobase(
                        prebuilt->search_tuple,
                        (byte*) key_val_buff,
===================================
[22 Jun 2010 7:19] Yasufumi Kinoshita
Stacktrace as bellow. But it is of XtraDB...

#0  0x00002b41980af6b2 in pthread_kill () from /lib64/libpthread.so.0
#1  0x00000000005b7051 in handle_segfault (sig=6) at mysqld.cc:2588
#2  <signal handler called>
#3  0x00002b4198bc7215 in raise () from /lib64/libc.so.6
#4  0x00002b4198bc8cc0 in abort () from /lib64/libc.so.6
#5  0x0000000000791ce4 in row_sel_convert_mysql_key_to_innobase (tuple=0x2ab101becf10,
    buf=0x2ab11526f1c8 "p", buf_len=83, index=0x2ab114f0b8e0, key_ptr=0x2ab138209900 "'\006", key_len=8,
    trx=0x3bb60010) at row/row0sel.c:2331
#6  0x000000000073df5b in ha_innobase::index_read (this=0x2ab10196c420, buf=0x2ab100485110 "",
    key_ptr=0x2ab138209900 "'\006", key_len=8, find_flag=HA_READ_KEY_EXACT) at handler/ha_innodb.cc:5414
#7  0x000000000061f14f in join_read_key (tab=0x2ab1382093a8) at sql_select.cc:11853
#8  0x0000000000625be1 in sub_select (join=0x2ab117fe7d90, join_tab=0xe71, end_of_records=6)
    at sql_select.cc:11311
#9  0x0000000000625ad4 in evaluate_join_record (join=0x2ab117fe7d90, join_tab=0x2ab138209150,
    error=<value optimized out>) at sql_select.cc:11438
#10 0x0000000000625bee in sub_select (join=0x2ab117fe7d90, join_tab=0x2ab138209150,
    end_of_records=<value optimized out>) at sql_select.cc:11312
#11 0x0000000000625ad4 in evaluate_join_record (join=0x2ab117fe7d90, join_tab=0x2ab138208ef8,
    error=<value optimized out>) at sql_select.cc:11438
#12 0x0000000000625bee in sub_select (join=0x2ab117fe7d90, join_tab=0x2ab138208ef8,
    end_of_records=<value optimized out>) at sql_select.cc:11312
#13 0x000000000062fbde in do_select (join=0x2ab117fe7d90, fields=0x2ab1084e4fa8, table=0x0, procedure=0x0)
    at sql_select.cc:11068
#14 0x0000000000633bb3 in JOIN::exec (this=0x2ab117fe7d90) at sql_select.cc:2290
#15 0x000000000063572e in mysql_select (thd=0x2ab1084e2e80, rref_pointer_array=0x2ab1084e5070,
    tables=0x3e8dd6d0, wild_num=0, fields=<value optimized out>, conds=0x2ab1382461a0, og_num=1,
    order=0x2ab11760e7c0, group=0x0, having=0x0, proc_param=0x0, select_options=2156709888,
    result=0x2ab11760e8b8, unit=0x2ab1084e4a78, select_lex=0x2ab1084e4ea0) at sql_select.cc:2485
#16 0x0000000000636017 in handle_select (thd=0x2ab1084e2e80, lex=0x2ab1084e49d8, result=0x2ab11760e8b8,
    setup_tables_done_option=0) at sql_select.cc:269
#17 0x00000000005c27e0 in execute_sqlcom_select (thd=0x2ab1084e2e80, all_tables=0x3e8dd6d0)
    at sql_parse.cc:5123
#18 0x00000000005c5992 in mysql_execute_command (thd=0x2ab1084e2e80) at sql_parse.cc:2316
...
[22 Jun 2010 8:23] Sveta Smirnova
Thank you for the report.

Please try to find a way to repeat the problem. Or at least query which crashes and output of SHOW CREATE TABLE affected_table
[22 Jun 2010 11:46] Marko Mäkelä
Thank you, Yasufumi!

I did not repeat this myself, but I believe that similar checks have to be added to every code path that invokes row_sel_convert_mysql_key_to_innobase(). That would include ha_innobase::records_in_range().

The workaround is to commit all transactions before issuing a CREATE INDEX statement, or SET old_alter_table=1 in order to disable the fast CREATE INDEX.
[22 Jun 2010 11:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/111761
[22 Jun 2010 11:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/111762
[22 Jun 2010 11:58] Jimmy Yang
Ok to push.
[22 Jun 2010 12:00] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/111763
[22 Jun 2010 12:00] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/111764
[22 Jun 2010 12:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/111768
[22 Jun 2010 12:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/111769
[19 Jul 2010 14:37] Bugs System
Pushed into 5.1.49 (revid:build@mysql.com-20100719143034-omcma40sblwmay3x) (version source revid:vasil.dimov@oracle.com-20100704071244-3lo4okzels3kvy1p) (merge vers: 5.1.49) (pib:16)
[20 Jul 2010 19:25] John Russell
Since the error condition involves code internals rather than a SQL scenario for encountering the bug, not adding a change log entry for this patch.
[23 Jul 2010 12:23] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100723121820-jryu2fuw3pc53q9w) (version source revid:alik@sun.com-20100723121820-jryu2fuw3pc53q9w) (merge vers: 5.5.6-m3) (pib:18)
[23 Jul 2010 12:30] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100723121929-90e9zemk3jkr2ocy) (version source revid:alik@sun.com-20100723121827-3bsh51m5sj6g4oma) (pib:18)
[4 Aug 2010 7:53] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:vasil.dimov@oracle.com-20100622163043-dc0lxy0byg74viet) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:04] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:vasil.dimov@oracle.com-20100622163043-dc0lxy0byg74viet) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:20] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:vasil.dimov@oracle.com-20100622163043-dc0lxy0byg74viet) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 9:01] Bugs System
Pushed into mysql-next-mr (revid:alik@ibmvm-20100804081630-ntapn8bf9pko9vj3) (version source revid:vasil.dimov@oracle.com-20100622163043-dc0lxy0byg74viet) (pib:20)
[14 Oct 2010 8:28] Bugs System
Pushed into mysql-5.1-telco-7.0 5.1.51-ndb-7.0.20 (revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (version source revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (merge vers: 5.1.51-ndb-7.0.20) (pib:21)
[14 Oct 2010 8:43] Bugs System
Pushed into mysql-5.1-telco-6.3 5.1.51-ndb-6.3.39 (revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (version source revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (merge vers: 5.1.51-ndb-6.3.39) (pib:21)
[14 Oct 2010 8:58] Bugs System
Pushed into mysql-5.1-telco-6.2 5.1.51-ndb-6.2.19 (revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (version source revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (merge vers: 5.1.51-ndb-6.2.19) (pib:21)
[15 Oct 2010 13:26] Jon Stephens
reverting to Closed -- see above.