Bug #30562 ALTER TABLE crashes mysqld when converting MyISAM table with TEXT field to ndb
Submitted: 22 Aug 2007 12:41 Modified: 22 Aug 2007 12:52
Reporter: Hartmut Holzgraefe Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:mysql-5.0 OS:Linux
Assigned to: CPU Architecture:Any
Tags: 5.0bk

[22 Aug 2007 12:41] Hartmut Holzgraefe
Description:
When trying to convert an existing table from MyISAM to cluster
the ALTER TABLE failes on a simple test table

  create table t1(i int primary key auto_increment, t text);

if filled with 256 rows that all have the TEXT field filled
with the maximum of 65535 characters

with only 128 rows it still works fine, also with 512 rows
but only 32768 chars per TEXT field ...

How to repeat:
drop table if exists t1;
create table t1(i int primary key auto_increment, t text);

-- fill the text column with 64K the lazy way
insert into t1 values (1, "0123456789ABCDEF"); -- 16 chars
update t1 set t = concat(t,t); -- now 32 chars
update t1 set t = concat(t,t); -- now 64 chars
update t1 set t = concat(t,t); -- now 128 chars
update t1 set t = concat(t,t); -- now 256 chars
update t1 set t = concat(t,t); -- now 512 chars
update t1 set t = concat(t,t); -- now 1024 chars
update t1 set t = concat(t,t); -- now 2048 chars
update t1 set t = concat(t,t); -- now 4096 chars
update t1 set t = concat(t,t); -- now 8192 chars
update t1 set t = concat(t,t); -- now 16384 chars
update t1 set t = concat(t,t); -- now 32768 chars
update t1 set t = concat(t,t); -- now 65536 chars ... truncated to 65535

-- we should have reached the 65535 limit by now
select length(t) from t1;

-- now double the row(s) a few times
insert into t1 select 0, t from t1; -- 2 rows
insert into t1 select 0, t from t1; -- 4 rows
insert into t1 select 0, t from t1; -- 8 rows
insert into t1 select 0, t from t1; -- 16 rows
insert into t1 select 0, t from t1; -- 32 rows
insert into t1 select 0, t from t1; -- 64 rows
insert into t1 select 0, t from t1; -- 128 rows
insert into t1 select 0, t from t1; -- 256 rows

-- and this should be 256 rows
select count(*) from t1;

-- now make it a cluster table, this is going to crash mysqld
ALTER TABLE t1 ENGINE = ndb;
[22 Aug 2007 12:45] Hartmut Holzgraefe
mysqltest test case

Attachment: bug30562.tgz (application/x-gtar, text), 967 bytes.

[22 Aug 2007 12:50] Hartmut Holzgraefe
only affects 5.0, the 5.1 cluster blob implementation plays nice

error message in the mysqld error log:

  mysqld: NdbBlob.cpp:1506: int NdbBlob::preCommit(): Assertion `theState == Active' failed.
  070822 13:54:37 - mysqld got signal 6;

backtrace:

#0  0xffffe410 in __kernel_vsyscall ()
#1  0x4005b8b8 in pthread_kill () from /lib/tls/libpthread.so.0
#2  0x08397593 in write_core (sig=6) at stacktrace.c:244
#3  0x0821a946 in handle_segfault (sig=6) at mysqld.cc:2163
#4  <signal handler called>
#5  0xffffe410 in __kernel_vsyscall ()
#6  0x400fc541 in raise () from /lib/tls/libc.so.6
#7  0x400fddbb in abort () from /lib/tls/libc.so.6
#8  0x400f5925 in __assert_fail () from /lib/tls/libc.so.6
#9  0x084b2388 in NdbBlob::preCommit (this=0x8def968) at NdbBlob.cpp:1506
#10 0x08480ce4 in NdbTransaction::execute (this=0x8db6db8, aTypeOfExec=Commit, 
    abortOption=AbortOnError, forceSend=1) at NdbTransaction.cpp:328
#11 0x08341302 in execute_commit (thd=0x8d80868, trans=0x8db6db8)
    at ha_ndbcluster.cc:270
#12 0x08330fae in ndbcluster_commit (thd=0x8d80868, all=false)
    at ha_ndbcluster.cc:3953
#13 0x0830d042 in ha_commit_one_phase (thd=0x8d80868, all=false)
    at handler.cc:749
#14 0x0830d71f in ha_commit_trans (thd=0x8d80868, all=false) at handler.cc:719
#15 0x0831091d in ha_enable_transaction (thd=0x8d80868, on=true)
    at handler.cc:2171
#16 0x0834bc98 in copy_data_between_tables (from=0x8db8250, to=0x8dc3ec0, 
    create=@0x426ab260, ignore=false, order_num=0, order=0x0, 
---Type <return> to continue, or q <return> to quit---
    copied=0x426ab320, deleted=0x426ab318, keys_onoff=LEAVE_AS_IS)
    at sql_table.cc:4114
#17 0x0834f04a in mysql_alter_table (thd=0x8d80868, new_db=0x8db9998 "test", 
    new_name=0x8db97d0 "t1", create_info=0x426ab5e4, table_list=0x8db97f8, 
    alter_info=0x426abb84, order_num=0, order=0x0, ignore=false)
    at sql_table.cc:3719
#18 0x08239bf2 in mysql_execute_command (thd=0x8d80868) at sql_parse.cc:3248
#19 0x08240571 in mysql_parse (thd=0x8d80868, 
    inBuf=0x8db9778 "ALTER TABLE t1 ENGINE = ndb", length=27)
    at sql_parse.cc:5931
#20 0x0824102a in dispatch_command (command=COM_QUERY, thd=0x8d80868, 
    packet=0x8db1719 "ALTER TABLE t1 ENGINE = ndb", packet_length=28)
    at sql_parse.cc:1798
#21 0x0824254d in do_command (thd=0x8d80868) at sql_parse.cc:1577
#22 0x08242a3a in handle_one_connection (arg=0x8d80868) at sql_parse.cc:1191
#23 0x40058297 in start_thread () from /lib/tls/libpthread.so.0
#24 0x4019337e in clone () from /lib/tls/libc.so.6
#25 0x426acbb0 in ?? ()
[22 Aug 2007 13:00] Hartmut Holzgraefe
Additional note: even when starting with a NDB table right away
instead of a MyISAM one mysqld crashes on the final 

  ALTER TABLE t1 ENGINE=NDB;

which now should only be a simple copy operation from/to cluster ...