Commit 0ad9c3a0 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-16456 InnoDB error "returned OS error 71" complains about wrong path

When attempting to rename a table to a non-existing database,
InnoDB would misleadingly report "OS error 71" when in fact the
error code is InnoDB's own (OS_FILE_NOT_FOUND), and not report
both pathnames. Errors on rename could occur due to reasons
connected to either pathname.

os_file_handle_rename_error(): New function, to report errors in
renaming files.
parent 24d7cbe1
call mtr.add_suppression("InnoDB: (Operating system error|The error means|Cannot rename file)");
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
RENAME TABLE t1 TO non_existing_db.t1;
ERROR HY000: Error on rename of './test/t1' to './non_existing_db/t1' (errno: -1 "Internal error < 0 (Not system error)")
DROP TABLE t1;
......@@ -9,9 +9,10 @@
# Ignore OS errors
call mtr.add_suppression("InnoDB: File ./test/t1*");
call mtr.add_suppression("InnoDB: Error number*");
call mtr.add_suppression("InnoDB: File ./test/t1#p#p1#sp#p1sp0.ibd: 'rename' returned OS error*");
call mtr.add_suppression("InnoDB: File ./test/t1");
call mtr.add_suppression("InnoDB: Error number");
call mtr.add_suppression("InnoDB: Cannot rename file '.*/test/t1#[Pp]#p1#[Ss][Pp]#p1sp0\\.ibd' to");
call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation.");
# MDEV-7046: MySQL#74480 - Failing assertion: os_file_status(newpath, &exists, &type)
# after Operating system error number 36 in a file operation
......
--source include/have_innodb.inc
call mtr.add_suppression("InnoDB: (Operating system error|The error means|Cannot rename file)");
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
--replace_result "\\" "/"
--error ER_ERROR_ON_RENAME
RENAME TABLE t1 TO non_existing_db.t1;
# Cleanup
DROP TABLE t1;
......@@ -1939,6 +1939,24 @@ os_file_delete_func(
#endif
}
/** Handle RENAME error.
@param name old name of the file
@param new_name new name of the file */
static void os_file_handle_rename_error(const char* name, const char* new_name)
{
if (os_file_get_last_error(true) != OS_FILE_DISK_FULL) {
ib_logf(IB_LOG_LEVEL_ERROR, "Cannot rename file '%s' to '%s'",
name, new_name);
} else if (!os_has_said_disk_full) {
os_has_said_disk_full = true;
/* Disk full error is reported irrespective of the
on_error_silent setting. */
ib_logf(IB_LOG_LEVEL_ERROR,
"Full disk prevents renaming file '%s' to '%s'",
name, new_name);
}
}
/***********************************************************************//**
NOTE! Use the corresponding macro os_file_rename(), not directly this function!
Renames a file (can also move it to another directory). It is safest that the
......@@ -1974,8 +1992,7 @@ os_file_rename_func(
return(TRUE);
}
os_file_handle_error_no_exit(oldpath, "rename", FALSE);
os_file_handle_rename_error(oldpath, newpath);
return(FALSE);
#else
int ret;
......@@ -1983,8 +2000,7 @@ os_file_rename_func(
ret = rename(oldpath, newpath);
if (ret != 0) {
os_file_handle_error_no_exit(oldpath, "rename", FALSE);
os_file_handle_rename_error(oldpath, newpath);
return(FALSE);
}
......
......@@ -2146,6 +2146,24 @@ os_file_delete_func(
#endif
}
/** Handle RENAME error.
@param name old name of the file
@param new_name new name of the file */
static void os_file_handle_rename_error(const char* name, const char* new_name)
{
if (os_file_get_last_error(true) != OS_FILE_DISK_FULL) {
ib_logf(IB_LOG_LEVEL_ERROR, "Cannot rename file '%s' to '%s'",
name, new_name);
} else if (!os_has_said_disk_full) {
os_has_said_disk_full = true;
/* Disk full error is reported irrespective of the
on_error_silent setting. */
ib_logf(IB_LOG_LEVEL_ERROR,
"Full disk prevents renaming file '%s' to '%s'",
name, new_name);
}
}
/***********************************************************************//**
NOTE! Use the corresponding macro os_file_rename(), not directly this function!
Renames a file (can also move it to another directory). It is safest that the
......@@ -2181,7 +2199,7 @@ os_file_rename_func(
return(TRUE);
}
os_file_handle_error_no_exit(oldpath, "rename", FALSE);
os_file_handle_rename_error(oldpath, newpath);
return(FALSE);
#else
......@@ -2190,7 +2208,7 @@ os_file_rename_func(
ret = rename(oldpath, newpath);
if (ret != 0) {
os_file_handle_error_no_exit(oldpath, "rename", FALSE);
os_file_handle_rename_error(oldpath, newpath);
return(FALSE);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment