List:Internals« Previous MessageNext Message »
From:sasha Date:October 11 2001 7:54pm
Subject:bk commit into 4.0 tree
View as plain text  
Below is the list of changes that have just been committed into a
4.0 repository of sasha. When sasha does a push, they will be propogated 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://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet@stripped, 2001-10-11 13:54:06-06:00, sasha@stripped
  fixes for mysql-test to run without manager
  a bit more work on failsafe replication

  sql/repl_failsafe.h
    1.3 01/10/11 13:54:05 sasha@stripped +4 -1
    more work

  sql/slave.cc
    1.131 01/10/11 13:54:05 sasha@stripped +10 -1
    update replication status for fail-safe replication on different events

  client/mysqltest.c
    1.65 01/10/11 13:54:04 sasha@stripped +13 -2
    added require_manager support

  mysql-test/mysql-test-run.sh
    1.112 01/10/11 13:54:04 sasha@stripped +33 -2
    added --no-manager

  mysql-test/r/rpl_failsafe.result
    1.4 01/10/11 13:54:04 sasha@stripped +7 -3
    updated result

  mysql-test/t/rpl000018.test
    1.4 01/10/11 13:54:04 sasha@stripped +1 -0
    must have manager

  mysql-test/t/rpl_failsafe.test
    1.4 01/10/11 13:54:04 sasha@stripped +9 -0
    must have manager

  sql/repl_failsafe.cc
    1.3 01/10/11 13:54:04 sasha@stripped +7 -0
    more work

# 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:	sasha
# Host:	mysql.sashanet.com
# Root:	/home/sasha/src/bk/mysql-4.0

--- 1.111/mysql-test/mysql-test-run.sh	Wed Oct 10 15:36:34 2001
+++ 1.112/mysql-test/mysql-test-run.sh	Thu Oct 11 13:54:04 2001
@@ -12,6 +12,7 @@
 DB=test
 DBPASSWD=
 VERBOSE=""
+NO_MANAGER=""
 TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work
 
 #++
@@ -162,6 +163,9 @@
      --ssl-ca=$BASEDIR/SSL/cacert.pem \
      --ssl-cert=$BASEDIR/SSL/server-cert.pem \
      --ssl-key=$BASEDIR/SSL/server-key.pem" ;;
+    --no-manager)
+     NO_MANAGER=1
+     ;;
     --skip-innobase)
      EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-innobase"
      EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-innobase" ;;
@@ -476,6 +480,7 @@
     
     for slave_num in 1 2 ;
     do
