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.
This commit is contained in:
Marko Mäkelä 2018-06-11 13:02:47 +03:00
commit 8f5f0575ab
4 changed files with 42 additions and 8 deletions

View file

@ -753,6 +753,23 @@ os_file_handle_error_no_exit(
name, operation, false, on_error_silent));
}
/** 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::error() << "Cannot rename file '" << name << "' to '"
<< 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::error() << "Full disk prevents renaming file '"
<< name << "' to '" << new_name << "'";
}
}
/** Does simulated AIO. This function should be called by an i/o-handler
thread.
@ -777,9 +794,7 @@ os_aio_simulated_handler(
#ifdef _WIN32
static HANDLE win_get_syncio_event();
#endif
#ifdef _WIN32
/**
Wrapper around Windows DeviceIoControl() function.
@ -3224,7 +3239,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);
}
@ -4555,8 +4570,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);
}