List:Commits« Previous MessageNext Message »
From:Ingo Struewing Date:March 25 2009 1:21pm
Subject:bzr commit into mysql-6.0-backup branch (ingo.struewing:2803) Bug#41722
View as plain text  
#At file:///home2/mydev/bzrroot/mysql-6.0-bug41722-2/ based on revid:rafal.somla@stripped

 2803 Ingo Struewing	2009-03-25
      Bug#41722 - Restore crashes with backup of Falcon tables
      
      During RESTORE of a not so small Falcon table, the server crashed.
      
      The cause for the crash was an attempt to retry to send table data
      to the restore driver after an error from the restore driver.
      Restore::send_data() does not expect to be called again with
      table data after returning an error.
      
      Fixed by aborting RESTORE, if a driver returns an error.
     @ mysql-test/suite/backup/r/backup_default_debug.result
        Bug#41722 - Restore crashes with backup of Falcon tables
        New test result.
     @ mysql-test/suite/backup/t/backup_default_debug.test
        Bug#41722 - Restore crashes with backup of Falcon tables
        New test case.
     @ sql/backup/backup_engine.h
        Bug#41722 - Restore crashes with backup of Falcon tables
        Updated comments.
     @ sql/backup/be_default.cc
        Bug#41722 - Restore crashes with backup of Falcon tables
        Added error injection to fake a storage engine write error.
     @ sql/backup/data_backup.cc
        Bug#41722 - Restore crashes with backup of Falcon tables
        Dropped repetition on errors during restore of table data.

    added:
      mysql-test/suite/backup/r/backup_default_debug.result
      mysql-test/suite/backup/t/backup_default_debug.test
    modified:
      sql/backup/backup_engine.h
      sql/backup/be_default.cc
      sql/backup/data_backup.cc
