We're updating the issue view to help you get more done. 

Tablespace desync from files causes uncreatable tables

Description

Originally reported at https://jira.mariadb.org/browse/MDEV-8541

If any kind of system issue causes the loss of specific .tokudb files for a given table, the TokuDB tablespace file mapping will contain invalid (nonexistent) entries, visible in information_schema.TokuDB_file_map where table_schema='$table' and table_name='$broken_table'. At this point, the table cannot be properly dropped and recreated (e.g. from a SQL backup) because recreating the table will result in error 17: file exists.

An easy way to replicate this, assuming tokudb_dir_per_db = ON:
use test;
create table btable (....); #specific schema does not matter
#restart server
drop table btable; #Fails
create table btable(....); #Fails with error 17: file exists
select * from information_schema.TokuDB_file_map where table_schema = 'test' and table_name = 'btable'; #Shows a bunch of nonexistent files

The only workaround I am aware of is to make another table in the same database, with an identical schema, but different name, stop the database, copy all of the table files from the new table over the corresponding files from the bad table (ensuring permissions are writable for the database server), and start the server, and then drop the bad table, which will flush the orphaned entries from information_schema.TokuDB_file_map, allowing the table to be recreated properly.

Environment

Ubuntu 16 Server x64

Status

Assignee

George Lorch

Reporter

Kai

Labels

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

Freshdesk Tickets

None

Affects versions

Percona-Server-5.6.35-80.0

Priority

Major