Bug #44670 ALTER TABLE crashes in StorageTableShare::haveIndexes()
Submitted: 5 May 2009 13:34 Modified: 26 May 2010 17:46
Reporter: Olav Sandstå Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: Falcon storage engine Severity:S2 (Serious)
Version:6.0.12-alpha OS:Any
Assigned to: Christopher Powers CPU Architecture:Any
Tags: F_ONLINE ALTER

[5 May 2009 13:34] Olav Sandstå
Description:
A run of the falcon_online_alter test resulted in the following crash:

# 12:15:02 Program terminated with signal 10, Bus error.
# 12:15:02 #0  0xfef411e4 in _lwp_kill () from /lib/libc.so.1
# 12:15:02 #0  0xfef411e4 in _lwp_kill () from /lib/libc.so.1
# 12:15:02 #1  0x00a2b30c in my_write_core (sig=10) at stacktrace.c:309
# 12:15:02 #2  0x002a859c in handle_segfault (sig=10) at mysqld.cc:2710
# 12:15:02 #3  <signal handler called>
# 12:15:02 #4  0x00644314 in StorageTableShare::haveIndexes (this=0x1e34838, 
# 12:15:02     indexCount=13) at StorageTableShare.cpp:574
# 12:15:02 #5  0x0061f0a4 in StorageInterface::setIndexes (this=0x782b918, 
# 12:15:02     srvTable=0x7875928) at ha_falcon.cpp:2720
# 12:15:02 #6  0x006258f0 in StorageInterface::open (this=0x782b918, 
# 12:15:02     name=0x7502398 "./test/B", mode=2, test_if_locked=2) at ha_falcon.cpp:590
# 12:15:02 #7  0x0045efa8 in handler::ha_open (this=0x782b918, table_arg=0x7875928, 
# 12:15:02     name=0x7502398 "./test/B", mode=2, test_if_locked=2) at handler.cc:2043
# 12:15:02 #8  0x0033bb20 in open_table_from_share (thd=0x7aa1908, share=0x7502128, 
# 12:15:02     alias=0x7885a58 "B", db_stat=39, prgflag=44, ha_open_flags=0, 
# 12:15:02     outparam=0x7875928, open_mode=OTM_OPEN) at table.cc:2025
# 12:15:02 #9  0x003340b4 in open_table (thd=0x7aa1908, table_list=0x7885a60, 
# 12:15:02     mem_root=0xfd4f02c8, action=0xfd4f0308, flags=32) at sql_base.cc:2777
# 12:15:02 #10 0x0033679c in open_tables (thd=0x7aa1908, start=0xfd4f0418, 
# 12:15:02     counter=0xfd4f03b8, flags=32) at sql_base.cc:3772
# 12:15:02 #11 0x00337204 in open_and_lock_tables_derived (thd=0x7aa1908, 
# 12:15:02     tables=0x7885a60, derived=false, flags=32) at sql_base.cc:4233
# 12:15:02 #12 0x003376f0 in open_n_lock_single_table (thd=0x7aa1908, table_l=0x7885a60, 
# 12:15:02     lock_type=TL_WRITE_ALLOW_READ, flags=32) at sql_base.cc:4083
# 12:15:02 #13 0x00495064 in mysql_alter_table (thd=0x7aa1908, new_db=0x7885c68 "test", 
# 12:15:02     new_name=0x0, create_info=0xfd4f1060, table_list=0x7885a60, 
# 12:15:02     alter_info=0xfd4f1560, order_num=0, order=0x0, ignore=false)
# 12:15:02     at sql_table.cc:6768
# 12:15:02 #14 0x002c9c84 in mysql_execute_command (thd=0x7aa1908) at sql_parse.cc:2892
# 12:15:02 #15 0x002d20ac in mysql_parse (thd=0x7aa1908, 
# 12:15:02     inBuf=0x7885900 "ALTER  TABLE `B` ADD PRIMARY KEY t ( `datetime_nokey` , `varchar_nokey` ) , ADD UNIQUE s ( `time_key` , `pk` )", length=110, 
# 12:15:02     found_semicolon=0xfd4f1dc8) at sql_parse.cc:5937
# 12:15:02 #16 0x002d2bd0 in dispatch_command (command=COM_QUERY, thd=0x7aa1908, 
# 12:15:02     packet=0x7b558f1 "ALTER  TABLE `B` ADD PRIMARY KEY t ( `datetime_nokey` , `varchar_nokey` ) , ADD UNIQUE s ( `time_key` , `pk` )", packet_length=110)
# 12:15:02     at sql_parse.cc:1049
# 12:15:02 #17 0x002d4368 in do_command (thd=0x7aa1908) at sql_parse.cc:731
# 12:15:02 #18 0x002bb7fc in handle_one_connection (arg=0x7aa1908) at sql_connect.cc:1146
# 12:15:02 #19 0xfef3fff8 in _lwp_start () from /lib/libc.so.1
# 12:15:02 #20 0xfef3fff8 in _lwp_start () from /lib/libc.so.1

The code where the crash occured:

	for (StorageIndexDesc *indexDesc = indexes; indexDesc; indexDesc = indexDesc->next, n++)
		{
		if (!indexDesc->index)    <<<< line causing the SIGBUS error
			return false;
		}

How to repeat:
Seen once when running the RGQ test falcon_online_alter.

Suggested fix:
Don't miss the BUS.
[5 Aug 2009 3:10] 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/80115

2764 Christopher Powers	2009-08-04
      Bug #44670, "ALTER TABLE crashes in StorageTableShare::haveIndexes()"
      
      Disabled unnecessary and unprotected check of StorageTableShare::indexes.
      modified:
        storage/falcon/StorageTableShare.cpp
[5 Aug 2009 3:10] Christopher Powers
StorageTableShare::haveIndexes() performs an unnecessary
and unprotected check of the ::indexes linked list.
[5 Aug 2009 23: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/80230

2765 Christopher Powers	2009-08-05
      Bug#44670, "ALTER TABLE crashes in StorageTableShare::haveIndexes()"
      
      Don't use StorageTableShare::haveIndexes() at all
      modified:
        storage/falcon/ha_falcon.cpp
[17 Aug 2009 18:32] Kevin Lewis
Falcon cannot crash in StorageTableShare::haveIndexes() if it is not called.  Without it, StorageInterface::remapIndexes() is just called more often.  But StorageInterface::setIndexes() is only called during create() and open(), which is not often enough to worry about performance.

Note; StorageTableShare::haveIndexes() should be deleted later as unused code.
[26 Aug 2009 2: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/81565

2770 Christopher Powers	2009-08-25
      Bug#44670 "ALTER TABLE crashes in StorageTableShare::haveIndexes()"
      
      Restore call to modified StorageTableShare::haveIndexes() to avoid deadlock.
      modified:
        storage/falcon/StorageTableShare.cpp
        storage/falcon/StorageTableShare.h
        storage/falcon/ha_falcon.cpp
[14 Sep 2009 6:41] Christopher Powers
[Assigned patch to wrong bug, Bug#46670]

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/81568

2771 Christopher Powers	2009-08-25
      Bug#46670 "ALTER TABLE crashes in StorageTableShare::haveIndexes()"
      
      Rewrote StorageTableShare::haveIndexes() to more effectively check for
      the need to remap Falcon indexes
      modified:
        storage/falcon/StorageTableShare.cpp
        storage/falcon/StorageTableShare.h
        storage/falcon/ha_falcon.cpp