Bug #86253 Errno: 168 - Unknown (generic) error from engine on RENAME TABLE

Submitted: 10 May 2017 4:31 Modified: 10 May 2017 9:52
Reporter: Roel Van de Paar Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S1 (Critical)
Version:5.7.17, 5.7.18 OS:Any
Assigned to: CPU Architecture:Any

[10 May 2017 4:31] Roel Van de Paar
Description:
mysql> RENAME TABLE t1 TO doesnotexist.t1;
ERROR 1025 (HY000): Error on rename of './test/t1' to './doesnotexist/t1' (errno: 168 - Unknown (generic) error from engine)

How to repeat:
DROP DATABASE test;CREATE DATABASE test;USE test;
CREATE TABLE t1(c1 INT KEY,old1 DOUBLE,new1 DOUBLE,old2 DOUBLE,new2 DOUBLE);
RENAME TABLE t1 TO doesnotexist.t1;
[10 May 2017 4:33] Roel Van de Paar
And error log does not match cli:

2017-05-10T03:44:04.363904Z 0 [Note] /sda/MS010217-mysql-5.7.17-linux-x86_64-debug/bin/mysqld: ready for connections.
Version: '5.7.17-debug-log'  socket: '/sda/MS010217-mysql-5.7.17-linux-x86_64-debug/socket.sock'  port: 18388  MySQL Community Server (GPL)
2017-05-10T03:56:00.945473Z 3 [ERROR] InnoDB: Operating system error number 2 in a file operation.
2017-05-10T03:56:00.945500Z 3 [ERROR] InnoDB: The error means the system cannot find the path specified.
2017-05-10T03:56:00.945512Z 3 [ERROR] InnoDB: File ./test/t1.ibd: 'rename' returned OS error 71.
[10 May 2017 4:33] Roel Van de Paar
You may want to mark this as a security bug until proven otherwise.
[10 May 2017 4:34] Roel Van de Paar
Updating version
[10 May 2017 6:27] MySQL Verification Team
Hello Roel,

Thank you for the report.
This is duplicate of Bug #74004, which is fixed in 8.0.

--
[umshastr@hod03]/export/umesh/server/binaries/Trunk/mysql-8.0.1: bin/mysql -uroot -S /tmp/mysql_ushastry.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 8.0.1-dmr MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@localhost [(none)]> DROP DATABASE test;CREATE DATABASE test;USE test;
ERROR 1008 (HY000): Can't drop database 'test'; database doesn't exist
Query OK, 1 row affected (0.00 sec)

Database changed
root@localhost [test]> CREATE TABLE t1(c1 INT KEY,old1 DOUBLE,new1 DOUBLE,old2 DOUBLE,new2 DOUBLE);
Query OK, 0 rows affected (0.01 sec)

root@localhost [test]> RENAME TABLE t1 TO doesnotexist.t1;
ERROR 1049 (42000): Unknown database 'doesnotexist'
root@localhost [test]>
root@localhost [test]>  \! tail -n 5 86253/log.err
2017-05-10T06:20:47.229273Z 0 [Note] IPv6 is available.
2017-05-10T06:20:47.229286Z 0 [Note]   - '::' resolves to '::';
2017-05-10T06:20:47.229336Z 0 [Note] Server socket created on IP: '::'.
2017-05-10T06:20:47.288006Z 0 [Note] bin/mysqld: ready for connections.
Version: '8.0.1-dmr'  socket: '/tmp/mysql_ushastry.sock'  port: 3306  MySQL Community Server (GPL)
root@localhost [test]>

Thanks,
Umesh
[10 May 2017 7:32] Roel Van de Paar
1) The error number is completely different
2) Please fix this is in all releases that it applies to
[10 May 2017 7:32] Roel Van de Paar
.
[10 May 2017 7:35] Roel Van de Paar
And, as mentioned, this can perhaps be exploited. I would suggest marking this as a security concern until proven otherwise.
[10 May 2017 9:52] MySQL Verification Team
--
[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-advanced-5.7.18: bin/mysql -uroot -S /tmp/mysql_ushastry.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@localhost [(none)]> DROP DATABASE test;CREATE DATABASE test;USE test;
ERROR 1008 (HY000): Can't drop database 'test'; database doesn't exist
Query OK, 1 row affected (0.00 sec)

Database changed
root@localhost [test]> CREATE TABLE t1(c1 INT KEY,old1 DOUBLE,new1 DOUBLE,old2 DOUBLE,new2 DOUBLE);
Query OK, 0 rows affected (0.01 sec)

root@localhost [test]> RENAME TABLE t1 TO doesnotexist.t1;
ERROR 1025 (HY000): Error on rename of './test/t1' to './doesnotexist/t1' (errno: 168 - Unknown (generic) error from engine)
root@localhost [test]> \! tail -n 5 86256/log.err
2017-05-10T09:50:30.126959Z 0 [Note] Beginning of list of non-natively partitioned tables
2017-05-10T09:50:30.139239Z 0 [Note] End of list of non-natively partitioned tables
2017-05-10T09:50:49.373749Z 3 [ERROR] InnoDB: Operating system error number 2 in a file operation.
2017-05-10T09:50:49.373773Z 3 [ERROR] InnoDB: The error means the system cannot find the path specified.
2017-05-10T09:50:49.373781Z 3 [ERROR] InnoDB: File ./test/t1.ibd: 'rename' returned OS error 71.
root@localhost [test]>
[13 Oct 2017 12:30] Putinas Piliponis
I would like to add that it fails even with existing directory
My OS is FreeBSD. And it has different mount points for database folders

e.g. 
zm_ssd1tb/db/historic_2013  1.11G   103G  1.11G  /var/db/mysql/historic_2013
zm_ssd1tb/db/historic_2014    88K   103G    88K  /var/db/mysql/historic_2014

I get same error.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.061 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.