Bug #7454 Creating table from disabled strage engine
Submitted: 21 Dec 2004 12:04 Modified: 7 May 2005 12:15
Reporter: Ilias Karampatsos Email Updates:
Status: Closed
Category:Server Severity:S3 (Non-critical)
Version:4.1.8 OS:Microsoft Windows (WINDOWS XP)
Assigned to: Antony Curtis Target Version:

[21 Dec 2004 12:04] Ilias Karampatsos
Description:
Server will crash if you request to create table y. Does not matter if x or y are
declared as TEMPORARY

How to repeat:
drop table if exists x,y;
CREATE TABLE x (x mediumint(10) unsigned NOT NULL default '0') ENGINE=MyISAM;
CREATE TABLE y select * FROM x

Suggested fix:
It was working fine up to 4.1.7
[21 Dec 2004 16:01] Victoria Reznichenko
Hi,

Thank you for the report, but I can't reproduce server crash with the above commans.
Is this enough to reproduce it?
[21 Dec 2004 16:40] Ilias Karampatsos
Here is my .ini file. These commands crash the server into my laptop that i use for
development ( 750 MB memory, P4 2.4 GHZ with Windows XP) . I have not tried into our main
server.

# MySQL Configuration File
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
# (@localstatedir@ for this installation) or to
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that the program supports.
# If you want to know the options a program supports, run the program
# with the "--help" option.
#
# More detailed information about the individual options can also be
# found in the manual.
#

#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]

port=3306

#
# The MySQL server
# This section is read by the MySQL Server
#
[mysqld]
group-concat-max-len=10000000

# The TCP/IP Port the MySQL Server will listen on
port=3306

#Path to installation directory. All paths are usually resolved relative to this.
basedir=C:\mysql\

#Path to the database root
datadir=C:\mysql\Data\

# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=latin1

# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB

# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connections=175

# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
query_cache_size=10M
query_cache_type=2 # 2=ondemand mode with SELECT SQL_CACHE ,1=always

# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
table_cache=256

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
tmp_table_size=7M

# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
thread_cache=8

#*** MyISAM Specific options

# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_max_extra_sort_file_size=100G

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_sort_buffer_size=12M

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
key_buffer_size=20M

# Size of the buffer used for doing full table scans of MyISAM tables.
# Allocated per thread, if a full scan is needed.
read_buffer_size=64K
read_rnd_buffer_size=256K

# This buffer is allocated when MySQL needs to rebuild the index in
# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE
# into an empty table. It is allocated per thread so be careful with
# large settings.
sort_buffer_size=1M

#*** INNODB Specific options ***

# Use this option if you have a MySQL server with InnoDB support enabled
# but you do not plan to use it. This will save memory and disk space
# and speed up some things.
skip-innodb

# Additional memory pool that is used by InnoDB to store metadata
# information.  If InnoDB requires more memory for this purpose it will
# start to allocate it from the OS.  As this is fast enough on most
# recent operating systems, you normally do not need to change this
# value. SHOW INNODB STATUS will display the current amount used.
innodb_additional_mem_pool_size=2M

# If set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise this safety, and you are running small
# transactions, you may set this to 0 or 2 to reduce disk I/O to the
# logs. Value 0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value 2
# means the log is written to the log file at each commit, but the log
# file is only flushed to disk approximately once per second.
innodb_flush_log_at_trx_commit=1

# The size of the buffer InnoDB uses for buffering log data. As soon as
# it is full, InnoDB will have to flush it to disk. As it is flushed
# once per second anyway, it does not make sense to have it very large
# (even with long transactions).
innodb_log_buffer_size=1M

# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
# row data. The bigger you set this the less disk I/O is needed to
# access data in tables. On a dedicated database server you may set this
# parameter up to 80% of the machine physical memory size. Do not set it
# too large, though, because competition of the physical memory may
# cause paging in the operating system.  Note that on 32bit systems you
# might be limited to 2-3.5G of user level memory per process, so do not
# set it too high.
innodb_buffer_pool_size=10M

# Size of each log file in a log group. You should set the combined size
# of log files to about 25%-100% of your buffer pool size to avoid
# unneeded buffer pool flush activity on log file overwrite. However,
# note that a larger logfile size will increase the time needed for the
# recovery process.
innodb_log_file_size=10M

# Number of threads allowed inside the InnoDB kernel. The optimal value
# depends highly on the application, hardware as well as the OS
# scheduler properties. A too high value may lead to thread thrashing.
innodb_thread_concurrency=8
[22 Dec 2004 12:31] Ilias Karampatsos
The problem was that default-storage-engine=INNODB and skip-innodb were given at the same
time! So when you create a new temp file and default strage engine is disabled the server
crashes. It is not a bug but an error message for the user would be nicer.
[22 Dec 2004 16:37] Victoria Reznichenko
Verified with 4.1.9-debug-log.
OS: Windows, Linux.
Back trace:

