Bug #21617 crash when selecting from merge table with inconsistent indexes
Submitted: 14 Aug 2006 10:18 Modified: 4 Oct 2006 18:54
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Merge storage engine Severity:S1 (Critical)
Version:5.0.24 OS:Any (*)
Assigned to: Sergey Vojtovich CPU Architecture:Any
Tags: crash, merge

[14 Aug 2006 10:18] Shane Bester
Description:
mysql-max-5.0.24-linux-i686-glibc23:

(gdb) bt
#0  0x0841dce5 in queue_insert ()
#1  0x0841019d in myrg_rkey ()
#2  0x08247c83 in ha_myisammrg::index_read ()
#3  0x081f81c9 in join_read_always_key ()
#4  0x081ea427 in sub_select ()
#5  0x081f02ac in do_select ()
#6  0x081e62f5 in JOIN::exec ()
#7  0x081e6e35 in mysql_select ()
#8  0x081e2e16 in handle_select ()
#9  0x081b79fe in mysql_execute_command ()
#10 0x081be912 in mysql_parse ()
#11 0x081b6296 in dispatch_command ()
#12 0x081b5dbd in do_command ()
#13 0x081b54bc in handle_one_connection ()
#14 0x0045fbd4 in start_thread () from /lib/libpthread.so.0
#15 0x003b74fe in clone () from /lib/libc.so.6
(gdb) 

mysql-5.0.24-win32:

mysqld_nt!queue_insert+0xd
mysqld_nt!myrg_rkey+0xc4
mysqld_nt!ha_myisammrg::index_read+0x3d
mysqld_nt!sub_select+0x538
mysqld_nt!sub_select+0x9d
mysqld_nt!setup_end_select_func+0x264
mysqld_nt!JOIN::exec+0xe82
mysqld_nt!mysql_select+0x1c7
mysqld_nt!handle_select+0xad
mysqld_nt!mysql_execute_command+0x54e
mysqld_nt!mysql_parse+0x102
mysqld_nt!dispatch_command+0x562
mysqld_nt!do_command+0xad
mysqld_nt!handle_one_connection+0x26e
mysqld_nt!pthread_start+0x3b
mysqld_nt!_threadstart+0x6c
WARNING: Frame IP not in any known module. Following frames may be wrong.
0x11f21a8

I noticed the -debug version didn't crash. Instead, it said:
mysql> select * from merge_t where y = 'foo';
ERROR 1030 (HY000): Got error 124 from storage engine

How to repeat:
drop table if exists t1;
drop table if exists t2;
drop table if exists merge_t;

create table t1 ( x int, y varchar(10), key (x), key (y) ) engine = MyISAM;
create table t2 ( x int, y varchar(10), key (x) ) engine = MyISAM;

create table merge_t ( x int, y varchar(10), key (x), key(y) ) 
engine = MERGE UNION (t1, t2) INSERT_METHOD LAST;

insert into t1 values (1, 'foo'), (2, 'bar');
insert into t2 values (3, 'baz'), (4, 'waz');

select * from merge_t where y = 'foo';

Suggested fix:
.
[23 Aug 2006 16:06] Sergey Vojtovich
This bug is a duplicate of bug#457.
[19 Sep 2006 18:22] Sergey Vojtovich
Reopened to address a crash when there are less keys in underlying table than in merge table problem.
[19 Sep 2006 21:17] 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/12239

ChangeSet@1.2548, 2006-09-20 02:14:19+05:00, svoj@mysql.com +4 -0
  BUG#21617 - crash when selecting from merge table with inconsistent indexes
  
  Crash may happen when selecting from a merge table that has underlying
  tables with less indexes than in a merge table itself.
  
  If number of keys in merge table is not bigger than requested key number,
  return error.
  
  Note that this problem is fixed partially. Crash could still happen since
  in current implementation number of keys is actually number of keys in last
  underlying table. Further fix will be delivered with patch for bug457.
[28 Sep 2006 17:08] 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/12745

ChangeSet@1.2548, 2006-09-28 22:10:06+05:00, svoj@mysql.com +5 -0
  BUG#21617 - crash when selecting from merge table with inconsistent indexes
  
  Crash may happen when selecting from a merge table that has underlying
  tables with less indexes than in a merge table itself.
  
  If number of keys in merge table is not bigger than requested key number,
  return error.
[3 Oct 2006 8:52] Sergey Vojtovich
Fixed in 4.1.22, 5.0.26, 5.1.12.
[4 Oct 2006 18:54] Paul Dubois
Noted in 4.1.22, 5.0.26, 5.1.12 changelogs.