MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Anurag Shekhar Date:October 23 2009 11:56am
Subject:bzr commit into mysql-5.1-bugteam branch (anurag.shekhar:3192)
Bug#47012
View as plain text  
#At file:///home/anurag/mysqlsrc/mysql-5.1-bugteam-47012/ based on revid:dao-gang.qu@stripped

 3192 Anurag Shekhar	2009-10-23
      Bug #47012 archive tables are not upgradeable, and server crashes 
                 on any access
      
      Archive engine for 5.1 (and latter) version uses a modified 
      version of zlib (azlib). These two version are incompatible
      so a proper upgrade is needed before tables created in 5.0 
      can be used reliable.
      
      This upgrade can be performed using repair. But due to lack 
      of test and close proximity with GA dates this patch addressed
      only the crashing issue. Any attempt to repair will be  blocked.
      
      Eventually repair can be allowed to run through (which will also
      cause an upgrade from older version to newer) but only after a 
      thorough testing.
     @ mysql-test/r/archive.result
        Updated result file for test case for bug#47012
     @ mysql-test/std_data/ar1.ARM
        part of table (ar1) created in mysql 5.0
     @ mysql-test/std_data/ar1.ARZ
        part of table (ar1) created in mysql 5.0
     @ mysql-test/std_data/ar1.frm
        part of table (ar1) created in mysql 5.0
     @ mysql-test/t/archive.test
        Added test case for 47012
     @ storage/archive/azio.c
        Fixed a minor issues (minor version over writing version in 
        stream structure)
        Removed assertion when an older version is found instead the 
        table is marked as corrupt which block all operation except 
        for repair.
     @ storage/archive/ha_archive.cc
        Blocked open for repair for older version archive file.
        An error is return indicating the table needs to upgraded.

    added:
      mysql-test/std_data/ar1.ARM
      mysql-test/std_data/ar1.ARZ
      mysql-test/std_data/ar1.frm
    modified:
      mysql-test/r/archive.result
      mysql-test/t/archive.test
      storage/archive/azio.c
      storage/archive/ha_archive.cc
=== modified file 'mysql-test/r/archive.result'
--- a/mysql-test/r/archive.result	2009-09-10 06:58:13 +0000
+++ b/mysql-test/r/archive.result	2009-10-23 11:56:44 +0000
@@ -12717,3 +12717,11 @@ COUNT(t1.a)
 729
 DROP TABLE t1;
 SET @@join_buffer_size= @save_join_buffer_size;
+SHOW CREATE TABLE ar1;
+ERROR HY000: Incorrect key file for table 'ar1'; try to repair it
+SELECT * FROM ar1;
+ERROR HY000: Incorrect key file for table 'ar1'; try to repair it
+REPAIR TABLE ar1;
+Table	Op	Msg_type	Msg_text
+test.ar1	repair	Error	Table upgrade required. Please do "REPAIR TABLE `ar1`" or dump/reload to fix it!
+test.ar1	repair	error	Corrupt

=== added file 'mysql-test/std_data/ar1.ARM'
Binary files a/mysql-test/std_data/ar1.ARM	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/ar1.ARM	2009-10-23 11:56:44 +0000 differ

=== added file 'mysql-test/std_data/ar1.ARZ'
Binary files a/mysql-test/std_data/ar1.ARZ	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/ar1.ARZ	2009-10-23 11:56:44 +0000 differ

=== added file 'mysql-test/std_data/ar1.frm'
Binary files a/mysql-test/std_data/ar1.frm	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/ar1.frm	2009-10-23 11:56:44 +0000 differ

=== modified file 'mysql-test/t/archive.test'
--- a/mysql-test/t/archive.test	2009-09-10 06:58:13 +0000
+++ b/mysql-test/t/archive.test	2009-10-23 11:56:44 +0000
@@ -1623,3 +1623,19 @@ INSERT INTO t1 VALUES('aaaaaaaaaaaaaaaaa
 SELECT COUNT(t1.a) FROM t1, t1 a, t1 b, t1 c, t1 d, t1 e;
 DROP TABLE t1;
 SET @@join_buffer_size= @save_join_buffer_size;
+
+#
+# BUG#47012 archive tables are not upgradeable, and server crashes on any access
+#
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+copy_file std_data/ar1.frm $MYSQLD_DATADIR/test/ar1.frm;
+copy_file std_data/ar1.ARZ $MYSQLD_DATADIR/test/ar1.ARZ;
+copy_file std_data/ar1.ARM $MYSQLD_DATADIR/test/ar1.ARM;
+
+--error ER_NOT_KEYFILE
+SHOW CREATE TABLE ar1;
+
+--error ER_NOT_KEYFILE
+SELECT * FROM ar1;
+
+REPAIR TABLE ar1;

=== modified file 'storage/archive/azio.c'
--- a/storage/archive/azio.c	2009-02-13 16:41:47 +0000
+++ b/storage/archive/azio.c	2009-10-23 11:56:44 +0000
@@ -69,7 +69,7 @@ int az_open (azio_stream *s, const char 
   s->transparent = 0;
   s->mode = 'r';
   s->version = (unsigned char)az_magic[1]; /* this needs to be a define to version */
-  s->version = (unsigned char)az_magic[2]; /* minor version */
+  s->minor_version = (unsigned char)az_magic[2]; /* minor version */
 
   /*
     We do our own version of append by nature. 
@@ -280,6 +280,11 @@ void check_header(azio_stream *s)
   /* Peek ahead to check the gzip magic header */
   if ( s->stream.next_in[0] == gz_magic[0]  && s->stream.next_in[1] == gz_magic[1])
   {
+    /*
+     Old file found.
+     Mark it as dirty. Repair will upgrade it.
+    */
+    s->dirty = AZ_STATE_DIRTY;
     s->stream.avail_in -= 2;
     s->stream.next_in += 2;
     s->version= (unsigned char)2;
@@ -354,7 +359,13 @@ void read_header(azio_stream *s, unsigne
   }
   else
   {
-    DBUG_ASSERT(buffer[0] == az_magic[0]  && buffer[1] == az_magic[1]);
+    /*
+     Old version file.
+     Mark it dirty. Repair will upgrade it.
+     Set version number to privious version (2).
+    */
+    s->dirty = AZ_STATE_DIRTY;
+    s->version= (unsigned char)2;
     return;
   }
 }

=== modified file 'storage/archive/ha_archive.cc'
--- a/storage/archive/ha_archive.cc	2009-09-23 13:21:29 +0000
+++ b/storage/archive/ha_archive.cc	2009-10-23 11:56:44 +0000
@@ -504,6 +504,17 @@ int ha_archive::open(const char *name, i
   }
 
   DBUG_ASSERT(share);
+  if ((open_options & HA_OPEN_FOR_REPAIR) &&
+                        (share->archive_write.version < ARCHIVE_VERSION))
+  {
+    /*
+     Block repair on older archives.
+     Letting repair run on older archives does an upgrade too
+     but this shouldn't be allowed before sufficient testing.
+    */
+    free_share();
+    DBUG_RETURN (HA_ERR_TABLE_NEEDS_UPGRADE);
+  }
 
   record_buffer= create_record_buffer(table->s->reclength + 
                                       ARCHIVE_ROW_HEADER_SIZE);


Attachment: [text/bzr-bundle] bzr/anurag.shekhar@sun.com-20091023115644-sqeu5srvtpyiur9w.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (anurag.shekhar:3192)Bug#47012Anurag Shekhar23 Oct
  • Re: bzr commit into mysql-5.1-bugteam branch (anurag.shekhar:3192)Bug#47012Sergey Vojtovich27 Oct