List:Commits« Previous MessageNext Message »
From:cbell Date:June 21 2007 3:39pm
Subject:bk commit into 5.1 tree (cbell:1.2541)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of cbell. When cbell does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-06-21 11:38:59-04:00, cbell@stripped +3 -0
  WL#3327 : Online Backup	
  
  This patch moves the open_and_lock_tables from the default and snapshot 
  drivers to the kernel.

  sql/backup/be_default.cc@stripped, 2007-06-21 11:38:55-04:00, cbell@stripped +0 -22
    WL#3327 : Online Backup	
    
    This patch alters the default algorithm by removing the begin() method.
    The open_and_lock_tables() has been moved to the backup kernel.
    

  sql/backup/be_default.h@stripped, 2007-06-21 11:38:55-04:00, cbell@stripped +1 -1
    WL#3327 : Online Backup	
    
    This patch alters the default algorithm by stubbing the begin() method.
    The open_and_lock_tables() has been moved to the backup kernel.

  sql/backup/data_backup.cc@stripped, 2007-06-21 11:38:55-04:00, cbell@stripped +61 -0
    WL#3327 : Online Backup	
    
    This patch alters the restore_table_data method to move the 
    open_and_lock_tables from the default and snapshot drivers to the kernel.
        
    The code retrieves the table_lists from the images, combines them, then
    calls open_and_lock_tables once for both drivers.
    
    The code also splits the lists before the first data is retrieved to 
    allow the drivers to work independently iterating through the tables.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	cbell
# Host:	suse.vabb.com
# Root:	/home/Chuck/source/mysql-5.1_OB_open_tables

--- 1.17/sql/backup/be_default.cc	2007-06-20 16:03:23 -04:00
+++ 1.18/sql/backup/be_default.cc	2007-06-21 11:38:55 -04:00
@@ -188,7 +188,6 @@
 result_t Backup::end()
 {
   DBUG_ENTER("Default_backup::end");
-  close_thread_tables(m_thd);
   DBUG_RETURN(backup::OK);
 }
 
@@ -553,27 +552,6 @@
   */
   if ((last_write_res != 0) && (last_write_res != HA_ERR_WRONG_COMMAND))
     DBUG_RETURN(backup::ERROR);
-  DBUG_RETURN(backup::OK);
-}
-
-/**
-  * @brief Start restore process.
-  *
-  * This method locks all of the tables for writing.
-  *
-  * @retval backup::OK     all tables locked properly.
-  * @retval backup::ERROR  problem with locking tables.
-  */
-result_t Restore::begin(const size_t)
-{
-  DBUG_ENTER("Restore::begin");
-  all_tables->lock_type= TL_WRITE;
-  query_cache.invalidate_locked_for_write(all_tables);
-  if (open_and_lock_tables(m_thd, all_tables))
-  {
-    DBUG_PRINT("restore", ( "error!" ));
-    DBUG_RETURN(backup::ERROR);
-  }
   DBUG_RETURN(backup::OK);
 }
 

--- 1.6/sql/backup/be_default.h	2007-06-20 16:03:23 -04:00
+++ 1.7/sql/backup/be_default.h	2007-06-21 11:38:55 -04:00
@@ -147,7 +147,7 @@
     enum has_data_info { YES, WAIT, EOD };
     Restore(const Table_list &tables, THD *t_thd);
     virtual ~Restore() {};
-    result_t  begin(const size_t);
+    result_t  begin(const size_t) { return backup::OK; };
     result_t  end();
     result_t  send_data(Buffer &buf);
     result_t  cancel() { return backup::OK; };

--- 1.18/sql/backup/data_backup.cc	2007-05-29 13:52:53 -04:00
+++ 1.19/sql/backup/data_backup.cc	2007-06-21 11:38:55 -04:00
@@ -14,6 +14,8 @@
 #include "stream.h"
 #include "backup_kernel.h"
 #include "debug.h"
+#include "archive.h"
+#include "be_default.h"
 
 
 /***********************************************
@@ -999,6 +1001,9 @@
   result_t res;
   Restore_driver* drv[256];
 
+  TABLE_LIST *table_list= 0;
+  TABLE_LIST *table_list_last= 0;
+
   DBUG_ASSERT(info.img_count < 256);
 
   for (uint no=0; no < info.img_count; ++no)
@@ -1016,6 +1021,39 @@
 
     res= drv[no]->begin(0); // TODO: provide correct size
     DBUG_ASSERT(res == OK);
+
+    /*
+      Collect tables from default and snapshot for open and lock tables.
+      There should be at most only 1 of each driver.
+    */
+    if ((img->type() == Image_info::DEFAULT_IMAGE) ||
+        (img->type() == Image_info::SNAPSHOT_IMAGE))
+    {
+      /* 
+        If the table list is defined and the last pointer is
+        defined then we are seeing a duplicate of either default
+        or snapshot drivers. There should be at most 1 of each.
+      */
+      if (table_list && table_list_last->next_global)
+      {
+        DBUG_PRINT("restore",("Duplicate default or snapshot subimage"));
+        DBUG_RETURN(ERROR); 
+      }
+      /*
+        If the table list is empty, use the first one and loop 
+        until the end then record the end of the first one.
+      */
+      if (!table_list)
+      {
+        table_list= ((default_backup::Restore *)drv[no])->get_table_list();
+        table_list_last= table_list;
+        while (table_list_last->next_global != NULL)
+          table_list_last= table_list_last->next_global;
+      }
+      else
+        table_list_last->next_global= 
+          ((default_backup::Restore *)drv[no])->get_table_list();
+    }
   }
 
   Buffer  buf;
@@ -1027,6 +1065,23 @@
 
   size_t start_bytes= s.bytes;
 
+  /*
+    Open tables for default and snapshot drivers.
+  */
+  if (table_list)
+  {
+    table_list->lock_type= TL_WRITE;
+    query_cache.invalidate_locked_for_write(table_list);
+    if (open_and_lock_tables(::current_thd, table_list))
+    {
+      DBUG_PRINT("restore", 
+        ( "error on open tables for default and snapshot drivers!" ));
+      DBUG_RETURN(backup::ERROR);
+    }
+    if (table_list_last)
+      table_list_last->next_global= NULL; // break lists
+  }
+
   // main data reading loop
 
   while ( state != DONE && state != ERROR )
@@ -1144,6 +1199,12 @@
       DBUG_ASSERT(0);
     drv[no]->free();
   }
+
+  /*
+    Close all tables if default or snapshot driver used.
+  */
+  if (table_list)
+    close_thread_tables(::current_thd);
 
   DBUG_RETURN(state != ERROR);
 }
Thread
bk commit into 5.1 tree (cbell:1.2541)cbell21 Jun
  • Re: bk commit into 5.1 tree (cbell:1.2541)Rafal Somla26 Jun
    • RE: bk commit into 5.1 tree (cbell:1.2541)Chuck Bell27 Jun
    • RE: bk commit into 5.1 tree (cbell:1.2541)Chuck Bell27 Jun