+     rm -rf var/slave$slave_num-data/
      mkdir -p var/slave$slave_num-data/mysql
      mkdir -p var/slave$slave_num-data/test
      cp var/slave-data/mysql/* var/slave$slave_num-data/mysql
@@ -533,6 +538,11 @@
 
 start_manager()
 {
+ if [ -n "$NO_MANAGER" ] ; then
+  echo "Manager disabled, skipping manager start. Tests requiring manager will\
+ be skipped"
+  return
+ fi
  MYSQL_MANAGER_PW=`$MYSQL_MANAGER_PWGEN -u $MYSQL_MANAGER_USER \
  -o $MYSQL_MANAGER_PW_FILE`
  $MYSQL_MANAGER --log=$MYSQL_MANAGER_LOG --port=$MYSQL_MANAGER_PORT \
@@ -550,6 +560,9 @@
 
 stop_manager()
 {
+ if [ -n "$NO_MANAGER" ] ; then
+  return
+ fi
  $MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT -u$MYSQL_MANAGER_USER \
   -p$MYSQL_MANAGER_PW -P $MYSQL_MANAGER_PORT <<EOF
 shutdown
@@ -560,6 +573,11 @@
 {
   ident=$1
   shift
+  if [ -n "$NO_MANAGER" ] ; then
+   $@  >$CUR_MYERR 2>&1  &
+   sleep 2 #hack 
+   return
+  fi
   $MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \
    --password=$MYSQL_MANAGER_PW  --port=$MYSQL_MANAGER_PORT <<EOF
 def_exec $ident $@
@@ -575,6 +593,11 @@
 {
   ident=$1
   shift
+  if [ -n "$NO_MANAGER" ] ; then
+   $MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$ident.sock -O \
+   connect_timeout=5 shutdown >/dev/null 2>&1
+   return
+  fi
   $MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \
    --password=$MYSQL_MANAGER_PW  --port=$MYSQL_MANAGER_PORT <<EOF
 stop_exec $ident $STOP_WAIT_TIMEOUT
@@ -841,7 +864,10 @@
  slave_init_script=$TESTDIR/$tname-slave.sh
  slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt
  SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
- many_slaves=`$EXPR \( $tname : rpl_failsafe \) != 0`
+ if [ -z "$NO_MANAGER" ] ; then
+  many_slaves=`$EXPR \( $tname : rpl_failsafe \) != 0`
+ fi 
+ 
  if [ -n "$SKIP_TEST" ] ; then 
    SKIP_THIS_TEST=`$EXPR \( $tname : "$SKIP_TEST" \) != 0`
    if [ x$SKIP_THIS_TEST = x1 ] ;
@@ -952,7 +978,12 @@
     timestr="$USERT $SYST $REALT"
     pname=`$ECHO "$tname                        "|$CUT -c 1-24`
     RES="$pname  $timestr"
-
+    
+    if [ x$many_slaves = x1 ] ; then
+     stop_slave 1
+     stop_slave 2
+    fi
+    
     if [ $res = 0 ]; then
       total_inc
       pass_inc

--- 1.130/sql/slave.cc	Sun Oct  7 04:26:03 2001
+++ 1.131/sql/slave.cc	Thu Oct 11 13:54:05 2001
@@ -21,6 +21,7 @@
 #include "mini_client.h"
 #include "slave.h"
 #include "sql_repl.h"
+#include "repl_failsafe.h"
 #include <thr_alarm.h>
 #include <my_dir.h>
 
@@ -1220,6 +1221,7 @@
   thd->proc_info = "Waiting for slave mutex on exit";
   pthread_mutex_lock(&LOCK_slave);
   slave_running = 0;
+  change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
   abort_slave = 0;
   save_temporary_tables = thd->temporary_tables;
   thd->temporary_tables = 0; // remove tempation from destructor to close them
@@ -1257,6 +1259,7 @@
   
   if(!slave_was_killed)
     {
+      change_rpl_status(RPL_IDLE_SLAVE,RPL_ACTIVE_SLAVE);
       mysql_log.write(thd, COM_CONNECT_OUT, "%s@%s:%d",
 		  mi->user, mi->host, mi->port);
 #ifdef SIGNAL_WITH_VIO_CLOSE
@@ -1298,9 +1301,15 @@
 		      mi->connect_retry);
       safe_sleep(thd, mi->connect_retry);
     }
-    if (err_count++ == master_retry_count)
+    /* by default we try forever. The reason is that failure will trigger
+       master election, so if the user did not set master_retry_count we
+       do not want to have electioin triggered on the first failure to
+       connect
+    */
+    if (master_retry_count && err_count++ == master_retry_count)
     {
       slave_was_killed=1;
+      change_rpl_status(RPL_ACTIVE_SLAVE,RPL_LOST_SOLDIER);
       break;
     }
   }

--- 1.64/client/mysqltest.c	Wed Oct 10 15:36:34 2001
+++ 1.65/client/mysqltest.c	Thu Oct 11 13:54:04 2001
@@ -181,7 +181,7 @@
 Q_RPL_PROBE,        Q_ENABLE_RPL_PARSE,
 Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
 Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
-Q_SERVER_START, Q_SERVER_STOP,
+Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER,
 Q_UNKNOWN,                             /* Unknown command.   */
 Q_COMMENT,                             /* Comments, ignored. */
 Q_COMMENT_WITH_COMMAND
@@ -215,6 +215,7 @@
   "disable_rpl_parse", "eval_result",
   "enable_query_log", "disable_query_log",
   "server_start", "server_stop",
+  "require_manager",
   0
 };
 
@@ -640,6 +641,13 @@
   return 0;
 }
 
