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

rename table to nonexistent schema crash

Description

Introduced by issue #DB-295. When tokudb_dir_per_db option is ON, and rename TokuDB table to a nonexistent schema will crash. Try the testcase bellow:

SET GLOBAL tokudb_dir_per_db=ON;
CREATE DATABASE db1;
CREATE TABLE db1.t1(id INT) ENGINE=TokuDB;
--error ER_ERROR_ON_RENAME
RENAME TABLE db1.t1 TO db2.t2; # crashed

The cause is return value of toku_ft_rename_iname() is not checked in env_dbrename().

A proposed fix is as bellow:

diff --git a/src/ydb.cc b/src/ydb.cc
index 3341f6d..76932b3 100644
— a/src/ydb.cc
+++ b/src/ydb.cc
@@ -3100,12 +3100,14 @@ env_dbrename(DB_ENV *env, DB_TXN *txn, const char *fname, const char *dbname, co
if (r != 0) { goto exit; }

// Do not rename ft file if 'dir_per_db' option is not set

  • if (env->get_dir_per_db(env))
    + if (env->get_dir_per_db(env)) {
    r = toku_ft_rename_iname(txn,
    env->get_data_dir(env),
    iname,
    new_iname.get(),
    env->i->cachetable);
    + if (r != 0) { goto exit; }
    + }

r = toku_db_put(env->i->directory,
txn,

Environment

RedHat 6

Status

Assignee

Vladislav Lesin

Reporter

Fungo Wang

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.33-79.0

Priority

Major