Bug #10814 CREATE TABLE a SELECT * from b crashes mysql when b is replaced
Submitted: 24 May 2005 6:14 Modified: 25 May 2005 1:32
Reporter: R.P.G. Brouwer Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S2 (Serious)
Version:4.0.16 and 4.0.24 OS:Linux (Linux and probably others)
Assigned to: CPU Architecture:Any

[24 May 2005 6:14] R.P.G. Brouwer
Description:
I have a template table wich is used as a  basis for new tables. Sometimes I recreate the template table. I expect some 'table does not exists' errors in that situation, but MySQL crashes instead. 

I don't know which order of actions actually results in the crashing, but the logfile shows regularly the CREATE TABLE a select * from b statement..

Version: '4.0.24-standard'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Official MySQL RPM
mysqld got signal 11;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=267386880
read_buffer_size=2093056
max_used_connections=6
max_connections=50
threads_connected=6
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 465719 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd=0x52213040
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0xbfeff478, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x8072da4
0x826d468
(nil)
0x806f1f8
0x8090ba0
0x807db61
0x807cbfe
0x807c428
0x826ac1c
0x82a0aca
New value of fp=(nil) failed sanity check, terminating stack trace!
Please read http://dev.mysql.com/doc/mysql/en/Using_stack_trace.html and follow instructions on how to resolve the stack trac
e. Resolved
stack trace is much more helpful in diagnosing the problem, so please do
resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x844e028 = CREATE TABLE test1 AS SELECT * FROM templatetable
thd->thread_id=58
The manual page at http://www.mysql.com/doc/en/Crashing.html contains
information that should help you find out what is causing the crash.

Number of processes running now: 0

How to repeat:
Run the following script

#!/bin/bash

for i in 1 2 3 4 5 6 7 8 9 10; do
        msql -e "DROP TABLE IF EXISTS test$i;"
done

for i in 1 2 3 4 5 6 7 8 9 10; do
        echo testing $i
        msql -e "DROP TABLE IF EXISTS templatetable;"&
        msql -e "CREATE TABLE templatetable( DIM SMALLINT,LEVEL SMALLINT,NAME VA
RCHAR(255),PARENT_DIM SMALLINT,PARENT_LEVEL SMALLINT,OPTIONS VARCHAR(255) );" &
        msql -e "CREATE TABLE test$i AS SELECT * FROM templatetable;" &
done

Suggested fix:
Probably the locking mechanism is not working as expected in this situation.
[24 May 2005 6:17] R.P.G. Brouwer
The test script as downloadable file

Attachment: test.sh (application/octet-stream, text), 466 bytes.

[25 May 2005 1:32] MySQL Verification Team
I was unable to repeat this issue with BK source 4.0.24 on
Slackware 10.0
[25 May 2005 13:20] R.P.G. Brouwer
I had to run the script multiple times before the it crashed on several other OS-es.
I used the following call from bash:
$ while : ; do ./test.sh; done

Running this makes mysqld, crash in a few seconds.
 
It made mysqld crash on:
RedHat ??, MySQL 4.0.??
FreeBSD, MySQL 4.0.21
Suse 6, MySQL 4.0.16 and 4.0.24
SuSe 9.2, MySQL 4.0.??