List:Maria Storage Engine« Previous MessageNext Message »
From:Guilhem Bichot Date:June 10 2008 8:19pm
Subject:commit into MySQL/Maria:mysql-maria branch (guilhem:2648) Bug#37288
View as plain text  
#At bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-maria/

 2648 Guilhem Bichot	2008-06-10
      Fix for BUG#37288 "Maria - zerofill corrupts table"
modified:
  storage/maria/ma_blockrec.c
  storage/maria/ma_check.c

per-file comments:
  storage/maria/ma_blockrec.c
    comment
  storage/maria/ma_check.c
    When zerofilling the data file, _ma_compact_block_page() may increase free space in a
    page so bitmap page needs to be corrected.
    Question: can, in some cases, other callers of _ma_compact_block_page() be subject to
this problem?
=== modified file 'storage/maria/ma_blockrec.c'
--- a/storage/maria/ma_blockrec.c	2008-06-02 07:27:41 +0000
+++ b/storage/maria/ma_blockrec.c	2008-06-10 20:12:43 +0000
@@ -1345,21 +1345,22 @@ static void calc_record_size(MARIA_HA *i
 }
 
 
-/*
+/**
   Compact page by removing all space between rows
 
-  IMPLEMENTATION
-    Move up all rows to start of page.
-    Move blocks that are directly after each other with one memmove.
+  Moves up all rows to start of page. Moves blocks that are directly after
+  each other with one memmove.
 
-  SYNOPSIS
-    _ma_compact_block_page()
-    buff                Page to compact
-    block_size          Size of page
-    rownr               Put empty data after this row
-    extend_block	If 1, extend the block at 'rownr' to cover the
+  @note if rownr is the last row in the page, and extend_block is false,
+  caller has to make sure to update bitmap page afterwards to reflect freed
+  space.
+
+  @param  buff          Page to compact
+  @param  block_size    Size of page
+  @param  rownr         Put empty data after this row
+  @param  extend_block	If 1, extend the block at 'rownr' to cover the
                         whole block.
-    min_read_from       If <> 0, remove all trid's that are less than this
+  @param  min_read_from If <> 0, remove all trid's that are less than this
 */
 
 

=== modified file 'storage/maria/ma_check.c'
--- a/storage/maria/ma_check.c	2008-05-29 18:39:25 +0000
+++ b/storage/maria/ma_check.c	2008-06-10 20:12:43 +0000
@@ -3240,11 +3240,16 @@ static my_bool maria_zerofill_data(HA_CH
         bzero(buff, LSN_SIZE);
       if (max_entry != 0)
       {
+        my_bool is_head_page= (page_type == HEAD_PAGE);
         dir= dir_entry_pos(buff, block_size, max_entry - 1);
         _ma_compact_block_page(buff, block_size, max_entry -1, 0,
-                               page_type == HEAD_PAGE ? ~(TrID) 0 : 0,
-                               page_type == HEAD_PAGE ?
+                               is_head_page ? ~(TrID) 0 : 0,
+                               is_head_page ?
                                share->base.min_block_length : 0);
+        /* compactation may have increased free space */
+        if (_ma_bitmap_set(info, page, is_head_page,
+                           uint2korr(buff + EMPTY_SPACE_OFFSET)))
+          goto err;
 
         /* Zerofille the not used part */
         offset= uint2korr(dir) + uint2korr(dir+2);
@@ -3266,10 +3271,9 @@ static my_bool maria_zerofill_data(HA_CH
                              PAGECACHE_UNPIN, LSN_IMPOSSIBLE,
                              LSN_IMPOSSIBLE, 1);
   }
-  if (flush_pagecache_blocks(share->pagecache, &info->dfile,
-                             FLUSH_FORCE_WRITE))
-    DBUG_RETURN(1);
-  DBUG_RETURN(0);
+  DBUG_RETURN(_ma_bitmap_flush(share) ||
+              flush_pagecache_blocks(share->pagecache, &info->dfile,
+                                     FLUSH_FORCE_WRITE));
 
 err:
   pagecache_unlock_by_link(share->pagecache, page_link.link,
Thread
commit into MySQL/Maria:mysql-maria branch (guilhem:2648) Bug#37288Guilhem Bichot10 Jun