MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Anurag Shekhar Date:November 2 2009 6:46am
Subject:bzr commit into mysql-5.1-bugteam branch (anurag.shekhar:3173)
Bug#47012
View as plain text  
#At file:///home/anurag/mysqlsrc/mysql-5.1-bugteam-47012/ based on revid:luis.soares@stripped

 3173 Anurag Shekhar	2009-11-02
      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
        setting the currect version (2) in s->version
        If an unknown version is found marked it as currupt.
     @ storage/archive/ha_archive.cc
        Detecting the archive version in getShare and marking
        it as need to upgrade.
        Blocking open if the archive needs an upgrade. This
        can be allwoed in case of open for repair to upgrade
        the archive but needs to tested.

    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-11-02 06:46:19 +0000
@@ -12717,3 +12717,12 @@ COUNT(t1.a)
 729
 DROP TABLE t1;
 SET @@join_buffer_size= @save_join_buffer_size;
+SHOW CREATE TABLE ar1;
+ERROR HY000: Table upgrade required. Please do "REPAIR TABLE `ar1`" or dump/reload to fix it!
+SELECT * FROM ar1;
+ERROR HY000: Table upgrade required. Please do "REPAIR TABLE `ar1`" or dump/reload to fix 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
+DROP TABLE ar1;

=== 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-11-02 06:46:19 +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-11-02 06:46:19 +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-11-02 06:46:19 +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-11-02 06:46:19 +0000
@@ -1623,3 +1623,20 @@ 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_TABLE_NEEDS_UPGRADE
+SHOW CREATE TABLE ar1;
+
+--error ER_TABLE_NEEDS_UPGRADE
+SELECT * FROM ar1;
+
+REPAIR TABLE ar1;
+DROP 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-11-02 06:46:19 +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. 
@@ -352,11 +352,22 @@ void read_header(azio_stream *s, unsigne
     s->comment_length= (unsigned int)uint4korr(buffer + AZ_COMMENT_LENGTH_POS);
     s->dirty= (unsigned int)buffer[AZ_DIRTY_POS];
   }
-  else
+  else if (buffer[0] == gz_magic[0]  && buffer[1] == gz_magic[1])
   {
-    DBUG_ASSERT(buffer[0] == az_magic[0]  && buffer[1] == az_magic[1]);
+    /*
+      Set version number to privious version (2).
+    */
+    s->version= (unsigned char) 2;
     return;
   }
+  else {
+    /*
+      Unknown version.
+      Most probably due to a corrupt archive.
+    */
+    s->dirty= AZ_STATE_DIRTY;
+    s->z_err = Z_VERSION_ERROR;
+  }
 }
 
 /* ===========================================================================

=== 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-11-02 06:46:19 +0000
@@ -360,6 +360,12 @@ ARCHIVE_SHARE *ha_archive::get_share(con
     stats.auto_increment_value= archive_tmp.auto_increment + 1;
     share->rows_recorded= (ha_rows)archive_tmp.rows;
     share->crashed= archive_tmp.dirty;
+    /*
+     If archive version is less than 3, It should be upgraded before
+     use.
+    */
+    if (archive_tmp.version < ARCHIVE_VERSION)
+      *rc= HA_ERR_TABLE_NEEDS_UPGRADE;
     azclose(&archive_tmp);
 
     VOID(my_hash_insert(&archive_open_tables, (uchar*) share));
@@ -504,6 +510,17 @@ int ha_archive::open(const char *name, i
   }
 
   DBUG_ASSERT(share);
+  if (rc == HA_ERR_TABLE_NEEDS_UPGRADE)
+  {
+    /*
+      Table in 5.0 ARCHIVE format. Though we have almost all
+      routines to access these tables, they were not well tested.
+      For now we have to refuse to open such table to avoid
+      potential data loss.
+    */
+    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-20091102064619-olmegyomv6hdxdpp.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (anurag.shekhar:3173)Bug#47012Anurag Shekhar2 Nov
  • Re: bzr commit into mysql-5.1-bugteam branch (anurag.shekhar:3173)Bug#47012Sergey Vojtovich9 Nov