Bug #39710 Maria assertion in maria_disable_non_unique_index
Submitted: 28 Sep 2008 11:34 Modified: 8 Jan 2009 11:05
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Maria storage engine Severity:S1 (Critical)
Version:5.1-maria, 6.0-maria OS:Any
Assigned to: Guilhem Bichot CPU Architecture:Any

[28 Sep 2008 11:34] Philip Stoev
Description:
When executing the rpl_sys SystemQA test against Maria, it asserted as follows:

mysqld: ma_check.c:6181: maria_disable_non_unique_index: Assertion `share->state.state.records == 0 && (!rows || rows >= 100)' failed.

#6  0x0000003ba8029756 in __assert_fail () from /lib64/libc.so.6
#7  0x0000000000bb83c3 in maria_disable_non_unique_index (info=0x7ee3948, rows=0) at ma_check.c:6180
#8  0x0000000000b556f5 in ha_maria::start_bulk_insert (this=0x7e17860, rows=0) at ha_maria.cc:1713
#9  0x00000000007699b0 in handler::ha_start_bulk_insert (this=0x7e17860, rows=0) at handler.h:1479
#10 0x0000000000767a8b in select_insert::prepare (this=0x2aaab4246408, values=@0x80f0758, u=0x80f01f0) at sql_insert.cc:3012
#11 0x0000000000758788 in JOIN::prepare (this=0x2aaab42464a0, rref_pointer_array=0x80f0838, tables_init=0x80f10f0, wild_num=1, conds_init=0x0, og_num=0,
    order_init=0x0, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x80f0650, unit_arg=0x80f01f0) at sql_select.cc:781
#12 0x0000000000758b84 in mysql_select (thd=0x2aaab42d2cf8, rref_pointer_array=0x80f0838, tables=0x80f10f0, wild_num=1, fields=@0x80f0758, conds=0x0,
    og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=3491515904, result=0x2aaab4246408, unit=0x80f01f0, select_lex=0x80f0650)
    at sql_select.cc:2986
#13 0x000000000075e54e in handle_select (thd=0x2aaab42d2cf8, lex=0x80f0150, result=0x2aaab4246408, setup_tables_done_option=1073741824) at sql_select.cc:300
#14 0x00000000006c94ef in mysql_execute_command (thd=0x2aaab42d2cf8) at sql_parse.cc:3090
#15 0x000000000088bbc3 in sp_instr_stmt::exec_core (this=0x80f16b8, thd=0x2aaab42d2cf8, nextp=0x4c0db578) at sp_head.cc:2893
#16 0x000000000088c4de in sp_lex_keeper::reset_lex_and_exec_core (this=0x80f16f8, thd=0x2aaab42d2cf8, nextp=0x4c0db578, open_tables=false, instr=0x80f16b8)
    at sp_head.cc:2723
#17 0x000000000088caf3 in sp_instr_stmt::execute (this=0x80f16b8, thd=0x2aaab42d2cf8, nextp=0x4c0db578) at sp_head.cc:2836
#18 0x000000000088ec55 in sp_head::execute (this=0x80391e0, thd=0x2aaab42d2cf8) at sp_head.cc:1238
#19 0x000000000088f9eb in sp_head::execute_procedure (this=0x80391e0, thd=0x2aaab42d2cf8, args=0x2aaab42d5158) at sp_head.cc:1971
#20 0x00000000006cd114 in mysql_execute_command (thd=0x2aaab42d2cf8) at sql_parse.cc:4227
#21 0x00000000006cf1fb in mysql_parse (thd=0x2aaab42d2cf8, inBuf=0x8097600 "CALL test.viewer_sp()", length=21, found_semicolon=0x4c0dcf20)
    at sql_parse.cc:5856
#22 0x00000000006cfe4b in dispatch_command (command=COM_QUERY, thd=0x2aaab42d2cf8, packet=0x2aaab42d5769 "CALL test.viewer_sp()", packet_length=21)
    at sql_parse.cc:1120
#23 0x00000000006d1382 in do_command (thd=0x2aaab42d2cf8) at sql_parse.cc:807
#24 0x00000000006bed57 in handle_one_connection (arg=0x2aaab42d2cf8) at sql_connect.cc:1153
#25 0x0000003ba88062f7 in start_thread () from /lib64/libpthread.so.0
#26 0x0000003ba80ce85d in clone () from /lib64/libc.so.6

The assertion is here:

6175    {
6176      MARIA_SHARE *share= info->s;
6177      MARIA_KEYDEF    *key=share->keyinfo;
6178      uint          i;
6179
6180      DBUG_ASSERT(share->state.state.records == 0 &&
6181                  (!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXES));
6182      for (i=0 ; i < share->base.keys ; i++,key++)
6183      {
6184        if (!(key->flag &

(gdb) print share->state.state.records
$1 = 2317
(gdb) print rows
$2 = 0

How to repeat:
If this happens again, a repeatable test case will be provided.
[28 Sep 2008 12:23] Philip Stoev
Test case for bug 39710

Attachment: bug39710.zip (application/x-zip-compressed, text), 7.81 KiB.

[28 Sep 2008 12:28] Philip Stoev
To reproduce, please unpack the zip and place the .txt files in mysql-test and the .test files in mysql-test/t Then run:

$ engine_type=Maria perl mysql-test-run.pl \
  --stress \
  --stress-init-file=rpl_RBR_init.txt \
  --stress-test-file=rpl_sys_test.txt \
  --stress-test-duration=3600

A non-concurrent scenario does not exhibit this assertion.

Once this bug has been fixed, you may wish to run this test for a full 1 hour in order to check for other transient bugs that have been observed with this workload.
[29 Sep 2008 12:51] Philip Stoev
This problem appears to occur when Maria decides to temporarily disable an index in order to facilitate a bulk insert. A test that specifically targets bulk inserts is available from Random Query Generator. To run:

1. clone the mysql-test-extra-6.0 tree
2. cd mysql-test/gentest

$ perl runall.pl \
  --basedir=/path/to/mysql-6.0-maria
  --engine=Maria
  --grammar=conf/maria_bulk_insert.yy
  --queries=100000
  --duration=1200
[1 Oct 2008 1:17] MySQL Verification Team
Thank you for the bug report. Verified as described:

mysqld: ma_check.c:6181: maria_disable_non_unique_index: Assertion `share->state.state.records == 0 && (!rows || rows >= 100)' failed.
/home/miguel/bzr/mysql-6.0-maria-build/sql/mysqld(my_print_stacktrace+0x32)[0xd5df38]
/home/miguel/bzr/mysql-6.0-maria-build/sql/mysqld(handle_segfault+0x30e)[0x705ee0]
/lib64/libpthread.so.0[0x315bc0e540]
/lib64/libc.so.6(gsignal+0x35)[0x315b030ec5]
/lib64/libc.so.6(abort+0x110)[0x315b032970]
/lib64/libc.so.6(__assert_fail+0xef)[0x315b02a11f]
/home/miguel/bzr/mysql-6.0-maria-build/sql/mysqld(maria_disable_non_unique_index+0x5e)[0xc48da7]
[2 Oct 2008 13:14] Guilhem Bichot
Christoffer I can maybe help you if you have questions on the code.
[16 Oct 2008 11:46] Guilhem Bichot
Christoffer still on NDB stuff, I take the bug.
[16 Oct 2008 20:15] Guilhem Bichot
http://lists.mysql.com/maria/240
Pushed in 5.1-maria.
I push this patch without review because:
- it's small
- it makes the testcase repeatedly pass on my machine
- it's guaranteed to be more correct than the old code, so at least should reduce the bug's occurrence
- I want to see if it fixes the problem in pushbuild2
- potential reviewer (Monty) is not available before days.
I have emailed Monty so that he does a review when he gets the time, because I'm not sure the patch fixes all possible problems, as I don't fully understand the different MARIA_STATE_INFO copies.
[26 Oct 2008 22:20] Bugs System
Pushed into 6.0.8-alpha  (revid:guilhem@mysql.com-20081016194832-sphxuwbxoqx501mi) (version source revid:guilhem@mysql.com-20081020191322-i0e65e3k8044kkce) (pib:5)
[8 Jan 2009 11:05] MC Brown
Test case failure. No documentation needed.