List:Maria Storage Engine« Previous MessageNext Message »
From:Guilhem Bichot Date:January 27 2009 9:43am
Subject:bzr commit into MySQL/Maria:mysql-maria branch (guilhem:2727)
View as plain text  
#At bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-maria/ based on revid:guilhem@stripped

 2727 Guilhem Bichot	2009-01-27
      When in flush_pagecache_blocks_with_filter(), in debug binaries, verify,
      by trashing them, that the function never uses the pointers found in its
      "file" argument. Using them would be wrong as explained in comments.
modified:
  storage/maria/ma_checkpoint.c
  storage/maria/ma_pagecache.c

per-file messages:
  storage/maria/ma_checkpoint.c
    comment
  storage/maria/ma_pagecache.c
    When in flush_pagecache_blocks_with_filter(), in debug binaries, verify,
    by trashing them, that the function never uses the pointers found in its
    "file" argument
=== modified file 'storage/maria/ma_checkpoint.c'
--- a/storage/maria/ma_checkpoint.c	2008-12-09 09:56:02 +0000
+++ b/storage/maria/ma_checkpoint.c	2009-01-27 09:43:45 +0000
@@ -651,6 +651,14 @@ pthread_handler_t ma_checkpoint_backgrou
             We use FLUSH_KEEP_LAZY: if a file is already in flush, it's
             smarter to move to the next file than wait for this one to be
             completely flushed, which may take long.
+            StaleFilePointersInFlush: notice how below we use "dfile" which
+            is an OS file descriptor plus some function and MARIA_SHARE
+            pointers; this data dates from a previous checkpoint; since then,
+            the table may have been closed (so MARIA_SHARE* became stale), and
+            the file descriptor reassigned to another table which does not
+            have the same CRC-read-set callbacks: it is thus important that
+            flush_pagecache_blocks_with_filter() does not use the pointers,
+            only the OS file descriptor.
           */
           int res=
             flush_pagecache_blocks_with_filter(maria_pagecache,

=== modified file 'storage/maria/ma_pagecache.c'
--- a/storage/maria/ma_pagecache.c	2008-12-27 02:05:16 +0000
+++ b/storage/maria/ma_pagecache.c	2009-01-27 09:43:45 +0000
@@ -4229,9 +4229,8 @@ static int flush_cached_blocks(PAGECACHE
     */
     /*
       It is important to use block->hash_link->file below and not 'file', as
-      the first one is right and the second may have different content (and
-      this matters for callbacks, bitmap pages and data pages have different
-      ones).
+      the first one is right and the second may have different out-of-date
+      content (see StaleFilePointersInFlush in ma_checkpoint.c).
     */
     error= pagecache_fwrite(pagecache, &block->hash_link->file,
                             block->buffer,
@@ -4638,6 +4637,12 @@ int flush_pagecache_blocks_with_filter(P
                                        void *filter_arg)
 {
   int res;
+#ifndef DBUG_OFF
+  PAGECACHE_FILE just_a_descriptor;
+  /* trash pointers to verify that they are not used */
+  bfill(&just_a_descriptor, sizeof(just_a_descriptor), 254);
+  just_a_descriptor.file= file->file; /* only keep OS file descriptor */
+#endif
   DBUG_ENTER("flush_pagecache_blocks_with_filter");
   DBUG_PRINT("enter", ("pagecache: 0x%lx", (long) pagecache));
 
@@ -4645,7 +4650,14 @@ int flush_pagecache_blocks_with_filter(P
     DBUG_RETURN(0);
   pagecache_pthread_mutex_lock(&pagecache->cache_lock);
   inc_counter_for_resize_op(pagecache);
-  res= flush_pagecache_blocks_int(pagecache, file, type, filter, filter_arg);
+  res= flush_pagecache_blocks_int(pagecache,
+#ifndef DBUG_OFF
+                                  &just_a_descriptor
+#else
+                                  file
+#endif
+                                  , type, filter,
+                                  filter_arg);
   dec_counter_for_resize_op(pagecache);
   pagecache_pthread_mutex_unlock(&pagecache->cache_lock);
   DBUG_RETURN(res);

Thread
bzr commit into MySQL/Maria:mysql-maria branch (guilhem:2727) Guilhem Bichot27 Jan