[Commits] Rev 3006: Don't do DBUG_ASSERT for checksum errors when using REPAIR in lp:maria/5.1

Michael Widenius monty at askmonty.org
Fri Jan 7 17:58:12 EET 2011


At lp:maria/5.1

------------------------------------------------------------
revno: 3006
revision-id: monty at askmonty.org-20110107155812-hqg2lq79ay4gskfb
parent: monty at askmonty.org-20110106204917-oi95n3mco9h7d81v
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.1
timestamp: Fri 2011-01-07 17:58:12 +0200
message:
  Don't do DBUG_ASSERT for checksum errors when using REPAIR
  mysql_convert_table_format ignored --engine option.
  Fix that zerofill() doesn't write out wrong data to client if run with auto repair.
  Ensure that pagecache is properly flushed, even in case of errors.
  Handle checksum errors in BLOCK_RECORD format.
-------------- next part --------------
=== modified file 'scripts/mysql_convert_table_format.sh'
--- a/scripts/mysql_convert_table_format.sh	2009-04-28 18:47:34 +0000
+++ b/scripts/mysql_convert_table_format.sh	2011-01-07 15:58:12 +0000
@@ -28,7 +28,7 @@ $opt_port=0;
 $exit_status=0;
 
 GetOptions(
-  "e|engine|type=s"       => \$opt_type,
+  "e|engine|type=s"       => \$opt_engine,
   "f|force"               => \$opt_force,
   "help|?"               => \$opt_help,
   "h|host=s"              => \$opt_host,

=== modified file 'storage/maria/ha_maria.cc'
--- a/storage/maria/ha_maria.cc	2010-11-07 12:25:29 +0000
+++ b/storage/maria/ha_maria.cc	2011-01-07 15:58:12 +0000
@@ -2022,6 +2022,7 @@ bool ha_maria::check_and_repair(THD *thd
   DBUG_ENTER("ha_maria::check_and_repair");
 
   check_opt.init();
+  check_opt.flags= T_MEDIUM | T_AUTO_REPAIR;
 
   error= 1;
   if ((file->s->state.changed &
@@ -2042,7 +2043,6 @@ bool ha_maria::check_and_repair(THD *thd
     DBUG_RETURN(error);
 
   error= 0;
-  check_opt.flags= T_MEDIUM | T_AUTO_REPAIR;
   // Don't use quick if deleted rows
   if (!file->state->del && (maria_recover_options & HA_RECOVER_QUICK))
     check_opt.flags |= T_QUICK;

=== modified file 'storage/maria/ma_check.c'
--- a/storage/maria/ma_check.c	2011-01-06 20:49:17 +0000
+++ b/storage/maria/ma_check.c	2011-01-07 15:58:12 +0000
@@ -2630,6 +2630,7 @@ int maria_repair(HA_CHECK *param, regist
 
   maria_lock_memory(param);                     /* Everything is alloced */
 
+  sort_param.sort_info->info->in_check_table= 1;
   /* Re-create all keys, which are set in key_map. */
   while (!(error=sort_get_next_record(&sort_param)))
   {
@@ -2797,6 +2798,7 @@ int maria_repair(HA_CHECK *param, regist
   VOID(end_io_cache(&sort_info.new_info->rec_cache));
   info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
   sort_info.new_info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
+  sort_param.sort_info->info->in_check_table= 0;
   /* this below could fail, shouldn't we detect error? */
   if (got_error)
   {
@@ -3247,6 +3249,7 @@ static my_bool maria_zerofill_index(HA_C
   uint block_size= share->block_size;
   my_bool zero_lsn= (share->base.born_transactional &&
                      !(param->testflag & T_ZEROFILL_KEEP_LSN));
+  int error= 1;
   DBUG_ENTER("maria_zerofill_index");
 
   if (!(param->testflag & T_SILENT))
@@ -3271,7 +3274,7 @@ static my_bool maria_zerofill_index(HA_C
       _ma_check_print_error(param,
                             "Page %9s: Got error %d when reading index file",
                             llstr(pos, llbuff), my_errno);
-      DBUG_RETURN(1);
+      goto end;
     }
     if (zero_lsn)
       bzero(buff, LSN_SIZE);
@@ -3279,7 +3282,7 @@ static my_bool maria_zerofill_index(HA_C
     if (share->base.born_transactional)
     {
       uint keynr= _ma_get_keynr(share, buff);
-      if (keynr != MARIA_DELETE_KEY_NR)
+      if (keynr < share->base.keys)
       {
         MARIA_PAGE page;
         DBUG_ASSERT(keynr < share->base.keys);
@@ -3291,7 +3294,7 @@ static my_bool maria_zerofill_index(HA_C
                                 "Page %9s: Got error %d when reading index "
                                 "file",
                                 llstr(pos, llbuff), my_errno);
-          DBUG_RETURN(1);
+          goto end;
         }
       }
     }
@@ -3305,10 +3308,13 @@ static my_bool maria_zerofill_index(HA_C
                              PAGECACHE_UNPIN, LSN_IMPOSSIBLE,
                              LSN_IMPOSSIBLE, 1, FALSE);
   }
+  error= 0;                                     /* ok */
+
+end:
   if (flush_pagecache_blocks(share->pagecache, &share->kfile,
                              FLUSH_FORCE_WRITE))
     DBUG_RETURN(1);
-  DBUG_RETURN(0);
+  DBUG_RETURN(error);
 }
 
 
@@ -4768,7 +4774,7 @@ static int sort_get_next_record(MARIA_SO
         DBUG_RETURN(-1);
       }
       /* Retry only if wrong record, not if disk error */
-      if (flag != HA_ERR_WRONG_IN_RECORD)
+      if (flag != HA_ERR_WRONG_IN_RECORD && flag != HA_ERR_WRONG_CRC)
       {
         retry_if_quick(sort_param, flag);
         DBUG_RETURN(flag);
@@ -6458,6 +6464,9 @@ static void change_data_file_descriptor(
 
 static void unuse_data_file_descriptor(MARIA_HA *info)
 {
+  (void) flush_pagecache_blocks(info->s->pagecache,
+                                &info->s->bitmap.file,
+                                FLUSH_IGNORE_CHANGED);
   info->dfile.file= info->s->bitmap.file.file= -1;
   _ma_bitmap_reset_cache(info->s);
 }

=== modified file 'storage/maria/ma_sort.c'
--- a/storage/maria/ma_sort.c	2009-11-29 23:08:56 +0000
+++ b/storage/maria/ma_sort.c	2011-01-07 15:58:12 +0000
@@ -275,12 +275,13 @@ static ha_rows find_all_keys(MARIA_SORT_
   idx=error=0;
   sort_keys[0]= (uchar*) (sort_keys+keys);
 
+  info->sort_info->info->in_check_table= 1;
   while (!(error=(*info->key_read)(info,sort_keys[idx])))
   {
     if (info->real_key_length > info->key_length)
     {
       if (write_key(info,sort_keys[idx],tempfile_for_exceptions))
-        DBUG_RETURN(HA_POS_ERROR);              /* purecov: inspected */
+        goto err;                             /* purecov: inspected */
       continue;
     }
 
@@ -289,7 +290,7 @@ static ha_rows find_all_keys(MARIA_SORT_
       if (info->write_keys(info,sort_keys,idx-1,
                            (BUFFPEK *)alloc_dynamic(buffpek),
                            tempfile))
-      DBUG_RETURN(HA_POS_ERROR);                /* purecov: inspected */
+        goto err;                             /* purecov: inspected */
 
       sort_keys[0]=(uchar*) (sort_keys+keys);
       memcpy(sort_keys[0],sort_keys[idx-1],(size_t) info->key_length);
@@ -298,18 +299,23 @@ static ha_rows find_all_keys(MARIA_SORT_
     sort_keys[idx]=sort_keys[idx-1]+info->key_length;
   }
   if (error > 0)
-    DBUG_RETURN(HA_POS_ERROR);          /* Aborted by get_key */ /* purecov: inspected */
+    goto err;                             /* purecov: inspected */
   if (buffpek->elements)
   {
     if (info->write_keys(info,sort_keys,idx,(BUFFPEK *)alloc_dynamic(buffpek),
                          tempfile))
-      DBUG_RETURN(HA_POS_ERROR);                /* purecov: inspected */
+      goto err;                         /* purecov: inspected */      
     *maxbuffer=buffpek->elements-1;
   }
   else
     *maxbuffer=0;
 
+  info->sort_info->info->in_check_table= 0;
   DBUG_RETURN((*maxbuffer)*(keys-1)+idx);
+
+err:
+  info->sort_info->info->in_check_table= 0;   /* purecov: inspected */
+  DBUG_RETURN(HA_POS_ERROR);                  /* purecov: inspected */
 } /* find_all_keys */
 
 



More information about the commits mailing list