(gdb) bt
#0  safe_mutex_lock (mp=0x4, file=0x8530460 "../include/os0sync.ic", line=43) at
thr_mutex.c:98
#1  0x08355a09 in os_fast_mutex_trylock (fast_mutex=0x4) at ../include/os0sync.ic:43
#2  0x08349857 in mutex_test_and_set (mutex=0x0) at ../include/sync0sync.ic:106
#3  0x083499e7 in mutex_enter_func (mutex=0x0, file_name=0x851ed80 "trx0trx.c", line=172)
at ../include/sync0sync.ic:253
#4  0x083078fb in trx_allocate_for_mysql () at trx0trx.c:172
#5  0x081ea075 in check_trx_exists (thd=0x86b1bb8) at ha_innodb.cc:528
#6  0x081ee68f in ha_innobase::create (this=0x86b5850, name=0xbf3fe9ac "./test/y.frm",
form=0xbf3fe194,
    create_info=0x86b1fd4) at ha_innodb.cc:3760
#7  0x081dd0cc in ha_create_table (name=0xbf3fe9ac "./test/y.frm", create_info=0x86b1fd4,
update_create_info=false)
    at handler.cc:1295
#8  0x081cd396 in rea_create_table (thd=0x86b1bb8, file_name=0xbf3fe9ac "./test/y.frm",
create_info=0x86b1fd4,
    create_fields=@0x86b1ef4, keys=0, key_info=0x86b3f48) at unireg.cc:229
#9  0x082049f8 in mysql_create_table (thd=0x86b1bb8, db=0x867d668 "test",
table_name=0x86b30a0 "y", create_info=0x86b1fd4,
    fields=@0x86b1ef4, keys=@0x86b1ee4, tmp_table=false, select_field_count=1) at
sql_table.cc:1395
#10 0x08204eae in create_table_from_items (thd=0x86b1bb8, create_info=0x86b1fd4,
db=0x867d668 "test", name=0x86b30a0 "y",
    extra_fields=0x86b1ef4, keys=0x86b1ee4, items=0x86b1d50, lock=0x86b3290) at
sql_table.cc:1527
#11 0x081ad96d in select_create::prepare (this=0x86b3230, values=@0x86b1d50, u=0x86b1c00)
at sql_insert.cc:1627
#12 0x08192bf9 in JOIN::prepare (this=0x86b3298, rref_pointer_array=0x86b1dec,
tables_init=0x86b31c8, wild_num=1,
    conds_init=0x0, og_num=0, order_init=0x0, group_init=0x0, having_init=0x0,
proc_param_init=0x0,
    select_lex_arg=0x86b1ce8, unit_arg=0x86b1c00) at sql_select.cc:401
#13 0x08195d83 in mysql_select (thd=0x86b1bb8, rref_pointer_array=0x86b1dec,
tables=0x86b31c8, wild_num=1,
    fields=@0x86b1d50, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0,
proc_param=0x0, select_options=277105152,
    result=0x86b3230, unit=0x86b1c00, select_lex=0x86b1ce8) at sql_select.cc:1564
#14 0x081924cc in handle_select (thd=0x86b1bb8, lex=0x86b1bf4, result=0x86b3230) at
sql_select.cc:193
#15 0x08170d4f in mysql_execute_command (thd=0x86b1bb8) at sql_parse.cc:2403
#16 0x08174b99 in mysql_parse (thd=0x86b1bb8, inBuf=0x86b3058 "CREATE TABLE y select *
FROM x", length=30)
    at sql_parse.cc:4094
#17 0x0816ecf2 in dispatch_command (command=COM_QUERY, thd=0x86b1bb8, packet=0x86b6b09
"CREATE TABLE y select * FROM x",
    packet_length=31) at sql_parse.cc:1505
#18 0x0816e612 in do_command (thd=0x86b1bb8) at sql_parse.cc:1291
#19 0x0816db4b in handle_one_connection (arg=0x86b1bb8) at sql_parse.cc:1023
#20 0xb7e4614b in pthread_start_thread () from /lib/libpthread.so.0
#21 0xb7e461df in pthread_start_thread_event () from /lib/libpthread.so.0
#22 0xb7d7950a in clone () from /lib/libc.so.6
[11 Feb 2005 17:54] Antony Curtis
New patch for fix.
[7 May 2005 12:15] Antony Curtis
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Bug already fixed.