Comment 1 for bug 1705239

Revision history for this message
Arturas Moskvinas (arturas-w) wrote :

Probably related to this bug is that after mysql is restarted and you get error with table missing and actually try dropping table - mysql removes metadata (*.frm file) but leaves innodb (*.ibd) behind and from then on you cannot create table with missing table name anymore or do anything with it without risking mysql crash:
```
test> create table a(id varchar(1) character set utf8, primary key(id));
test> create table b(id varchar(1) character set utf8, b_id varchar(1) character set utf8, primary key(id), CONSTRAINT a_fkey FOREIGN KEY (b_id) REFERENCES a (id));
test> alter table a modify column id varchar(1) character set utf8mb4;
ERROR 1833 (HY000): Cannot change column 'id': used in a foreign key constraint 'a_fkey' of table 'test.b'
test> set foreign_key_checks=0;
test> alter table a modify column id varchar(1) character set utf8mb4;
service mysql restart
test> select * from b;
ERROR 1146 (42S02): Table 'test.b' doesn't exist
test> root@perconatraindb03-sjc1 test5> drop table b;
ERROR 1051 (42S02): Unknown table 'test.b'

/var/lib/mysql/test# ls -la
total 232
drwx------ 2 mysql mysql 4096 Jul 19 11:22 .
drwx------ 31 mysql mysql 4096 Jul 19 11:10 ..
-rw-rw---- 1 mysql mysql 8556 Jul 19 11:10 a.frm
-rw-rw---- 1 mysql mysql 98304 Jul 19 11:10 a.ibd
-rw-rw---- 1 mysql mysql 114688 Jul 19 11:10 b.ibd
-rw-rw---- 1 mysql mysql 67 Jul 19 10:56 db.opt

test> create table b(a varchar(1));
ERROR 1813 (HY000): Tablespace for table '`test`.`b`' exists. Please DISCARD the tablespace before IMPORT.
```

This leaves table in limbo state