MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Luis Soares Date:July 28 2010 6:09pm
Subject:bzr commit into mysql-trunk-bugfixing branch (luis.soares:3156)
View as plain text  
#At file:///home/lsoares/Workspace/bzr/work/bugfixing/44209/mysql-trunk-bugfixing-vanilla/ based on revid:davi.arnaut@stripped

 3156 Luis Soares	2010-07-28
      Adds one entry in the error log for every reconnection attempt
      that failed. Also, prints the current number of reconnection 
      attempts.
     @ mysql-test/suite/rpl/t/rpl_master_retry_count.test
        Just a sketch of a test case to demonstrate that master-retry-count=0
        makes the server to try to reconnect "ad eternum":
        
        On shell #1:
        mysql-test> ./mtr --mysqld=--master-retry-count=0 rpl_master_retry_count
        
        On shell #2:
        mysql-test> tail -f var/log/mysqld.2.err
     @ sql/slave.cc
        try_to_reconnect - depoyed some debug calls
        connect_to_master - prints an error for every failed reconnection 
                            attempt

    added:
      mysql-test/suite/rpl/t/rpl_master_retry_count.test
    modified:
      sql/slave.cc
=== added file 'mysql-test/suite/rpl/t/rpl_master_retry_count.test'
--- a/mysql-test/suite/rpl/t/rpl_master_retry_count.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_master_retry_count.test	2010-07-28 18:09:11 +0000
@@ -0,0 +1,34 @@
+-- source include/master-slave.inc
+
+#
+# On the slave we set it to wait 1 second before retrying to
+# connect.
+# 
+-- connection slave
+-- source include/stop_slave.inc
+CHANGE MASTER TO  master_connect_retry=1;
+-- source include/start_slave.inc
+
+#
+# We then shutdown the master
+# 
+-- connection master
+--echo ### stop slave server
+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+wait
+EOF
+--shutdown_server 10
+--source include/wait_until_disconnected.inc
+
+-- connection slave
+
+#
+# Sleep 1000 seconds
+# Now on the command line tail the slave's error log:
+# tail -f var/log/mysqld.2.err
+#
+-- sleep 1000
+
+#--query_vertical SHOW SLAVE STATUS
+
+-- exit

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2010-07-23 20:13:36 +0000
+++ b/sql/slave.cc	2010-07-28 18:09:11 +0000
@@ -2627,6 +2627,7 @@ static int try_to_reconnect(THD *thd, MY
                             uint *retry_count, bool suppress_warnings,
                             const char *messages[SLAVE_RECON_MSG_MAX])
 {
+  DBUG_ENTER("try_to_reconnect");
   mi->slave_running= MYSQL_SLAVE_RUN_NOT_CONNECT;
   thd->proc_info= messages[SLAVE_RECON_MSG_WAIT];
 #ifdef SIGNAL_WITH_VIO_CLOSE  
@@ -2636,12 +2637,12 @@ static int try_to_reconnect(THD *thd, MY
   if ((*retry_count)++)
   {
     if (*retry_count > master_retry_count)
-      return 1;                             // Don't retry forever
+      DBUG_RETURN(1);                             // Don't retry forever
     safe_sleep(thd, mi->connect_retry, (CHECK_KILLED_FUNC) io_slave_killed,
                (void *) mi);
   }
   if (check_io_slave_killed(thd, mi, messages[SLAVE_RECON_MSG_KILLED_WAITING]))
-    return 1;
+    DBUG_RETURN(1);
   thd->proc_info = messages[SLAVE_RECON_MSG_AFTER];
   if (!suppress_warnings) 
   {
@@ -2667,9 +2668,9 @@ static int try_to_reconnect(THD *thd, MY
   {
     if (global_system_variables.log_warnings)
       sql_print_information("%s", messages[SLAVE_RECON_MSG_KILLED_AFTER]);
-    return 1;
+    DBUG_RETURN(1);
   }
-  return 0;
+  DBUG_RETURN(0);
 }
 
 
@@ -4208,6 +4209,12 @@ static int connect_to_master(THD* thd, M
                  mi->user, mi->host, mi->port,
                  mi->connect_retry, master_retry_count);
     }
+    else
+      sql_print_error("error %s to master '%s@%s:%d' - retry-time: %d  retries: %lu", 
+                      (reconnect ? "reconnecting" : "connecting"),
+                      mi->user, mi->host, mi->port,
+                      mi->connect_retry, err_count+1);
+
     /*
       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


Attachment: [text/bzr-bundle] bzr/luis.soares@sun.com-20100728180911-xbtdz7nuawfqv3of.bundle
Thread
bzr commit into mysql-trunk-bugfixing branch (luis.soares:3156)Luis Soares28 Jul