Bug #20052 Failure of CREATE TABLE SPACE should rollback TS name from cluster db
Submitted: 24 May 2006 19:15 Modified: 1 Jun 2006 17:27
Reporter: Jonathan Miller Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Cluster: Disk Data Severity:S3 (Non-critical)
Version:5.1.12 OS:Linux (Linux 32 Bit OS)
Assigned to: CPU Architecture:Any

[24 May 2006 19:15] Jonathan Miller
Description:
mysql> set storage_engine=ndb; Query OK, 0 rows affected (0.00 sec)

mysql> CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undofile.dat' INITIAL_SIZE 16M UNDO_BUFFER_SIZE = 1M;
Query OK, 0 rows affected (1.29 sec)

mysql> CREATE TABLESPACE ts1 ADD DATAFILE 'datafile.dat' USE LOGFILE GROUP lg1 INITIAL_SIZE 12M ENGINE NDB;
Query OK, 0 rows affected (1.23 sec)

mysql> CREATE TABLESPACE ts2 ADD DATAFILE 'datafile.dat' USE LOGFILE GROUP lg1 INITIAL_SIZE 12M ENGINE NDB;
ERROR 1515 (HY000): Failed to create DATAFILE
mysql> show warnings;
+-------+------+----------------------------------------------+
| Level | Code | Message                                      |
+-------+------+----------------------------------------------+
| Error | 1296 | Got error 760 'File already exists' from NDB |
| Error | 1515 | Failed to create DATAFILE                    |
+-------+------+----------------------------------------------+
2 rows in set (0.01 sec)
mysql> CREATE TABLESPACE ts2 ADD DATAFILE 'datafile2.dat' USE LOGFILE GROUP lg1 INITIAL_SIZE 12M ENGINE NDB;
ERROR 1515 (HY000): Failed to create TABLESPACE
mysql> show warnings; +-------+------+------------------------------------------------------------------------+
| Level | Code | Message                                                                |
+-------+------+------------------------------------------------------------------------+
| Error | 1296 | Got error 721 'Table or index with given name already exists' from NDB |
| Error | 1515 | Failed to create TABLESPACE                                            |
+-------+------+------------------------------------------------------------------------+
2 rows in set (0.00 sec)
+----+------+----------------------------------+------------------------------------------------------------------------------------------------------+---------+-------+----+---------+------+
| db | name | slock                            | query                                                      | node_id | epoch | id | version | type |
+----+------+----------------------------------+------------------------------------------------------------------------------------------------------+---------+-------+----+---------+------+
|    | ts1  |                                  | CREATE TABLESPACE ts1 ADD DATAFILE 'datafile.dat' USE LOGFILE GROUP lg1 INITIAL_SIZE 12M ENGINE NDB  |       4 |     0 |  0 |       0 |    7 |
|    | ts2  |                                  | DROP TABLESPACE ts2 ENGINE =NDB                                                      |       4 |     0 |  0 |       0 |    7 |
|    | lg1  |                                  | CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undofile.dat' INITIAL_SIZE 16M UNDO_BUFFER_SIZE = 1M          |       4 |     0 |  0 |       0 |    7 |
+----+------+----------------------------------+------------------------------------------------------------------------------------------------------+---------+-------+----+---------+------+

id    type                 state    logging database     schema   name
3     UserTable            Online   Yes     cluster      def      NDB$BLOB_2_3
1     SystemTable          Online   Yes     sys          def      NDB$EVENTS_0
5     LogfileGroup         Online   -                             lg1
11    Datafile             Online   -                             datafile2.dat
6     Undofile             Online   -                             undofile.dat
2     UserTable            Online   Yes     cluster      def      schema
4     UserTable            Online   Yes     cluster      def      apply_status
8     Datafile             Online   -                             datafile.dat
7     Tablespace           Online   -                             ts1
9     Tablespace           Online   -                             ts2

How to repeat:
See above

Suggested fix:
If the create fails, you should rollback the table space name so that the next try will work.

Work arounds currently for this:
mysql> DROP TABLESPACE ts2 ENGINE =NDB; Query OK, 0 rows affected (0.40 sec)

mysql> CREATE TABLESPACE ts2 ADD DATAFILE 'datafile2.dat' USE LOGFILE GROUP lg1 INITIAL_SIZE 12M ENGINE NDB;
Query OK, 0 rows affected (1.25 sec)
[1 Jun 2006 17:27] Jonas Oreland
closing as duplicate of #16341, as it's the same code.
updated synopsis of that one.