List:Internals« Previous MessageNext Message »
From:tomas Date:June 3 2005 10:34am
Subject:bk commit into 5.1 tree (tomas:1.1931)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas 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
  1.1931 05/06/03 12:34:18 tomas@stripped +4 -0
  added test of rest slave and reset master to see that they reset the cluster_replication databases...
  added so that reset slave clears the apply_status table
  + some cleanup

  sql/sql_repl.cc
    1.139 05/06/03 12:34:13 tomas@stripped +10 -3
    added test of rest slave and reset master to see that they reset the cluster_replication databases...
    added so that reset slave clears the apply_status table

  sql/ha_ndbcluster.cc
    1.271 05/06/03 12:34:13 tomas@stripped +51 -64
    added test of rest slave and reset master to see that they reset the cluster_replication databases...
    added so that reset slave clears the apply_status table
    + some cleanup

  mysql-test/t/rpl_ndb_sync.test
    1.4 05/06/03 12:34:13 tomas@stripped +13 -5
    added test of rest slave and reset master to see that they reset the cluster_replication databases...
    added so that reset slave clears the apply_status table

  mysql-test/r/rpl_ndb_sync.result
    1.3 05/06/03 12:34:13 tomas@stripped +6 -2
    added test of rest slave and reset master to see that they reset the cluster_replication databases...
    added so that reset slave clears the apply_status table

# 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:	tomas
# Host:	poseidon.ndb.mysql.com
# Root:	/home/tomas/mysql-5.1-wl2325

--- 1.270/sql/ha_ndbcluster.cc	2005-06-02 20:23:17 +02:00
+++ 1.271/sql/ha_ndbcluster.cc	2005-06-03 12:34:13 +02:00
@@ -8259,23 +8259,8 @@
   return 0;
 }
 
-/* Called from  MYSQL_LOG::reset_logs in log.cc */
-
-int ndbcluster_reset_logs(THD *thd)
+static void run_query(THD *thd, char *buf, char *end, my_bool print_error)
 {
-  DBUG_ENTER("ndbcluster_reset_logs");
-
-  if (ndb_injector_thread_running <= 0)
-    DBUG_RETURN(0);
-
-  /*
-   * ToDo: make sure that all events from this mysql server has
-   * reached the binlog before doing the below
-   */
-
-  char buf[1024];
-  char *end=strmov(buf, "DELETE FROM " NDB_REP_DB "." NDB_REP_TABLE);
-
   ulong save_query_length= thd->query_length;
   char *save_query= thd->query;
   ulong save_thread_id= thd->variables.pseudo_thread_id;
@@ -8289,10 +8274,37 @@
 
   mysql_parse(thd,thd->query,thd->query_length);
 
+  if (print_error && thd->query_error)
+  {
+    sql_print_error("NDB: %s: error %s %d %d %d",
+		    buf, thd->net.last_error, thd->net.last_errno,
+		    thd->net.report_error, thd->query_error);
+  }
+
   thd->query_length= save_query_length;
   thd->query= save_query;
   thd->variables.pseudo_thread_id= save_thread_id;
   thd->net= save_net;
+}
+
+/* Called from  MYSQL_LOG::reset_logs in log.cc */
+
+int ndbcluster_reset_logs(THD *thd)
+{
+  if (ndb_injector_thread_running <= 0)
+    return 0;
+
+  DBUG_ENTER("ndbcluster_reset_logs");
+
+  /*
+   * ToDo: make sure that all events from this mysql server has
+   * reached the binlog before doing the below
+   */
+
+  char buf[1024];
+  char *end=strmov(buf, "DELETE FROM " NDB_REP_DB "." NDB_REP_TABLE);
+
+  run_query(thd,buf,end,FALSE);
 
   DBUG_RETURN(0);
 }
