Bug #38521 Problem deleting manually datafiles
Submitted: 1 Aug 2008 14:50 Modified: 25 Mar 2009 16:24
Reporter: Marian Lander Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Falcon storage engine Severity:S3 (Non-critical)
Version: 6.0.5-alpha OS:Linux
Assigned to: Hakan Küçükyılmaz CPU Architecture:Any
Tags: F_TABLESPACE

[1 Aug 2008 14:50] Marian Lander
Description:
Deleting manually a datafile from a tablespace cause other tablespaces to be deleted.

I did the following:

I have 2 tablespaces, the first one I create with the name parent, the second one I create with the name cucu. Create after 2 tables, each one assigned to 1 tablespace, later drop manually 'cucu.fts' datafile, restart the Mysql server after made that change. Login normally to mysql server, verifying that the tablespace 'cucu' didn't exist anymore ::

mysql> select * from babies;
ERROR 1146 (42S02): Table 'primaria.babies' doesn't exist  // Since I delete manually the datafile 'cucu.fts' where table babies where at.

Ok, that's not a problem. in /var/lib/mysql I still have the other tablespace 'parent' which I create first than 'cucu', I haven't delete 'parent' tablespace or 'parent.fts' datafile, in fact I still see 'parent.fts' under /var/lib/mysql. 

In parent tablespace I have 2 tables with name baby and employee, which I create before I delete cucu datafile and before I restart mysql server. So I want to select * data I have in baby table ::

mysql> select * from baby;
ERROR 1146 (42S02): Table 'primaria.baby' doesn't exist

mysql> select * from employee;
ERROR 1146 (42S02): Table 'primaria.employee' doesn't exist

Both tables where assigned to 'parent' tablespace, which I haven't drop or delete manually or else, in fact 'parent.fts' stills exists ::

bash-3.1# ls
falcon_master.flt  mysql-bin.000018  mysql-bin.000024  mysql-bin.000030  parent.fts

But I am not able to describe, insert, modify, etc any of the tables that where in parents tablespace. 

How to repeat:
Create a few tablespaces by order (Will use 3 for this example)

1 - tablespace_1
2 - tablespace_2
3 - tablespace_3

create 3 tables for each tablespace :

1 - table_one assigned to tablespace_1
2 - table_two assigned to tablespace_2
3 - table_3 assigned to tablespace_3

If someone accidentally delete manually the datafile from tablespace 3 (the last tablespace create). After rebooting mysql server, is not possible to view any tables that belongs to tablespace_2 and tablespace_1 even if their datafile exists, it's like for mysql they didn't exists anymore. try to drop them in mysql server and you get a :

mysql> drop tablespace tablespace_2
    -> engine = falcon;
ERROR 1667 (HY000): Tablespace 'tablespace_2' doesn't exist

Suggested fix:
That if some datafile get deleted manually, it doesn't affect other tablespaces.
[1 Aug 2008 18:20] Sveta Smirnova
Thank you for the report.

I can not repeat described behavior in my environment.

Please provide output of `ls /PATH/TO/DATADIR` before and after you delete file from Falcon tablespace.
[1 Aug 2008 19:03] Marian Lander
Thanks for reply. Ok I create again 2 new tablespaces name :: bubu and parents

bubu datafile ::  bubu.fts
parents datafile :: parent.fts

bash-3.1# ls 
falcon_master.fl1     ibdata1           mysql-bin.000004  mysql-bin.000011  mysql-bin.000018  mysql-bin.000025  mysql-bin.000032  bubu.fts
falcon_master.fl2     marian.err        mysql-bin.000005  mysql-bin.000012  mysql-bin.000019  mysql-bin.000026  mysql-bin.000033
falcon_master.fts     marian.pid        mysql-bin.000006  mysql-bin.000013  mysql-bin.000020  mysql-bin.000027  mysql-bin.000034
falcon_temporary.fts  mysql             mysql-bin.000007  mysql-bin.000014  mysql-bin.000021  mysql-bin.000028  mysql-bin.000035
falcon_user.fts       mysql-bin.000001  mysql-bin.000008  mysql-bin.000015  mysql-bin.000022  mysql-bin.000029  mysql-bin.index
ib_logfile0           mysql-bin.000002  mysql-bin.000009  mysql-bin.000016  mysql-bin.000023  mysql-bin.000030  parent.fts
ib_logfile1           mysql-bin.000003  mysql-bin.000010  mysql-bin.000017  mysql-bin.000024  mysql-bin.000031  primaria

So I proceed to delete the last tablespace I create which was bubu;

