Bug #33186 Crash in CREATE TABLE LIKE during unlocking of table
Submitted: 12 Dec 2007 22:09 Modified: 13 Dec 2007 5:42
Reporter: Harrison Fisk Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: DDL Severity:S2 (Serious)
Version:5.0.50 OS:Linux (x86_64 (RHEL 5))
Assigned to: CPU Architecture:Any

[12 Dec 2007 22:09] Harrison Fisk
Description:
There appears to be a race condition regarding CREATE TABLE LIKE which can cause a crash in certain circumstances.

This has occurred twice with different queries running in the different threads, but this backtrace has looked exactly the same between the crashes.

The backtraces look like:

Thread 1 (process 3423):
#0  0x0000003fd120b002 in pthread_kill () from /lib64/libpthread.so.0
#1  0x00000000005743f3 in handle_segfault (sig=11) at mysqld.cc:2194
#2  <signal handler called>
#3  0x00000000007ee529 in my_hash_sort_bin (cs=<value optimized out>, key=0x15c4ff7ec083daf8 <Address 0x15c4ff7ec083daf8 out of bounds>, len=2703423488, nr1=0x457a2e40, 
    nr2=0x457a2e38) at ctype-bin.c:306
#4  0x00000000007cc1be in calc_hash (hash=<value optimized out>, key=0x15c1cc10 "\004", length=2703423488) at hash.c:44
#5  0x00000000007cc859 in hash_delete (hash=0xcc19c0, record=0x15c02860 "`<E8><BF>\025") at hash.c:184
#6  0x000000000056e84a in unlock_table_name (thd=<value optimized out>, table_list=<value optimized out>) at lock.cc:921
#7  0x0000000000638616 in mysql_create_like_table (thd=0x2aac605b0950, table=<value optimized out>, src_table=0x15c00c70, create_info=0x457a36a0) at sql_table.cc:2893
#8  0x000000000058c56c in mysql_execute_command (thd=0x2aac605b0950) at sql_parse.cc:3094
#9  0x000000000058dbeb in mysql_parse (thd=0x2aac605b0950, inBuf=0x15c00850 "create table gorillaworkspace.target_temp_3 like gorillaworkspace.target", length=72, 
    found_semicolon=0x457a4a18) at sql_parse.cc:6094
#10 0x000000000058e0b0 in dispatch_command (command=COM_QUERY, thd=0x2aac605b0950, 
    packet=0x2aac605b2a51 "\r\ncreate table gorillaworkspace.target_temp_3 like gorillaworkspace.target", packet_length=<value optimized out>) at sql_parse.cc:1812
#11 0x000000000058f2f3 in do_command (thd=0x2aac605b0950) at sql_parse.cc:1586
#12 0x000000000058fd0d in handle_one_connection (arg=<value optimized out>) at sql_parse.cc:1197
#13 0x0000003fd12061b5 in start_thread () from /lib64/libpthread.so.0
#14 0x0000003fd06cd39d in clone () from /lib64/libc.so.6
#15 0x0000000000000000 in ?? ()

How to repeat:
Run a CREATE TABLE LIKE with some other statements.  Not sure what those are yet.

Suggested fix:
Make it not crash.
[12 Dec 2007 22:14] Harrison Fisk
Might potentially be related to the fix that was done for:

http://bugs.mysql.com/bug.php?id=23667
[12 Dec 2007 23:26] Davi Arnaut
Could also be a duplicate of Bug#31479, can you check if the thread was killed?
[13 Dec 2007 5:42] Dmitry Lenev
Inspection of both cores provided shows that CREATE TABLE ... LIKE statement in which crash occurred was killed during its execution. This fact and the exact place in code where crash has occurred allows to say that this bug is duplicate of already fixed bug #31479 "Bad lock interaction if CREATE TABLE LIKE is killed" (particularly see the problem #2 in it).