List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:March 2 2010 9:45am
Subject:bzr commit into mysql-5.1-bugteam branch (svoj:3354) Bug#51307
View as plain text  
#At file:///home/svoj/devel/bzr-mysql/mysql-5.1-bugteam-bug51307/ based on revid:magne.mahre@stripped

 3354 Sergey Vojtovich	2010-03-02
      BUG#51307 - widespread corruption with partitions and
                  insert...select
      
      Queries following bulk insert into an empty MyISAM table
      may break it. This was pure MyISAM problem.
      
      When bulk insert into an empty table is complete, MyISAM
      may want to enable indexes via repair by sort. If repair
      by sort fails (e.g. insufficient buffer), MyISAM failover
      to repair with key cache, requesting repair of data file.
      
      Repair of data file performs data file substitution. This
      means that current table instance will point to new data
      file. Other cached table instances are still pointing to
      an old, deleted data file.
      
      This is fixed by not requesting repair of data file
      during enable indexes.
      
      Explicit REPAIR is not affected, since it flushes all
      table instances.
     @ mysql-test/r/myisam.result
        A test case for BUG#51307.
     @ mysql-test/t/myisam.test
        A test case for BUG#51307.
     @ storage/myisam/ha_myisam.cc
        When enabling indexes do not attempt to repair data file.

    modified:
      mysql-test/r/myisam.result
      mysql-test/t/myisam.test
      storage/myisam/ha_myisam.cc
=== modified file 'mysql-test/r/myisam.result'
--- a/mysql-test/r/myisam.result	2010-02-12 12:47:43 +0000
+++ b/mysql-test/r/myisam.result	2010-03-02 09:45:50 +0000
@@ -2339,4 +2339,37 @@ CHECK TABLE t1;
 Table	Op	Msg_type	Msg_text
 test.t1	check	status	OK
 DROP TABLE t1;
+#
+# BUG#51307 - widespread corruption with partitions and insert...select
+#
+CREATE TABLE t1(a CHAR(255), KEY(a));
+SELECT * FROM t1, t1 AS a1;
+a	a
+SET myisam_sort_buffer_size=4;
+INSERT INTO t1 VALUES
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0');
+Warnings:
+Error	1034	myisam_sort_buffer_size is too small
+Error	1034	Number of rows changed from 0 to 157
+SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
+INSERT INTO t1 VALUES('1');
+SELECT * FROM t1, t1 AS a1 WHERE t1.a=1 AND a1.a=1;
+a	a
+1	1
+DROP TABLE t1;
 End of 5.1 tests

=== modified file 'mysql-test/t/myisam.test'
--- a/mysql-test/t/myisam.test	2010-02-12 12:47:43 +0000
+++ b/mysql-test/t/myisam.test	2010-03-02 09:45:50 +0000
@@ -1587,5 +1587,33 @@ REPLACE INTO t1 VALUES
 CHECK TABLE t1;
 DROP TABLE t1;
 
+--echo #
+--echo # BUG#51307 - widespread corruption with partitions and insert...select
+--echo #
+CREATE TABLE t1(a CHAR(255), KEY(a));
+SELECT * FROM t1, t1 AS a1;
+SET myisam_sort_buffer_size=4;
+INSERT INTO t1 VALUES
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0');
+SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
+INSERT INTO t1 VALUES('1');
+SELECT * FROM t1, t1 AS a1 WHERE t1.a=1 AND a1.a=1;
+DROP TABLE t1;
+
 --echo End of 5.1 tests
 

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2009-10-27 14:27:27 +0000
+++ b/storage/myisam/ha_myisam.cc	2010-03-02 09:45:50 +0000
@@ -1448,9 +1448,17 @@ int ha_myisam::enable_indexes(uint mode)
     {
       sql_print_warning("Warning: Enabling keys got errno %d on %s.%s, retrying",
                         my_errno, param.db_name, param.table_name);
-      /* Repairing by sort failed. Now try standard repair method. */
-      param.testflag&= ~(T_REP_BY_SORT | T_QUICK);
-      error= (repair(thd,param,0) != HA_ADMIN_OK);
+      /*
+        Repairing by sort failed. Now try standard repair method.
+        Still we want to fix only index file. If data file corruption
+        was detected (T_RETRY_WITHOUT_QUICK), we shouldn't do much here.
+        Let implicit repair do this job.
+      */
+      if (!(param.testflag & T_RETRY_WITHOUT_QUICK))
+      {
+        param.testflag&= ~T_REP_BY_SORT;
+        error= (repair(thd,param,0) != HA_ADMIN_OK);
+      }
       /*
         If the standard repair succeeded, clear all error messages which
         might have been set by the first repair. They can still be seen


Attachment: [text/bzr-bundle] bzr/svoj@sun.com-20100302094550-dolgimt5qauove40.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (svoj:3354) Bug#51307Sergey Vojtovich2 Mar