rename table to non-existent db with dir-per-db asserts

Description

https://bugs.launchpad.net/bugs/1645386
Also see

1 2 3 4 5 6 7 8 9 10 11 12 mysql> use test; Database changed mysql> show tables; Empty set (0.00 sec) mysql> set global tokudb_dir_per_db=true; Query OK, 0 rows affected (0.00 sec) mysql> create table t1 (id int auto_increment primary key not null) engine=tokudb; Query OK, 0 rows affected (0.09 sec) mysql> alter table test.t1 rename foo.t2;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 #0 0x00007ffff6155c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 resultvar = 0 pid = 32405 selftid = 32500 #1 0x00007ffff6159028 in __GI_abort () at abort.c:89 save_stage = 2 act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = { 140737353508672, 140737353508768, 40960, 140737325687232, 140737322208914, 140737353508672, 140736663534467, 140737415839745, 140737325687232, 140737353508736, 175921860444183, 40959, 140737353467712, 140735869432218, 140735870156960, 140736493790464}}, sa_flags = 0, sa_restorer = 0x7ffff7f6c9c0} sigs = {__val = {32, 0 <repeats 15 times>}} #2 0x00007fffced63be0 in toku_do_backtrace_abort () at /ssd/percona/myrocks-import/percona-server/storage/tokudb/PerconaFT/portability/toku_assert.cc:147 No locals. #3 0x00007fffced63db7 in toku_do_assert_zero_fail (expr=2, expr_as_string=0x7fffced70437 "r", function=0x7fffced72850 <can_acquire_table_lock(__toku_db_env*, __toku_db_txn*, char const*)::__FUNCTION__> "can_acquire_table_lock", file=0x7fffced70838 "/ssd/percona/myrocks-import/percona-server/storage/tokudb/PerconaFT/src/ydb.cc", line=2917, caller_errno=2) at /ssd/percona/myrocks-import/percona-server/storage/tokudb/PerconaFT/portability/toku_assert.cc:177 msg = "/ssd/percona/myrocks-import/percona-server/storage/tokudb/PerconaFT/src/ydb.cc:2917 can_acquire_table_lock: Assertion `r == 0' failed (errno=2) (r=2)\n\000\000(\000\000\000\060\000\000\000\200i\366\367\377\177\000\000\300h\366\367\377\177\000\000\340h\366\367\377\177\000\000\240@\214\237\377\177\000\000\020i\366\367\377\177\000\000"... #4 0x00007fffcec68953 in can_acquire_table_lock (env=0x7fffd23bcc00, txn=0x7ffff5830200, iname_in_env=0x7fff9f8c40a0 "./foo/t2_main_7_2_1d.tokudb") at /ssd/percona/myrocks-import/percona-server/storage/tokudb/PerconaFT/src/ydb.cc:2917 r = 2 got_lock = false db = 0x7fff9f8ae380 __FUNCTION__ = "can_acquire_table_lock" #5 0x00007fffcec695d9 in env_dbrename (env=0x7fffd23bcc00, txn=0x7ffff5830200, fname=0x7fff9f813500 "./test/t1-main", dbname=0x0, newname=0x7fff9f813380 "./foo/t2-main", flags=0) at /ssd/percona/myrocks-import/percona-server/storage/tokudb/PerconaFT/src/ydb.cc:3138 new_iname_dbt = {data = 0x7fff9f8c40a0, size = 28, ulen = 0, flags = 0} new_iname = std::unique_ptr<char> containing 0x7fff9f8c40a0 "./foo/t2_main_7_2_1d.tokudb" dname = 0x7fff9f813500 "./test/t1-main" __FUNCTION__ = "env_dbrename" new_dname_dbt = {data = 0x7fff9f813380, size = 14, ulen = 0, flags = 0} iname_dbt = {data = 0x7fff9f878400, size = 29, ulen = 58, flags = 64} r = 0 old_dname_dbt = {data = 0x7fff9f813500, size = 15, ulen = 0, flags = 0} iname = 0x7fff9f878400 "./test/t1_main_4_2_1d.tokudb"

gdb bt full log attached.

I am very surprised that the server does not validate that the target database exists before passing the command down to the storage engine. I imagine that either the SE ot the FT layer will need to detect this and return some kind of error.

Environment

None

Status

Assignee

Vladislav Lesin

Reporter

George Lorch

Labels

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
Percona-Server-5.7.15-9

Priority

Blocker
Configure