=== added file 'mysql-test/suite/backup/r/backup_default_debug.result'
--- a/mysql-test/suite/backup/r/backup_default_debug.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_default_debug.result	2009-03-25 13:21:35 +0000
@@ -0,0 +1,19 @@
+DROP DATABASE IF EXISTS mysql_db1;
+#
+# Bug#41722 - Restore crashes with backup of Falcon tables
+#
+CREATE DATABASE mysql_db1;
+CREATE TABLE mysql_db1.t1 (c1 TEXT) ENGINE=Falcon;
+INSERT INTO mysql_db1.t1 VALUES('fdafdsfdsfdsfdsfdsfd');
+BACKUP DATABASE mysql_db1 TO 'mysqltest.bak';
+backup_id
+#
+DROP DATABASE mysql_db1;
+#
+# Inject error Restore__send_data_write_error
+#
+SET debug='d,Restore__send_data_write_error';
+RESTORE FROM 'mysqltest.bak';
+ERROR HY000: Error when sending data (for table #1) to Snapshot restore driver
+SET debug= '';
+DROP DATABASE mysql_db1;

=== added file 'mysql-test/suite/backup/t/backup_default_debug.test'
--- a/mysql-test/suite/backup/t/backup_default_debug.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_default_debug.test	2009-03-25 13:21:35 +0000
@@ -0,0 +1,37 @@
+###########################################################################
+# Purpose: To test backup using default driver with error injection
+###############################################################################
+--source include/have_debug.inc
+--source include/have_falcon.inc
+--source include/not_embedded.inc
+
+--let $BACKUPDIR= `SELECT @@backupdir`
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysql_db1;
+--error 0, 1
+--remove_file $BACKUPDIR/mysqltest.bak
+--enable_warnings
+
+--echo #
+--echo # Bug#41722 - Restore crashes with backup of Falcon tables
+--echo #
+CREATE DATABASE mysql_db1;
+CREATE TABLE mysql_db1.t1 (c1 TEXT) ENGINE=Falcon;
+INSERT INTO mysql_db1.t1 VALUES('fdafdsfdsfdsfdsfdsfd');
+#
+--replace_column 1 #
+BACKUP DATABASE mysql_db1 TO 'mysqltest.bak';
+#
+DROP DATABASE mysql_db1;
+#
+--echo #
+--echo # Inject error Restore__send_data_write_error
+--echo #
+SET debug='d,Restore__send_data_write_error';
+--error ER_BACKUP_SEND_DATA
+RESTORE FROM 'mysqltest.bak';
+#
+SET debug= '';
+DROP DATABASE mysql_db1;
+--remove_file $BACKUPDIR/mysqltest.bak

=== modified file 'sql/backup/backup_engine.h'
--- a/sql/backup/backup_engine.h	2009-02-13 13:25:43 +0000
+++ b/sql/backup/backup_engine.h	2009-03-25 13:21:35 +0000
@@ -495,7 +495,7 @@ public:
    and the buffer can be re-used for further transfers. If method returns
    PROCESSING, it means that the request was accepted but is not
    completed yet. The buffer will not be used for other purposes until a further
-   call to @c get_data() with the same buffer as argument returns OK.
+   call to @c send_data() with the same buffer as argument returns OK.
 
    @param  buf   (in) buffer filled with backup data. Fields @c size,
                  @c table_num and @c last are set
@@ -518,6 +518,11 @@ public:
    @retval ERROR An error has happened. The request is cancelled and the buffer
                  can be used for other transfers.
 
+   @note
+   Reporting ERROR means that restore process has been interrupted and can not 
+   be continued. The driver is assumed to be in error state and backup kernel 
+   will not call any of its methods except for @c free().
+
    @see @c Buffer class.
   */
 

=== modified file 'sql/backup/be_default.cc'
--- a/sql/backup/be_default.cc	2009-02-13 13:25:43 +0000
+++ b/sql/backup/be_default.cc	2009-03-25 13:21:35 +0000
@@ -845,7 +845,11 @@ result_t Restore::send_data(Buffer &buf)
     }
     if (write_row)
     {
+      /* Error injection. */
+      DBUG_EXECUTE_IF("Restore__send_data_write_error",
+                      last_write_res= -1; goto write_skip;);
       last_write_res = hdl->ha_write_row(cur_table->record[0]);
+      IF_DBUG(write_skip:); /* Label for error injection. */
       DBUG_PRINT("backup_default_write", ("%d", last_write_res));
 
       /*

=== modified file 'sql/backup/data_backup.cc'
--- a/sql/backup/data_backup.cc	2009-03-16 14:38:05 +0000
+++ b/sql/backup/data_backup.cc	2009-03-25 13:21:35 +0000
@@ -1572,7 +1572,6 @@ int restore_table_data(THD *thd, Restore
     uint    repeats=0, errors= 0;
     int     ret;
 
-    static const uint MAX_ERRORS= 3;
     static const uint MAX_REPEATS= 7;
 
     Restore_driver  *drvr= NULL;  // pointer to the current driver
@@ -1670,19 +1669,14 @@ int restore_table_data(THD *thd, Restore
           break;
 
         case backup::ERROR:
-          if( errors > MAX_ERRORS )
-          {
-            log.report_error(ER_BACKUP_SEND_DATA, buf.table_num, snap->name());
-            /*
-              If driver signals error then it is not active any longer - neither 
-              ->end() nor ->cancel() should be called on it, only ->free(). 
-              This is why we need to remove it from active[] array.
-            */
-            active[snap_num]= NULL;
-            goto error;
-          }
-          errors++;
-          break;
+          log.report_error(ER_BACKUP_SEND_DATA, buf.table_num, snap->name());
+          /*
+            If driver signals error then it is not active any longer - neither 
+            ->end() nor ->cancel() should be called on it, only ->free(). 
+            This is why we need to remove it from active[] array.
+          */
+          active[snap_num]= NULL;
+          goto error;
 
         case backup::PROCESSING:
         case backup::BUSY:


Attachment: [text/bzr-bundle] bzr/ingo.struewing@sun.com-20090325132135-gh2yqls1h88u3l12.bundle
Thread
bzr commit into mysql-6.0-backup branch (ingo.struewing:2803) Bug#41722Ingo Struewing25 Mar
  • Re: bzr commit into mysql-6.0-backup branch (ingo.struewing:2803)Bug#41722Rafal Somla26 Mar
  • Re: bzr commit into mysql-6.0-backup branch (ingo.struewing:2803)Bug#41722Chuck Bell30 Mar