bash-3.1# rm bubu.fts
bash-3.1# ls 
falcon_master.fl1     ibdata1           mysql-bin.000004  mysql-bin.000011  mysql-bin.000018  mysql-bin.000025  mysql-bin.000032
falcon_master.fl2     marian.err        mysql-bin.000005  mysql-bin.000012  mysql-bin.000019  mysql-bin.000026  mysql-bin.000033
falcon_master.fts     marian.pid        mysql-bin.000006  mysql-bin.000013  mysql-bin.000020  mysql-bin.000027  mysql-bin.000034
falcon_temporary.fts  mysql             mysql-bin.000007  mysql-bin.000014  mysql-bin.000021  mysql-bin.000028  mysql-bin.000035
falcon_user.fts       mysql-bin.000001  mysql-bin.000008  mysql-bin.000015  mysql-bin.000022  mysql-bin.000029  mysql-bin.index
ib_logfile0           mysql-bin.000002  mysql-bin.000009  mysql-bin.000016  mysql-bin.000023  mysql-bin.000030  parent.fts
ib_logfile1           mysql-bin.000003  mysql-bin.000010  mysql-bin.000017  mysql-bin.000024  mysql-bin.000031  primaria

bubu.fts is not anymore in /var/lib/mysql  because I delete it, ok that's no problem. I kill any Mysql service running now;

bash-3.1# killall mysqld
bash-3.1# killall mysqld
mysqld: no process killed

And turn it on again :

bash-3.1# /usr/local/bin/mysqld_safe &
[1] 6497
bash-3.1# 080801 14:53:50 mysqld_safe Logging to '/var/lib/mysql/marian.err'.
080801 14:53:50 mysqld_safe Starting mysqld daemon with databases from /var

So I login again to mysql

bash-3.1# mysql -u marian -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 6.0.5-alpha-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

select a database to see my tables, I have 2 tables before I delete 'bubu.fts' datafile.
mysql> use primaria;
Database changed
mysql> show tables;
+--------------------+
| Tables_in_primaria |
+--------------------+
| baby               |
| bubu               |
+--------------------+
2 rows in set (0.00 sec)

table baby is assigned to parent tablespace and table bubu is assigned to bubu tablespace. I didn't touch or modify anything about parent tablespace or datafile, so nothing should be happen to baby table, so I proceed.

mysql> show create table baby;
ERROR 1146 (42S02): Table 'primaria.baby' doesn't exist
mysql> describe bubu;
ERROR 1146 (42S02): Table 'primaria.bubu' doesn't exist
mysql> select * from information_schema.falcon_tables;
Empty set (0.00 sec)

and if I do a 'ls' command to PATH where parent datafile still exists :

bash-3.1# ls
falcon_master.fl1     ibdata1           mysql-bin.000004  mysql-bin.000011  mysql-bin.000018  mysql-bin.000025  mysql-bin.000032  primaria
falcon_master.fl2     marian.err        mysql-bin.000005  mysql-bin.000012  mysql-bin.000019  mysql-bin.000026  mysql-bin.000033
falcon_master.fts     marian.pid        mysql-bin.000006  mysql-bin.000013  mysql-bin.000020  mysql-bin.000027  mysql-bin.000034
falcon_temporary.fts  mysql             mysql-bin.000007  mysql-bin.000014  mysql-bin.000021  mysql-bin.000028  mysql-bin.000035
falcon_user.fts       mysql-bin.000001  mysql-bin.000008  mysql-bin.000015  mysql-bin.000022  mysql-bin.000029  mysql-bin.000036
ib_logfile0           mysql-bin.000002  mysql-bin.000009  mysql-bin.000016  mysql-bin.000023  mysql-bin.000030  mysql-bin.index
ib_logfile1           mysql-bin.000003  mysql-bin.000010  mysql-bin.000017  mysql-bin.000024  mysql-bin.000031  parent.fts

the parent.fts datafile still untouch, so baby table shouldn't be damage but I am not able to do any SQL query into baby table either since I delete manually 'bubu.fts' datafile I can't access to data in other datafiles after I restart mysql server again, my system is Linux Slackware 12.1 I compile mysql-6.0.5-alpha from source with falcon plugin. I have done this same procedure once and again, and it keeps happening to me, haven't done the same thing in other Linux OS or Windows, so cannot help to said in which system this issue is happening.
[1 Aug 2008 19:22] Sveta Smirnova
Thank you for the feedback.

Verified as described. Problem was name of tablespace: if it does not end with fts problem does not exists.

Workaround: does not add extensio .fts to custom tablespaces.
[1 Aug 2008 21:53] Marian Lander
Thanks for Reply.

