Commit 20cec8bf authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Bug#39750 -cannot create temp file on Windows.

The problem appears often in conjuction with temp files, when temp-pool is used, so that names of temp files are not unique.

The reason is that rapid deletiion and creation of fiiles with the same name on Windows is not guaranteed to succeed. File disappears from the file system only when the last handle to it is closed. If for example  a virus scanner, a backup or indexing  application  opens the  temp file just before MySQL deletes it, the file will enter "delete pending" state. In this state,it is not possible to open the file , or create a file with the same name (CreateFile returns  ERROR_ACCESS_DENED, posix open returns EACESS)

Fix (rather a cheap workarounf) is not to use temp-pool when working with temporary files- this will make filenames unique. 
With this patch , temp- pool setting will be ignored on anything but Linux(the option only made sense for Linux since its invention anyway).
parent 8f500c52
......@@ -227,6 +227,12 @@ extern "C" int gethostname(char *name, int namelen);
extern "C" sig_handler handle_segfault(int sig);
#if defined(__linux__)
#define ENABLE_TEMP_POOL 1
#else
#define ENABLE_TEMP_TOOL 0
#endif
/* Constants */
const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"};
......@@ -3398,8 +3404,13 @@ static int init_common_variables(const char *conf_file_name, int argc,
sys_var_slow_log_path.value= my_strdup(s, MYF(0));
sys_var_slow_log_path.value_length= strlen(s);
#if (ENABLE_TEMP_POOL)
if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1))
return 1;
#else
use_temp_pool= 0;
#endif
if (my_database_names_init())
return 1;
......@@ -6297,9 +6308,14 @@ log and this option does nothing anymore.",
(uchar**) &opt_tc_heuristic_recover, (uchar**) &opt_tc_heuristic_recover,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"temp-pool", OPT_TEMP_POOL,
#if (ENABLE_TEMP_POOL)
"Using this option will cause most temporary files created to use a small set of names, rather than a unique name for each new file.",
#else
"This option is ignored on this OS.",
#endif
(uchar**) &use_temp_pool, (uchar**) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1,
0, 0, 0, 0, 0},
{"timed_mutexes", OPT_TIMED_MUTEXES,
"Specify whether to time mutexes (only InnoDB mutexes are currently supported)",
(uchar**) &timed_mutexes, (uchar**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0,
......
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