Bug #23737 CREATE TABLESPACE without INITIAL_SIZE creates datafile with random size
Submitted: 27 Oct 2006 21:09 Modified: 15 Mar 2007 0:31
Reporter: Roland Bouman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S2 (Serious)
Version:5.1.13 bk OS:Linux (ubuntu dapper drake)
Assigned to: Jon Stephens CPU Architecture:Any
Tags: CREATE TABLESPACE, Datafile, INITIAL_SIZE

[27 Oct 2006 21:09] Roland Bouman
Description:
http://dev.mysql.com/doc/refman/5.1/en/create-tablespace.html

explains the syntax of CREATE TABLESPACE:

CREATE TABLESPACE tablespace
    ADD DATAFILE 'file'
    USE LOGFILE GROUP logfile_group
    [EXTENT_SIZE [=] extent_size]
    INITIAL_SIZE [=] initial_size
    ENGINE [=] engine

Note that the INITIAL_SIZE is marked as mandatory.

However, a CREATE TABLESPACE statement without INITIAL_SIZE is accepted, and creates a tablespace as well as an associated datafile. The size of the created datafile is indeterminate (I've seen: ~128MB, ~62Mb, 52Mb)  

How to repeat:
create logfile group logfile_group_1
add undofile 'logfile_group_1_undofile_1.dat'
initial_size 16M
undo_buffer_size 2M
engine ndb;

--here comes:

# mysql:

create tablespace tablespace_1 
add datafile 'datafile_1.data' 
use logfile group logfile_group_1 
engine ndb;

# shell at roland@Rolenove:/opt/mysql/cluster/ndb_2_fs

ls -l d*.dat

-rw-r--r-- 1 roland roland 134283264 2006-10-27 22:36 datafile_1.data

# mysql:

alter tablespace tablespace_1 drop datafile 'datafile_1.data' engine ndb;

drop tablespace tablespace_1 engine ndb;

# then, repeat from where the table space is created, you will notice other sizes:

-rw-r--r-- 1 roland roland 65110016 2006-10-27 22:51 datafile_1.data

..

-rw-r--r-- 1 roland roland 54689792 2006-10-27 22:53 datafile_1.data 
 

Suggested fix:
Uhm...fix statement according to the documentation. 

Better yet: allow the syntax without the INITIAL_SIZE (it might not be applicable to all storage engines that can use this syntax in the future) and provide a constant default size.
[4 Dec 2006 9:52] Jonas Oreland
Hi,

I could not reproduce this to my big surprise.
I run a 1-node cluster.

Also from looking at code, there is a default value of 128M

/Jonas
[9 Feb 2007 21:12] Serge Kozlov
This is can be reproduced for mysql-5.1.16-bk (cluster has 2 data nodes, 2 replicas). the size of datafile isn't random but ~134MB.

mysql> create logfile group lg1 add undofile 'undofile.dat' initial_size=20M un
do_buffer_size=10M engine=ndb;
Query OK, 0 rows affected (9.79 sec)

mysql> create tablespace ts1 add datafile 'datafile.dat' use logfile group lg1
engine=ndb;
Query OK, 0 rows affected (57.00 sec)
[9 Feb 2007 22:13] Roland Bouman
Hi Serge, 

thank you! Did you use a debug build? 

The filesize you report corresponds with what I think is the default, 128M. If this can be reproduced over and over with the same file size, we need to make a documentation request out of it to document the default value. Also the syntax production rule will need to reflect that the size specification is optional.

Thank you!
[15 Mar 2007 0:23] Jon Stephens
Okay, it's a docs bug. :)

Changed category/status/severity/priority to Docs/Open/S2/P2.

Reassigned to myself with Stefan as lead.
[15 Mar 2007 0:31] Jon Stephens
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Updated CREATE TABLESPACE info in 5.1 Manual as suggested. Thanks for the heads-up.