List:Commits« Previous MessageNext Message »
From:Alfranio Correia Date:April 19 2009 1:21am
Subject:bzr commit into mysql-5.1-bugteam branch (alfranio.correia:2860)
Bug#43949
View as plain text  
#At file:///home/acorreia/workspace.sun/repository.mysql/bzrwork/bug-43949/mysql-5.1-bugteam/ based on revid:chad@stripped

 2860 Alfranio Correia	2009-04-19
      BUG#43949 Initialization of slave produces a warning message in Valgrind
      
      In order to define the --slave-load-tmpdir, the init_relay_log_file()
      was calling fn_format(MY_PACK_FILENAME) which internally was indirectly
      calling strmov_overlapp() (through pack_dirname) and the following
      warning message was being printed out while running in Valgrind:
      "source and destination overlap in strcpy".
      
      We fixed the issue by removing the flag MY_PACK_FILENAME as it was not
      necessary. In a nutshell, with this flag the function fn_format() tried
      to replace a directory by either "~", "." or "..". However, we wanted
      exactly to remove such strings.
      
      In this patch, we also refactored the functions init_relay_log_file()
      and check_temp_dir(). The former was refactored to call the fn_format()
      with the flag MY_SAFE_PATH along with the MY_RETURN_REAL_PATH,  in order
      to avoid issues with long directories and return an absolute path,
      respectively. The flag MY_SAFE_UNPACK_FILENAME was removed too as it was
      responsible for removing "~", "." or ".." only from the file parameter
      and we wanted to remove such strings from the directory parameter in
      the fn_format(). This result is stored in an rli variable, which is then
      processed by the other function in order to verify if the directory exists
      and if we are able to create files in it.
     @ mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test
        Changed the output to make it consistent among different runs.
     @ mysys/mf_format.c
        Replaced a return for DBUG_RETURN.

    modified:
      mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result
      mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test
      mysys/mf_format.c
      sql/rpl_rli.cc
      sql/slave.cc
=== modified file 'mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result'
--- a/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result	2009-03-23 01:07:25 +0000
+++ b/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result	2009-04-19 01:21:33 +0000
@@ -3,4 +3,4 @@ MASTER_CONNECT_RETRY=1,
 MASTER_HOST='127.0.0.1',
 MASTER_PORT=MASTER_MYPORT;
 START SLAVE;
-Unable to use slave's temporary directory ../../../error - Can't read dir of '../../../error' (Errcode: 2)
+12

=== modified file 'mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test'
--- a/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test	2009-03-23 01:07:25 +0000
+++ b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test	2009-04-19 01:21:33 +0000
@@ -20,5 +20,5 @@ eval CHANGE MASTER TO MASTER_USER='root'
 START SLAVE;
 
 source include/wait_for_slave_sql_to_stop.inc;
-let $error=query_get_value("show slave status", Last_SQL_Error, 1);
-echo $error;
+let $errno=query_get_value("show slave status", Last_SQL_Errno, 1);
+echo $errno;

=== modified file 'mysys/mf_format.c'
--- a/mysys/mf_format.c	2007-05-10 09:59:39 +0000
+++ b/mysys/mf_format.c	2009-04-19 01:21:33 +0000
@@ -79,7 +79,7 @@ char * fn_format(char * to, const char *
     /* To long path, return original or NULL */
     size_t tmp_length;
     if (flag & MY_SAFE_PATH)
-      return NullS;
+      DBUG_RETURN(NullS);
     tmp_length= strlength(startpos);
     DBUG_PRINT("error",("dev: '%s'  ext: '%s'  length: %u",dev,ext,
                         (uint) length));

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2009-02-22 13:40:52 +0000
+++ b/sql/rpl_rli.cc	2009-04-19 01:21:33 +0000
@@ -104,9 +104,16 @@ int init_relay_log_info(Relay_log_info* 
   rli->tables_to_lock= 0;
   rli->tables_to_lock_count= 0;
 
-  fn_format(rli->slave_patternload_file, PREFIX_SQL_LOAD, slave_load_tmpdir, "",
-            MY_PACK_FILENAME | MY_UNPACK_FILENAME |
-            MY_RETURN_REAL_PATH);
+  char pattern[FN_REFLEN];
+  if (fn_format(pattern, PREFIX_SQL_LOAD, slave_load_tmpdir, "",
+            MY_SAFE_PATH | MY_RETURN_REAL_PATH) == NullS)
+  {
+    pthread_mutex_unlock(&rli->data_lock);
+    sql_print_error("Unable to use slave's temporary directory %s",
+                    slave_load_tmpdir);
+    DBUG_RETURN(1);
+  }
+  unpack_filename(rli->slave_patternload_file, pattern);
   rli->slave_patternload_file_size= strlen(rli->slave_patternload_file);
 
   /*

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2009-04-14 14:38:55 +0000
+++ b/sql/slave.cc	2009-04-19 01:21:33 +0000
@@ -2648,14 +2648,21 @@ err:
   LOAD DATA INFILE.
  */
 static 
-int check_temp_dir(char* tmp_dir, char *tmp_file)
+int check_temp_dir(char* tmp_file)
 {
   int fd;
   MY_DIR *dirp;
+  char tmp_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))))
@@ -2810,7 +2817,7 @@ log '%s' at position %s, relay log '%s' 
                     llstr(rli->group_master_log_pos,llbuff),rli->group_relay_log_name,
                     llstr(rli->group_relay_log_pos,llbuff1));
 
-  if (check_temp_dir(slave_load_tmpdir, rli->slave_patternload_file))
+  if (check_temp_dir(rli->slave_patternload_file))
   {
     rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), 
                 "Unable to use slave's temporary directory %s - %s", 


Attachment: [text/bzr-bundle] bzr/alfranio.correia@sun.com-20090419012133-qymormnarc87ypjm.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (alfranio.correia:2860)Bug#43949Alfranio Correia19 Apr