Bug #27381 InnoDB exits when attempting to rename table to non-existant database
Submitted: 22 Mar 2007 17:52 Modified: 18 Jun 2010 23:09
Reporter: Harrison Fisk Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:MySQL 5.0.36, 5.1 OS:Any (All)
Assigned to: Vasil Dimov CPU Architecture:Any
Tags: crash, innodb, rename

[22 Mar 2007 17:52] Harrison Fisk
Description:
When you start the system with innodb_file_per_table and attempt to rename an InnoDB table to a different database that doesn't exist, then InnoDB will exit with the following message:

InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
InnoDB: File name ./test/ibtest.ibd
InnoDB: File operation call: 'rename'.
InnoDB: Cannot continue operation.

How to repeat:
Start MySQL with innodb_file_per_table = 1 then issue the following statements:

CREATE TABLE ibtest (id int) ENGINE=InnoDB;
RENAME TABLE ibtest TO non_existing_database.ibtest;

Suggested fix:
RENAME TABLE calls os_file_rename in the file innobase/os/os0file.c  

When this function gets a failed rename, then it calls os_file_handle_error which exits.  Instead it could call os_file_handle_error_no_exit either all of the time, or conditionally when required since renaming failing isn't bad for RENAME TABLE.
[22 Mar 2007 19:10] Vasil Dimov
I will take it
[23 Mar 2007 11:35] Vasil Dimov
I confirm the issue (tested on 5.1.18-beta BK)
[23 Mar 2007 17:35] Heikki Tuuri
Vasil,

thank you. Excellent work!

This should be fixed both in 5.0 and 5.1.

Regards,

Heikki
[26 Mar 2007 19:49] Vasil Dimov
The fix has been committed to 5.0 and 5.1 InnoDB repositories.
[6 Apr 2007 17:21] Bugs System
Pushed into 5.0.40
[6 Apr 2007 17:25] Bugs System
Pushed into 5.1.18-beta
[7 Apr 2007 18:26] Paul Dubois
Noted in 5.0.40, 5.1.18  changelogs.

With innodb_file_per_table enabled, attempting to rename an InnoDB
table to a non-existent database caused the server to exit.
[5 May 2010 15:10] Bugs System
Pushed into 5.1.47 (revid:joro@sun.com-20100505145753-ivlt4hclbrjy8eye) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[6 May 2010 2:58] Paul Dubois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug. Re-closing.
[28 May 2010 5:55] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100524190136-egaq7e8zgkwb9aqi) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (pib:16)
[28 May 2010 6:24] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100524190941-nuudpx60if25wsvx) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[28 May 2010 6:52] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100524185725-c8k5q7v60i5nix3t) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[29 May 2010 15:23] Paul Dubois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug.
Re-closing.
[17 Jun 2010 11:56] Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 12:35] Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 13:21] Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)