@@ -8301,35 +8313,19 @@
 
 int ndbcluster_binlog_index_purge_file(THD *thd,const char *file)
 {
+  if (ndb_injector_thread_running <= 0)
+    return 0;
+
   DBUG_ENTER("ndbcluster_binlog_index_purge_file");
   DBUG_PRINT("enter",("file: %s",file));
 
-  if (ndb_injector_thread_running <= 0)
-    DBUG_RETURN(0);
-
   char buf[1024];
   char *end=strmov(strmov(strmov(buf,
 				 "DELETE FROM "
 				 NDB_REP_DB "." NDB_REP_TABLE
 				 " WHERE File='"), file), "'");
 
-  ulong save_query_length= thd->query_length;
-  char *save_query= thd->query;
-  ulong save_thread_id= thd->variables.pseudo_thread_id;
-  NET save_net= thd->net;
-
-  bzero((char*)&thd->net,sizeof(NET));
-  thd->query_length= end-buf;
-  thd->query= buf;
-  thd->variables.pseudo_thread_id= thread_id;		// for temp tables
-  DBUG_PRINT("query",("%s",thd->query));
-
-  mysql_parse(thd,thd->query,thd->query_length);
-
-  thd->query_length= save_query_length;
-  thd->query= save_query;
-  thd->variables.pseudo_thread_id= save_thread_id;
-  thd->net= save_net;
+  run_query(thd,buf,end,FALSE);
 
   DBUG_RETURN(0);
 }
@@ -8372,20 +8368,15 @@
   char buf[1024], *end;
 
   sql_print_information("NDB: Creating " NDB_REP_DB "." NDB_APPLY_TABLE);
-  /* save some thread variables as not to changes them */
-  ulong save_query_length= thd->query_length;
-  char *save_query= thd->query;
-  ulong save_thread_id= thd->variables.pseudo_thread_id;
-  NET save_net= thd->net;
 
   /* Check if apply status table exists in MySQL "dictionary"
    * if so, remove it since there is none in Ndb
    */
   {
     strxnmov(buf, sizeof(buf),
-	     mysql_data_home, "/",
-	     NDB_REP_DB, "/",
-	     NDB_APPLY_TABLE, reg_ext, NullS);
+	     mysql_data_home,
+	     "/" NDB_REP_DB "/" NDB_APPLY_TABLE,
+	     reg_ext, NullS);
     unpack_filename(buf,buf);
     my_delete(buf,MYF(0));
   }
@@ -8397,25 +8388,7 @@
 	     " ( server_id INT UNSIGNED NOT NULL, epoch BIGINT UNSIGNED NOT NULL, "
 	     " PRIMARY KEY USING HASH (server_id) ) ENGINE=NDB");
 
-  bzero((char*)&thd->net,sizeof(NET));
-  thd->query_length= end-buf;
-  thd->query= buf;
-  thd->variables.pseudo_thread_id= thread_id;		// for temp tables
-  DBUG_PRINT("query",("%s",thd->query));
-
-  mysql_parse(thd,thd->query,thd->query_length);
-
-  if (thd->query_error)
-  {
-    sql_print_error("NDB: %s: error %s %d %d %d",
-		    buf, thd->net.last_error, thd->net.last_errno,
-		    thd->net.report_error, thd->query_error);
-  }
-
-  thd->query_length= save_query_length;
-  thd->query= save_query;
-  thd->variables.pseudo_thread_id= save_thread_id;
-  thd->net= save_net;
+  run_query(thd,buf,end,TRUE);
 
   DBUG_RETURN(0);
 }
@@ -8473,6 +8446,18 @@
   DBUG_VOID_RETURN;
 }
 
