mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
Fix for bug #31781: multi-table UPDATE with temp-pool enabled fails
with errno 17 my_create() did not perform any checks for the case when a file is successfully created by a call to open(), but the call to my_register_filename() later fails because the number of open files has exceeded the my_open_files limit. This can happen on platforms which do not have getrlimit(), and hence we do not know the real limit for open files. In such a case an error was returned to a caller although the file has actually been created. Since callers assume my_create() to return an error only when it failed to create a file, they did not perform any cleanups, leaving an 'orphaned' file on the file system. Fixed by adding a check for the above case to my_create() and ensuring the newly created file is deleted before returning an error. Creating a deterministic test case in the test suite is impossible, because the exact steps required to reproduce the above situation depend on the platform and/or environment (OS per-user limits, queries executed by previous tests, startup parameters). The patch was manually tested on Windows using examples posted in the bug report.
This commit is contained in:
parent
d9e7b3b11c
commit
bd53f960dd
1 changed files with 17 additions and 3 deletions
|
@ -35,7 +35,7 @@
|
|||
File my_create(const char *FileName, int CreateFlags, int access_flags,
|
||||
myf MyFlags)
|
||||
{
|
||||
int fd;
|
||||
int fd, rc;
|
||||
DBUG_ENTER("my_create");
|
||||
DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d",
|
||||
FileName, CreateFlags, access_flags, MyFlags));
|
||||
|
@ -60,6 +60,20 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
|
|||
fd = open(FileName, access_flags);
|
||||
#endif
|
||||
|
||||
DBUG_RETURN(my_register_filename(fd, FileName, FILE_BY_CREATE,
|
||||
EE_CANTCREATEFILE, MyFlags));
|
||||
rc= my_register_filename(fd, FileName, FILE_BY_CREATE,
|
||||
EE_CANTCREATEFILE, MyFlags);
|
||||
/*
|
||||
my_register_filename() may fail on some platforms even if the call to
|
||||
*open() above succeeds. In this case, don't leave the stale file because
|
||||
callers assume the file to not exist if my_create() fails, so they don't
|
||||
do any cleanups.
|
||||
*/
|
||||
if (unlikely(fd >= 0 && rc < 0))
|
||||
{
|
||||
int tmp= my_errno;
|
||||
my_delete(FileName, MyFlags);
|
||||
my_errno= tmp;
|
||||
}
|
||||
|
||||
DBUG_RETURN(rc);
|
||||
} /* my_create */
|
||||
|
|
Loading…
Reference in a new issue