Unable to use slave ' s temporary directory/tmp-can ' t create/write to file '/tmp/sql_load-' (errcode:17)

Source: Internet
Author: User

This error occurred in MySQL master-slave configuration, and finally found a bug in this MySQL

http://bugs.mysql.com/bug.php?id=62055

The main reason for the bug is: When the open mode is specified in the function of opening the file, if O_creat and O_EXCL are specified at the same time, there will be an error in opening the file when the file exists, but when using MySQL master-slave backup mechanism, When installing multiple mysqld instances on a single server, the code is in the MySQL source/sql/slave.cc file, Mysql5.1.68 is in 2904 rows

/*Check The temporary directory used by commands like LOAD DATA INFILE.*/Static intCheck_temp_dir (Char*tmp_file) {  intFD; My_dir*Dirp; CharTmp_dir[fn_reflen];  size_t Tmp_dir_size; Dbug_enter ("Check_temp_dir"); /*Get the directory from the temporary file. */Dirname_part (Tmp_dir, Tmp_file,&tmp_dir_size); /*Check if the directory exists. */  if(! (dirp=My_dir (TMP_DIR,MYF (MY_WME)))) Dbug_return (1);  My_dirend (DIRP); /*Check permissions to create a file. */ if (fd= my_create (Tmp_file, Create_mode, O_wronly | O_binary | O_excl | O_nofollow, MYF (MY_WME)) < 0 ) Dbug_return (1); /*Clean up . */My_close (FD, MYF (0)); My_delete (Tmp_file, MYF (0)); Dbug_return (0);}

The red is called a function to open the file, my_create, in the function of the third argument passed O_EXCL, but there is no o_creat, continue to see the My_create function, it is defined in the/mysys/my_create.c file

File My_create (Const Char*filename,intCreateFlags,intaccess_flags, Myf myflags) {  intFD, RC; Dbug_enter ("my_create"); Dbug_print ("my",("Name: '%s ' CreateFlags:%d AccessFlags:%d myflags:%d", FileName, CreateFlags, Access_flags, Myflags));#if!defined (no_open_3) fd = OPEN (char *) FileName, Access_flags | O_creat, CreateFlags? Createflags:my_umask); #elif defined (VMS) FD = open ((char *) FileName, Access_flags | O_creat, 0, "ctx=stm", "Ctx=bin"); #elif defined (__win__) fd= my_sopen ((char *) FileName, Access_flags | O_creat | O_binary, Sh_denyno, My_s_iread | my_s_iwrite); #else fd = open (FileName, access_flags); #endif  if((Myflags & My_sync_dir) && (FD >=0) &&my_sync_dir_by_file (FileName, Myflags))    {My_close (fd, myflags); FD= -1; } 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))  {    inttmp=My_errno;    My_delete (FileName, myflags); My_errno=tmp; } dbug_return (RC);} /*my_create*/

The red font part of the code is to achieve cross-platform, where the default is the Blue font code, you can see clearly, then add o_creat, at this time caused the o_creat and o_excl at the same time used.

As you can see in the POSIX documentation for the Open function, when O_creat and O_excl are in use, the file will fail if it exists.

Http://linux.die.net/man/3/open

Unable to use slave ' s temporary directory/tmp-can ' t create/write to file '/tmp/sql_load-' (errcode:17)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.