Bug #34604 handler::ha_rnd_end(): Assertion `inited==RND' failed.
Submitted: 15 Feb 2008 17:07 Modified: 8 Mar 2010 14:51
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Partitions Severity:S3 (Non-critical)
Version:5.1+ OS:Any
Assigned to: Mattias Jonsson CPU Architecture:Any

[15 Feb 2008 17:07] Philip Stoev
Description:
When running the iuds6 systems test, the server asserted as follows:

mysqld: handler.h:1435: int handler::ha_rnd_end(): Assertion `inited==RND' failed.

backtrace is:

#0  0x0000003ba880b132 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000650e12 in handle_segfault (sig=6) at mysqld.cc:2313
#2  <signal handler called>
#3  0x0000003ba8030055 in raise () from /lib64/libc.so.6
#4  0x0000003ba8031af0 in abort () from /lib64/libc.so.6
#5  0x0000003ba8029756 in __assert_fail () from /lib64/libc.so.6
#6  0x0000000000740e4c in ha_partition::rnd_end (this=0x2aaab4163370) at handler.h:1435
#7  0x000000000072ff2e in end_read_record (info=0x472db8f0) at handler.h:1437
#8  0x00000000006dcb7a in mysql_update (thd=0x2aaab494c3b0, table_list=0x8660708, fields=@0x2aaab494dea0, values=@0x2aaab494e2a0, conds=0x8661648,
    order_num=3022043704, order=0x0, limit=0, handle_duplicates=DUP_ERROR, ignore=false) at sql_update.cc:764
#9  0x000000000065e134 in mysql_execute_command (thd=0x2aaab494c3b0) at sql_parse.cc:2544
#10 0x000000000066317e in mysql_parse (thd=0x2aaab494c3b0,
    inBuf=0x8660590 "update tb0_eng1  \nset f2=concat('U:',@tmp_word,'-',@tmp_num), f3=f3+1 \nwhere f1=@tmp_num-1", length=90, found_semicolon=0x472dc590)
    at sql_parse.cc:5410
#11 0x000000000065b895 in dispatch_command (command=COM_QUERY, thd=0x2aaab494c3b0, packet=0x86605ea "", packet_length=90) at sql_parse.cc:948
#12 0x000000000065b092 in do_command (thd=0x2aaab494c3b0) at sql_parse.cc:697
#13 0x0000000000659e4f in handle_one_connection (arg=0x390) at sql_connect.cc:1146
#14 0x0000003ba88062f7 in start_thread () from /lib64/libpthread.so.0
#15 0x0000003ba80ce85d in clone () from /lib64/libc.so.6

How to repeat:
Core files and hopefully an easier test case will follow.
[3 Apr 2008 12:01] Mattias Jonsson
Can be reproduced with this:

create table t2 (ai INT AUTO_INCREMENT, comment varchar(255), primary key (ai)) engine = innodb partition by hash (ai) partitions 2;

transaction 1:
start transaction;
insert into t2 values (NULL, 'first row t2');

transaction 2 (will hang):
alter table t2 auto_increment = 10;

transaction 1:
insert into t2 values (NULL, 'second row t2');

Now it is deadlocked, and after the timeout it will crash on:
Assertion failed: (inited==RND), function ha_rnd_end, file handler.h, line 1179.
(latest 5.1-engines)
[9 Apr 2008 12:49] 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/45125

ChangeSet@1.2576, 2008-04-09 14:48:42+02:00, mattiasj@witty. +1 -0
  Bug#34604: hander::ha_rnd_end(): Assertion inited==RND failed
  
  In some cases error was not properly propagated through
  ha_partition::rnd_next.
  
  Will now return the error code from the partitions rnd_next and
  update m_part_spec.start_part and m_last_part properly.
  This makes the inited state to be correct.
[9 Apr 2008 12:51] Mattias Jonsson
Philip, I did not find the test that you ran, could you please try to verify this patch if it also solves your test?
[9 Apr 2008 13:00] Philip Stoev
Mattias: the test is very long and non-deterministic. I will be running it for 6.0.5 this month, and I will update the bug if I see the issue again.
[9 May 2008 5:38] 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/46547

ChangeSet@1.2656, 2008-05-09 07:38:29+02:00, mattiasj@witty. +1 -0
  Bug#34604: hander::ha_rnd_end(): Assertion inited==RND failed
  
  In some cases error was not properly propagated through
  ha_partition::rnd_next.
  
  Will now return the error code from the partitions rnd_next and
  update m_part_spec.start_part and m_last_part properly.
  This makes the inited state to be correct.
[9 May 2008 7:16] Mattias Jonsson
Pushed into mysql-6.0-bugteam
[22 May 2008 9:51] Bugs System
Pushed into 6.0.6-alpha
[24 May 2008 17:10] Jon Stephens
Documented in the 6.0.6 changelog as follows:

        When one user was in the midst of a transaction on a partitioned table,
        a second user performing an ALTER TABLE on this table caused the server
        to hang.
[14 Aug 2008 16:34] Philip Stoev
I am reopening this bug because according to the tag it should have been fixed in 5.1 as well. Instead, the patch was only pushed in 6.0. In addition to that, the patch was commited without a test case. Here is a simple one, converted from the comment above:

--source include/have_innodb.inc

create table t2 (ai INT AUTO_INCREMENT, comment varchar(255), primary key (ai)) engine = innodb partition by hash (ai) partitions 2;

connect (con1,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (con2,127.0.0.1,root,,test,$MASTER_MYPORT,);

--connection con1
set autocommit=off;
start transaction;
insert into t2 values (NULL, 'first row t2');

--connection con2
set autocommit=off;
alter table t2 auto_increment = 10;

--connection con1
insert into t2 values (NULL, 'second row t2');
[20 Aug 2008 15:29] 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/52066

2715 Mattias Jonsson	2008-08-20
      Backport of patch for Bug#34604 (from 6.0)
      
      post push fix for bug#20129, test failed due to non existing
      source files.
[20 Aug 2008 18: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/52082

2791 Mattias Jonsson	2008-08-20 [merge]
      merge (manual mysql-5.1-bugteam
      + bug#34604 + post push fix for bug#20129 -> mysql-6.0-bugteam)
[20 Aug 2008 18:35] 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/52083

2792 Mattias Jonsson	2008-08-20
      pre push fix of test case for bug#34604
      (needed change in 6.0 from 5.1)
[20 Aug 2008 18:59] 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/52085

2792 Mattias Jonsson	2008-08-20
      pre push fix of test case for bug#34604
      (needed change in 6.0 from 5.1)
[20 Aug 2008 19:42] Mattias Jonsson
Pushed to mysql-5.1-bugteam (including a test case added to parts.partition_special_innodb)
test case updated and pushed to mysql-6.0-bugteam
(not going through a new round of review, since it was already reviewed previously when only pushing it to 6.0)
[21 Aug 2008 18:03] Bugs System
Pushed into 5.1.28  (revid:mattiasj@mysql.com-20080820152914-n73dnrhaohaduemb) (version source revid:azundris@mysql.com-20080821081500-f2d61fh4u61owz3p) (pib:3)
[22 Aug 2008 7:53] Jon Stephens
Also documented fix in 5.1.28 changelog. Closed.
[13 Sep 2008 22:33] Bugs System
Pushed into 6.0.6-alpha  (revid:mattiasj@mysql.com-20080820152914-n73dnrhaohaduemb) (version source revid:hakan@mysql.com-20080716105246-eg0utbybp122n2w9) (pib:3)
[11 Feb 2010 11:59] 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/99924

3091 Jon Olav Hauglid	2010-02-11
      Followup to Bug#34604 handler::ha_rnd_end(): Assertion `inited==RND' failed.
      
      The test case for this bug relies on getting a ER_LOCK_WAIT_TIMEOUT
      error. However with the introduction of MDL, the test would hang
      forever since the metadata locks would not timeout.
      
      MDL timeouts are now introduced in the scope of Bug#45225. This
      patch changes the testcase for Bug#34604 to set the new server
      variable "lock_wait_timeout" to one second which makes the test
      generate the necessary timeout again.
[11 Feb 2010 12:15] Jon Olav Hauglid
Followup patch pushed to mysql-next-4284.
[16 Feb 2010 16:48] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100216101445-2ofzkh48aq2e0e8o) (version source revid:jon.hauglid@sun.com-20100211140522-unpky24gmq8fkhhj) (merge vers: 6.0.14-alpha) (pib:16)
[16 Feb 2010 16:58] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100216101208-33qkfwdr0tep3pf2) (version source revid:jon.hauglid@sun.com-20100211115912-iqjq2h132it9iyvw) (pib:16)
[16 Feb 2010 19:26] Jon Stephens
Already documented bugfix in the 6.0.6 changelog. Re-closing.
[6 Mar 2010 11:03] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@mysql.com-20100216221947-luyhph0txl2c5tc8) (merge vers: 5.5.99-m3) (pib:16)
[8 Mar 2010 14:35] Jon Stephens
Also documented in the 5.5.3 changelog -- closed.