+int do_require_manager(struct st_query* __attribute__((unused)) q)
+{
+  if (!manager)
+    abort_not_supported_test();
+  return 0;
+}
+
 #ifndef EMBEDDED_LIBRARY
 int do_server_start(struct st_query* q)
 {
@@ -1930,7 +1938,9 @@
     ds= &ds_res;
   
   if ((flags & QUERY_SEND) && mysql_send_query(mysql, query, query_len))
-    die("At line %u: unable to send query '%s'", start_lineno, query);
+    die("At line %u: unable to send query '%s'(mysql_errno=%d,errno=%d)",
+	start_lineno, query,
+	mysql_errno(mysql), errno);
   if ((flags & QUERY_SEND) && !disable_query_log)
   {
     dynstr_append_mem(ds,query,query_len);
@@ -2236,6 +2246,7 @@
       case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
       case Q_SOURCE: do_source(q); break;
       case Q_SLEEP: do_sleep(q); break;
+      case Q_REQUIRE_MANAGER: do_require_manager(q); break;
 #ifndef EMBEDDED_LIBRARY	
       case Q_SERVER_START: do_server_start(q); break;
       case Q_SERVER_STOP: do_server_stop(q); break;

--- 1.3/mysql-test/r/rpl_failsafe.result	Wed Oct 10 15:36:34 2001
+++ 1.4/mysql-test/r/rpl_failsafe.result	Thu Oct 11 13:54:04 2001
@@ -9,21 +9,25 @@
 show status like 'Rpl_status';
 Variable_name	Value
 Rpl_status	AUTH_MASTER
+create table t1(n int);
+drop table t1;
 show variables like 'rpl_recovery_rank';
 Variable_name	Value
 rpl_recovery_rank	2
 show status like 'Rpl_status';
 Variable_name	Value
-Rpl_status	IDLE_SLAVE
+Rpl_status	ACTIVE_SLAVE
+slave start;
 show variables like 'rpl_recovery_rank';
 Variable_name	Value
 rpl_recovery_rank	3
 show status like 'Rpl_status';
 Variable_name	Value
-Rpl_status	IDLE_SLAVE
+Rpl_status	ACTIVE_SLAVE
+slave start;
 show variables like 'rpl_recovery_rank';
 Variable_name	Value
 rpl_recovery_rank	4
 show status like 'Rpl_status';
 Variable_name	Value
-Rpl_status	IDLE_SLAVE
+Rpl_status	ACTIVE_SLAVE

--- 1.3/mysql-test/t/rpl000018.test	Sun Oct  7 20:36:35 2001
+++ 1.4/mysql-test/t/rpl000018.test	Thu Oct 11 13:54:04 2001
@@ -1,3 +1,4 @@
+require_manager;
 connect (master,localhost,root,,test,0,master.sock);
 connect (slave,localhost,root,,test,0,slave.sock);
 server_stop master;

--- 1.3/mysql-test/t/rpl_failsafe.test	Wed Oct 10 15:36:34 2001
+++ 1.4/mysql-test/t/rpl_failsafe.test	Thu Oct 11 13:54:04 2001
@@ -1,15 +1,24 @@
+require_manager;
 source include/master-slave.inc;
 connect (slave_sec,localhost,root,,test,0,slave.sock-1); 
 connect (slave_ter,localhost,root,,test,0,slave.sock-2); 
 connection master;
 show variables like 'rpl_recovery_rank';
 show status like 'Rpl_status';
+create table t1(n int);
+drop table t1;
+save_master_pos;
 connection slave;
+sync_with_master;
 show variables like 'rpl_recovery_rank';
 show status like 'Rpl_status';
 connection slave_sec;
+slave start;
+sync_with_master;
 show variables like 'rpl_recovery_rank';
 show status like 'Rpl_status';
 connection slave_ter;
+slave start;
+sync_with_master;
 show variables like 'rpl_recovery_rank';
 show status like 'Rpl_status';

--- 1.2/sql/repl_failsafe.cc	Wed Oct 10 15:36:34 2001
+++ 1.3/sql/repl_failsafe.cc	Thu Oct 11 13:54:04 2001
@@ -33,4 +33,11 @@
 TYPELIB rpl_status_typelib= {array_elements(rpl_status_type)-1,"",
 			     rpl_status_type};
 
+void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status)
+{
+  pthread_mutex_lock(&LOCK_rpl_status);
+  if (rpl_status == from_status || rpl_status == RPL_ANY)
+    rpl_status = to_status;
+  pthread_mutex_unlock(&LOCK_rpl_status);
+}
 

--- 1.2/sql/repl_failsafe.h	Wed Oct 10 15:36:34 2001
+++ 1.3/sql/repl_failsafe.h	Thu Oct 11 13:54:05 2001
@@ -3,11 +3,14 @@
 
 typedef enum {RPL_AUTH_MASTER=0,RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE,
 	      RPL_LOST_SOLDIER,RPL_TROOP_SOLDIER,
-	      RPL_RECOVERY_CAPTAIN,RPL_NULL} RPL_STATUS;
+	      RPL_RECOVERY_CAPTAIN,RPL_NULL /* inactive */,
+	      RPL_ANY /* wild card used by change_rpl_status */ } RPL_STATUS;
 extern RPL_STATUS rpl_status;
 
 extern pthread_mutex_t LOCK_rpl_status;
 extern pthread_cond_t COND_rpl_status;
 extern TYPELIB rpl_role_typelib, rpl_status_typelib;
 extern const char* rpl_role_type[], *rpl_status_type[];
+
+void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status);
 #endif
Thread
bk commit into 4.0 treesasha11 Oct