List:Commits« Previous MessageNext Message »
From:guilhem Date:February 11 2008 1:48pm
Subject:bk commit into maria tree (guilhem:1.2584)
View as plain text  
Below is the list of changes that have just been committed into a local
maria repository of guilhem.  When guilhem does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-02-11 14:48:03+01:00, guilhem@mysqlwin32. +3 -0
  Fix for failures of ma_control_file-t, ma_test_loghandler_purge-t,
  ma_test_loghandler_pagecache-t on Windows.

  storage/maria/ma_control_file.c@stripped, 2008-02-11 14:47:56+01:00, guilhem@mysqlwin32. +8 -9
    stat() is unreliable on Windows (does not reflect process' own writes)

  storage/maria/ma_loghandler.c@stripped, 2008-02-11 14:47:56+01:00, guilhem@mysqlwin32. +12 -18
    translog_set_lsn_for_files() didn't close its file descriptor; it was
    a real problem as non-closed files could not be purged.
    Same for translog_truncate_log() in case of error.

  storage/maria/unittest/ma_test_loghandler_pagecache-t.c@stripped, 2008-02-11 14:47:57+01:00, guilhem@mysqlwin32. +13 -8
    stat() is unreliable on Windows (does not reflect process' own writes)

diff -Nrup a/storage/maria/ma_control_file.c b/storage/maria/ma_control_file.c
--- a/storage/maria/ma_control_file.c	2008-02-07 23:23:59 +01:00
+++ b/storage/maria/ma_control_file.c	2008-02-11 14:47:56 +01:00
@@ -212,9 +212,9 @@ CONTROL_FILE_ERROR ma_control_file_creat
   uchar buffer[CF_MAX_SIZE];
   char name[FN_REFLEN], errmsg_buff[256];
   const char *errmsg;
-  MY_STAT stat_buff;
   uint new_cf_create_time_size, new_cf_changeable_size, new_block_size;
   uint retry;
+  my_off_t file_size;
   int open_flags= O_BINARY | /*O_DIRECT |*/ O_RDWR;
   int error= CONTROL_FILE_UNKNOWN_ERROR;
   DBUG_ENTER("ma_control_file_create_or_open");
@@ -252,13 +252,13 @@ CONTROL_FILE_ERROR ma_control_file_creat
     goto err;
   }
 
-  if (my_stat(name, &stat_buff, MYF(0)) == NULL)
+  file_size= my_seek(control_file_fd, 0, SEEK_END, MYF(MY_WME));
+  if (file_size == MY_FILEPOS_ERROR)
   {
-    errmsg= "Can't read status";
+    errmsg= "Can't read size";
     goto err;
   }
-
-  if ((uint) stat_buff.st_size < CF_MIN_SIZE)
+  if (file_size < CF_MIN_SIZE)
   {
     /*
       Given that normally we write only a sector and it's atomic, the only
@@ -277,14 +277,14 @@ CONTROL_FILE_ERROR ma_control_file_creat
   }
 
   /* Check if control file is unexpectedly big */
-  if ((uint)stat_buff.st_size > CF_MAX_SIZE)
+  if (file_size > CF_MAX_SIZE)
   {
     error= CONTROL_FILE_TOO_BIG;
     errmsg= "File size bigger than expected";
     goto err;
   }
 
-  if (my_read(control_file_fd, buffer, stat_buff.st_size, MYF(MY_FNABP)))
+  if (my_pread(control_file_fd, buffer, (size_t)file_size, 0, MYF(MY_FNABP)))
   {
     errmsg= "Can't read file";
     goto err;
@@ -312,8 +312,7 @@ CONTROL_FILE_ERROR ma_control_file_creat
 
   if (new_cf_create_time_size < CF_MIN_CREATE_TIME_TOTAL_SIZE ||
       new_cf_changeable_size <  CF_MIN_CHANGEABLE_TOTAL_SIZE ||
-      new_cf_create_time_size + new_cf_changeable_size !=
-      stat_buff.st_size)
+      new_cf_create_time_size + new_cf_changeable_size != file_size)
   {
     error= CONTROL_FILE_INCONSISTENT_INFORMATION;
     errmsg= "Sizes stored in control file are inconsistent";
diff -Nrup a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c
--- a/storage/maria/ma_loghandler.c	2008-02-08 15:34:54 +01:00
+++ b/storage/maria/ma_loghandler.c	2008-02-11 14:47:56 +01:00
@@ -1135,10 +1135,11 @@ static my_bool translog_set_lsn_for_file
   {
     LOGHANDLER_FILE_INFO info;
     File fd= open_logfile_by_number_no_cache(file);
-    if (fd < 0 ||
-        translog_read_file_header(&info, fd) ||
-        (cmp_translog_addr(lsn, info.max_lsn) > 0 &&
-         translog_max_lsn_to_header(fd, lsn)))
+    if ((fd < 0) ||
+        ((translog_read_file_header(&info, fd) ||
+          (cmp_translog_addr(lsn, info.max_lsn) > 0 &&
+           translog_max_lsn_to_header(fd, lsn))) |
+          my_close(fd, MYF(MY_WME))))
     {
       translog_stop_writing();
       DBUG_RETURN(1);
@@ -1316,16 +1317,9 @@ LSN translog_get_file_max_lsn_stored(uin
 
   {
     LOGHANDLER_FILE_INFO info;
-    my_bool error;
     File fd= open_logfile_by_number_no_cache(file);
-    if (fd >= 0)
-    {
-      error= translog_read_file_header(&info, fd);
-      my_close(fd, MYF(MY_WME));
-    }
-    else
-      error= TRUE;
-    if (error)
+    if ((fd < 0) ||
+        (translog_read_file_header(&info, fd) | my_close(fd, MYF(MY_WME))))
     {
       DBUG_PRINT("error", ("Can't read file header"));
       DBUG_RETURN(LSN_ERROR);
@@ -3129,11 +3123,11 @@ static my_bool translog_truncate_log(TRA
   page_rest= next_page_offset - LSN_OFFSET(addr);
   memset(page_buff, TRANSLOG_FILLER, page_rest);
   if ((fd= open_logfile_by_number_no_cache(LSN_FILE_NO(addr))) < 0 ||
-      my_chsize(fd, next_page_offset, TRANSLOG_FILLER, MYF(MY_WME)) ||
-      (page_rest && my_pwrite(fd, page_buff, page_rest, LSN_OFFSET(addr),
-                              log_write_flags)) ||
-      my_sync(fd, MYF(MY_WME)) ||
-      my_close(fd, MYF(MY_WME)) ||
+      ((my_chsize(fd, next_page_offset, TRANSLOG_FILLER, MYF(MY_WME)) ||
+        (page_rest && my_pwrite(fd, page_buff, page_rest, LSN_OFFSET(addr),
+                                log_write_flags)) ||
+        my_sync(fd, MYF(MY_WME))) |
+       my_close(fd, MYF(MY_WME))) ||
       (sync_log_dir >= TRANSLOG_SYNC_DIR_ALWAYS &&
        sync_dir(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD))))
     DBUG_RETURN(1);
diff -Nrup a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c
--- a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c	2008-02-07 21:46:18 +01:00
+++ b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c	2008-02-11 14:47:57 +01:00
@@ -51,7 +51,7 @@ int main(int argc __attribute__((unused)
   uchar long_tr_id[6];
   PAGECACHE pagecache;
   LSN lsn;
-  MY_STAT st, *stat;
+  my_off_t file_size;
   LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1];
 
   MY_INIT(argv[0]);
@@ -101,18 +101,20 @@ int main(int argc __attribute__((unused)
   /* Suppressing of automatic record writing */
   dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
 
-  if ((stat= my_stat(first_translog_file, &st,  MYF(0))) == 0)
+  if ((file1.file= my_open(first_translog_file, O_RDONLY,  MYF(MY_WME))) < 0)
   {
     fprintf(stderr, "There is no %s (%d)\n", first_translog_file, errno);
     exit(1);
   }
-  if (st.st_size != TRANSLOG_PAGE_SIZE)
+  file_size= my_seek(file1.file, 0, SEEK_END, MYF(MY_WME));
+  if (file_size != TRANSLOG_PAGE_SIZE)
   {
     fprintf(stderr,
             "incorrect initial size of %s: %ld instead of %ld\n",
-            first_translog_file, (long)st.st_size, (long)TRANSLOG_PAGE_SIZE);
+            first_translog_file, (long)file_size, (long)TRANSLOG_PAGE_SIZE);
     exit(1);
   }
+  my_close(file1.file, MYF(MY_WME));
   int4store(long_tr_id, 0);
   parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
   parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
@@ -153,20 +155,23 @@ int main(int argc __attribute__((unused)
                     0, LSN_IMPOSSIBLE);
     flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE);
   }
-  if ((stat= my_stat(first_translog_file, &st,  MYF(0))) == 0)
+  my_close(file1.file, MYF(MY_WME));
+  if ((file1.file= my_open(first_translog_file, O_RDONLY, MYF(MY_WME))) < 0)
   {
-    fprintf(stderr, "can't stat %s (%d)\n", first_translog_file, errno);
+    fprintf(stderr, "can't open %s (%d)\n", first_translog_file, errno);
     exit(1);
   }
-  if (st.st_size != TRANSLOG_PAGE_SIZE * 2)
+  file_size= my_seek(file1.file, 0, SEEK_END, MYF(MY_WME));
+  if (file_size != TRANSLOG_PAGE_SIZE * 2)
   {
     fprintf(stderr,
             "incorrect initial size of %s: %ld instead of %ld\n",
             first_translog_file,
-            (long)st.st_size, (long)(TRANSLOG_PAGE_SIZE * 2));
+            (long)file_size, (long)(TRANSLOG_PAGE_SIZE * 2));
     ok(0, "log triggered");
     exit(1);
   }
+  my_close(file1.file, MYF(MY_WME));
   ok(1, "log triggered");
 
   translog_destroy();
Thread
bk commit into maria tree (guilhem:1.2584)guilhem11 Feb