+void ndbcluster_reset_slave(THD* thd)
+{
+  if (ndb_injector_thread_running <= 0)
+    return;
+
+  DBUG_ENTER("ndbcluster_reset_slave");
+  char buf[1024];
+  char *end=strmov(buf, "DELETE FROM " NDB_REP_DB "." NDB_APPLY_TABLE);
+  run_query(thd,buf,end,FALSE);
+  DBUG_VOID_RETURN;
+}
+
 void ndbcluster_wait_binlog(THD* thd)
 {
   if (ndb_injector_thread_running > 0)
@@ -8481,7 +8466,9 @@
     const char *save_info= thd->proc_info;
     ulonglong wait_epoch= g_latest_trans_gci;
     int count= 30;
-    thd->proc_info= "Waiting for ndbcluster binlog update to reach current position";
+    thd->proc_info=
+      "Waiting for ndbcluster binlog update to "
+      "reach current position";
     while (count && ndb_injector_thread_running > 0 &&
 	   ndb_latest_applied_binlog_epoch < wait_epoch)
     {

--- 1.138/sql/sql_repl.cc	2005-06-02 19:17:30 +02:00
+++ 1.139/sql/sql_repl.cc	2005-06-03 12:34:13 +02:00
@@ -26,6 +26,11 @@
 my_bool opt_sporadic_binlog_dump_fail = 0;
 static int binlog_dump_count = 0;
 
+#ifdef HAVE_NDBCLUSTER_DB
+void ndbcluster_reset_slave(THD* thd);
+void ndbcluster_wait_binlog(THD* thd);
+#endif
+
 /*
     fake_rotate_event() builds a fake (=which does not exist physically in any
     binlog) Rotate event, which contains the name of the binlog we are going to
@@ -970,6 +975,11 @@
     error=1;
     goto err;
   }
+
+#ifdef HAVE_NDBCLUSTER_DB
+  ndbcluster_reset_slave(thd);
+#endif
+
   // delete relay logs, clear relay log coordinates
   if ((error= purge_relay_logs(&mi->rli, thd,
 			       1 /* just reset */,
@@ -1296,9 +1306,6 @@
   return ((log_file_name1_len < log_file_name2_len) ? -1 : 1);
 }
 
-#ifdef HAVE_NDBCLUSTER_DB
-void ndbcluster_wait_binlog(THD* thd);
-#endif
 bool mysql_show_binlog_events(THD* thd)
 {
   Protocol *protocol= thd->protocol;

--- 1.2/mysql-test/r/rpl_ndb_sync.result	2005-05-09 05:10:41 +02:00
+++ 1.3/mysql-test/r/rpl_ndb_sync.result	2005-06-03 12:34:13 +02:00
@@ -4,9 +4,7 @@
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-DELETE FROM cluster_replication.binlog_index;
 STOP SLAVE;
-DELETE FROM cluster_replication.binlog_index;
 CREATE TABLE t1 (c1 BIT(1) NOT NULL, c2 BIT(1) NOT NULL, c3 CHAR(15), PRIMARY KEY(c3)) ENGINE = NDB ;
 INSERT INTO t1 VALUES (1,1,"row1"),(0,1,"row2"),(1,0,"row3"),(0,0,"row4");
 CREATE TABLE t2 (c1 CHAR(15), c2 BIT(1) NOT NULL, c3 BIT(1) NOT NULL, PRIMARY KEY(c1)) ENGINE = NDB ;
@@ -80,3 +78,9 @@
 0	0	DEFGHIJKL
 DROP TABLE t1,t2;
 STOP SLAVE;
+reset master;
+select * from cluster_replication.binlog_index;
+Position	File	epoch	inserts	updates	deletes	schemaops
+reset slave;
+select * from cluster_replication.apply_status;
+server_id	epoch

--- 1.3/mysql-test/t/rpl_ndb_sync.test	2005-05-24 15:44:26 +02:00
+++ 1.4/mysql-test/t/rpl_ndb_sync.test	2005-06-03 12:34:13 +02:00
@@ -9,13 +9,8 @@
 
 # stop the save
 connection slave;
-DELETE FROM cluster_replication.binlog_index;
 STOP SLAVE;
 
-# reset master
-connection master;
-DELETE FROM cluster_replication.binlog_index;
-
 # get some data on the master
 connection master;
 CREATE TABLE t1 (c1 BIT(1) NOT NULL, c2 BIT(1) NOT NULL, c3 CHAR(15), PRIMARY KEY(c3)) ENGINE = NDB ;
@@ -105,3 +100,16 @@
 --sleep 2
 connection slave;
 STOP SLAVE;
+
+#
+# Test some replication commands
+#
+connection master;
+reset master;
+# should now contain nothing
+select * from cluster_replication.binlog_index;
+
+connection slave;
+reset slave;
+# should now contain nothing
+select * from cluster_replication.apply_status;
Thread
bk commit into 5.1 tree (tomas:1.1931)tomas3 Jun