Even if I create datafile without extension 'fts' I have the same matter.
What I have done, is change mysql path ownership so this way I try to avoid that any other user delete accidentally some datafile.
[4 Aug 2008 15:43] Sveta Smirnova
Thank you for the feedback.

You are right: extension does not matter. Seems I did wrong test befor.

Here is output in my environment:

$mysql60 test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 6.0.7-alpha-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE TABLESPACE ts1
    ->     ADD DATAFILE 'fn1'
    ->     ENGINE Falcon;
Query OK, 0 rows affected (0.35 sec)

mysql> 
mysql> CREATE TABLESPACE ts2
    ->     ADD DATAFILE 'fn2'
    ->     ENGINE Falcon;
Query OK, 0 rows affected (0.25 sec)

mysql> 
mysql> CREATE TABLESPACE ts3
    ->     ADD DATAFILE 'fn3'
    ->     ENGINE Falcon;
Query OK, 0 rows affected (0.26 sec)

mysql> 
mysql> create table t1(f1 int) engine=falcon tablespace ts1;
Query OK, 0 rows affected (0.15 sec)

mysql> create table t2(f1 int) engine=falcon tablespace ts2;
Query OK, 0 rows affected (0.12 sec)

mysql> create table t3(f1 int) engine=falcon tablespace ts3;
Query OK, 0 rows affected (0.14 sec)

mysql> 
mysql> insert into t1 values(1);
Query OK, 1 row affected (0.01 sec)

mysql> insert into t2 values(2);
Query OK, 1 row affected (0.01 sec)

mysql> insert into t3 values(3);
Query OK, 1 row affected (0.04 sec)

mysql> \q
Bye

$rm  ~/build/mysql-6.0/data/fn2

$boot_manager stop

$boot_manager start

$mysql60 test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 6.0.7-alpha-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show create table t1;
ERROR 1146 (42S02): Table 'test.t1' doesn't exist
mysql> show create table t2;
ERROR 1146 (42S02): Table 'test.t2' doesn't exist
mysql> show create table t3;
ERROR 1146 (42S02): Table 'test.t3' doesn't exist
mysql> \q
Bye
[16 Mar 2009 22:55] Kevin Lewis
Hakan, can you check if this is still a problem?
[25 Mar 2009 16:24] Hakan Küçükyılmaz
Can't repeat with latest Falcon anymore. Deleting a datafile of a tablespace will stop Falcon from restarting:

hakan@lu0011:~/work/mysql-falcon$ mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 6.0.11-alpha Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

[17:17] root@test>CREATE TABLESPACE ts1 ADD DATAFILE 'fn1' ENGINE Falcon;
Query OK, 0 rows affected (0.02 sec)

[17:17] root@test>CREATE TABLESPACE ts2
    -> ADD DATAFILE 'fn2'
    -> ENGINE Falcon;
Query OK, 0 rows affected (0.01 sec)

[17:17] root@test>CREATE TABLESPACE ts3
    -> ADD DATAFILE 'fn3'
    -> ENGINE Falcon;
Query OK, 0 rows affected (0.04 sec)

[17:17] root@test> create table t1(f1 int) engine=falcon tablespace ts1;
Query OK, 0 rows affected (0.00 sec)

[17:17] root@test>create table t2(f1 int) engine=falcon tablespace ts2;
Query OK, 0 rows affected (0.01 sec)

[17:17] root@test>create table t3(f1 int) engine=falcon tablespace ts3;
Query OK, 0 rows affected (0.00 sec)

[17:18] root@test>insert into t1 values(1);
Query OK, 1 row affected (0.00 sec)

[17:18] root@test> insert into t2 values(2);
Query OK, 1 row affected (0.00 sec)

[17:18] root@test>insert into t3 values(3);
Query OK, 1 row affected (0.00 sec)

[17:18] root@test>\q
Bye

# Remove fn2.fts from DATADIR
rm fn2.fts

stop mysqld
start mysqld

090325 17:20:32 mysqld_safe mysqld from pid file /data/mysql/lu0011.pid ended
090325 17:20:37 mysqld_safe Starting mysqld daemon with databases from /data/mysql
090325 17:20:37 [ERROR] Falcon: Recovery failed: can't open file "/data/mysql/fn2.fts": No such file or directo
ry (2)
090325 17:20:37 [ERROR] Plugin 'Falcon' init function returned error.
090325 17:20:37 [ERROR] Plugin 'Falcon' registration as a STORAGE ENGINE failed.
090325 17:20:37  InnoDB: Started; log sequence number 0 46409
090325 17:20:37 [ERROR] Unknown/unsupported table type: Falcon
090325 17:20:37 [ERROR] Aborting