Skip to content
Permalink
Browse files
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.
  • Loading branch information
dr-m committed Jun 12, 2018
1 parent d54d067 commit 8f5f057
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
@@ -18,3 +18,9 @@ path
./abc_def2/test1.ibd
DROP DATABASE abc_def;
DROP DATABASE abc_def2;
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: 168 "Unknown (generic) error from engine")
FOUND 1 /\[ERROR\] InnoDB: Cannot rename file '.*t1\.ibd' to '.*non_existing_db/ in mysqld.1.err
DROP TABLE t1;
@@ -9,9 +9,9 @@


# 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)
@@ -29,3 +29,17 @@ DROP DATABASE abc_def;
--source include/restart_mysqld.inc

DROP DATABASE abc_def2;

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;

--let SEARCH_PATTERN= \[ERROR\] InnoDB: Cannot rename file '.*t1\.ibd' to '.*non_existing_db
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
--source include/search_pattern_in_file.inc

# Cleanup
DROP TABLE t1;
@@ -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);
}

0 comments on commit 8f5f057

Please sign in to comment.