List:Commits« Previous MessageNext Message »
From:Luis Soares Date:July 29 2010 1:51am
Subject:bzr commit into mysql-next-mr branch (luis.soares:3170) Bug#44209
View as plain text  
#At file:///home/lsoares/Workspace/bzr/work/MC/merge.to.next-mr/mysql-next-mr-push/ based on revid:luis.soares@stripped

 3170 Luis Soares	2010-07-29
      BUG#44209: MASTER_CONNECT_RETRY and --master-retry-count disconnected 
      from each other
      
      Improvements on the tests:
      
        1. Changed assertion when CHANGE MASTER TO master_rety_count=0;
        2. Added assertion to check that when issuing a CHANGE MASTER TO
           without specifying a value for master_retry_count, the current
           value is preserved;
        3. Added assertion checking that when feeding a negative value for
           master_retry_count, an error is raised;
     @ mysql-test/suite/rpl/t/rpl_change_master_dbug.test
        Test that asserts that slave retries N times, according to the value
        of master_retry_count, before giving up. Requires DBUG, so that's the
        reason to be placed on its own .test file.
     @ sql/rpl_slave.cc
        Deployed some conditional code so that the server always reports
        the error when it cannot connect. While reporting it includes the
        current number of attempts in the retries field, instead of the 
        mi->retry_count.

    added:
      mysql-test/suite/rpl/r/rpl_change_master_dbug.result
      mysql-test/suite/rpl/t/rpl_change_master_dbug.test
    modified:
      mysql-test/suite/rpl/r/rpl_change_master.result
      mysql-test/suite/rpl/t/rpl_change_master.test
      sql/rpl_slave.cc
=== modified file 'mysql-test/suite/rpl/r/rpl_change_master.result'
--- a/mysql-test/suite/rpl/r/rpl_change_master.result	2010-07-27 14:04:13 +0000
+++ b/mysql-test/suite/rpl/r/rpl_change_master.result	2010-07-29 01:51:38 +0000
@@ -55,15 +55,19 @@ include/stop_slave.inc
 CHANGE MASTER TO master_retry_count=10;
 include/start_slave.inc
 include/stop_slave.inc
-CHANGE MASTER TO master_retry_count=1;
+CHANGE MASTER TO master_retry_count=RETRY_COUNT_SET;
+SELECT RETRY_COUNT_EXPECTED AS current_retry_count;
+current_retry_count
+RETRY_COUNT_EXPECTED
+CHANGE MASTER TO master_connect_retry= 2;
+CHANGE MASTER TO master_connect_retry= 1;
 ### stop slave server
 ### start slave server
 include/start_slave.inc
-include/stop_slave.inc
-CHANGE MASTER TO master_retry_count=3, master_host='dummy', master_connect_retry=1;
-START SLAVE io_thread;
 CHANGE MASTER TO master_retry_count='a';
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''a'' at line 1
+CHANGE MASTER TO master_retry_count=-1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1
 stop slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 reset master;

=== added file 'mysql-test/suite/rpl/r/rpl_change_master_dbug.result'
--- a/mysql-test/suite/rpl/r/rpl_change_master_dbug.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_change_master_dbug.result	2010-07-29 01:51:38 +0000
@@ -0,0 +1,18 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+include/stop_slave.inc
+SET @old_debug= @@global.debug;
+SET GLOBAL debug="+d,connect_to_master_always_report_error";
+CHANGE MASTER TO master_retry_count=3, master_host='dummy', master_connect_retry=1;
+START SLAVE io_thread;
+SET @@global.debug= @old_debug;
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;

=== modified file 'mysql-test/suite/rpl/t/rpl_change_master.test'
--- a/mysql-test/suite/rpl/t/rpl_change_master.test	2010-07-27 14:04:13 +0000
+++ b/mysql-test/suite/rpl/t/rpl_change_master.test	2010-07-29 01:51:38 +0000
@@ -133,8 +133,9 @@ if (`SELECT $retry_count1 <> ($retry_cou
 
 -- source include/stop_slave.inc
 
-# action: change master_retry_count to zero, which should produce no change.
-CHANGE MASTER TO master_retry_count=0;
+# action: change master_retry_count to zero will set it to zero.
+-- let $retry_count1= 0
+-- eval CHANGE MASTER TO master_retry_count=$retry_count1
 
 -- source include/start_slave.inc
 
@@ -176,13 +177,37 @@ if (`SELECT $retry_count4 <> $retry_coun
   -- die
 }
 
-## Now lets change master_retry_count to 1 and stop and restart the slave 
-## to check whether master_retry_count persists or not
+## Now lets change master_retry_count to the maximum value possible
+## and stop and restart the slave to check that (in the middle of it 
+## we also check that when issueing CHANGE MASTER TO without specifying
+## master_retry_count will not affect its current value):
+##   1. master_retry_count persists after restart
+##   2. setting a value higher than the max will make the max to be set.
+##   3. maximum value is accepted and persists after serialization 
+##      and de-serialization
 -- source include/stop_slave.inc
--- let $retry_count_expected= 1
--- eval CHANGE MASTER TO master_retry_count=$retry_count_expected
+-- let $retry_count_set= 18446744073709551616
+-- replace_result 18446744073709551616 RETRY_COUNT_SET
+-- eval CHANGE MASTER TO master_retry_count=$retry_count_set
+-- let $retry_count_expected= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+-- replace_result 18446744073709551615 RETRY_COUNT_EXPECTED 4294967295 RETRY_COUNT_EXPECTED 9223372036854775807 RETRY_COUNT_EXPECTED
+-- eval SELECT $retry_count_expected AS current_retry_count
+
+## assert that issuing CHANGE MASTER without changing master_retry_count
+## does not affect the existing value for master_retry_count
+-- let $connect_retry_old= query_get_value(SHOW SLAVE STATUS, Connect_Retry, 1)
+-- let $connect_retry_new= `SELECT $connect_retry_old + 1`
+-- let $retry_count_before= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+-- eval CHANGE MASTER TO master_connect_retry= $connect_retry_new
+-- let $retry_count_after= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+if (`SELECT $retry_count_before <> $retry_count_after`)
+{
+  -- echo Unexpected retry count value! Got: $retry_count_after, expected: $retry_count_before
+  -- die
+}
+-- eval CHANGE MASTER TO master_connect_retry= $connect_retry_old
 
-# Stop master server
+## Server restart persisting test
 --echo ### stop slave server
 --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
 wait
@@ -207,27 +232,13 @@ if (`SELECT $retry_count5 <> $retry_coun
   -- die
 }
 
-## Checks that the slave actually gives up after retrying N times, where
-## N was set with CHANGE MASTER TO master_retry_count=N
-
--- source include/stop_slave.inc
-CHANGE MASTER TO master_retry_count=3, master_host='dummy', master_connect_retry=1;
-START SLAVE io_thread;
-
-# We wait for slave to stop and inspect the number of retries in 
-# the error message.
--- source include/wait_for_slave_io_to_stop.inc
--- let $error= query_get_value("SHOW SLAVE STATUS", Last_IO_Error, 1)
-if (!`SELECT "$error" LIKE "%retries: 3"`)
-{
-  -- echo Unexpected retry count value! Got: $error
-  -- echo Expected number of retries was: 3
-  -- die
-}
-
-## check that there is a parse error if not using a numerical value
+## assert that there is a parse error if not using a numerical value
 -- error ER_PARSE_ERROR
 CHANGE MASTER TO master_retry_count='a';
 
+## assert that there is a parse error if using a negative number
+-- error ER_PARSE_ERROR
+CHANGE MASTER TO master_retry_count=-1;
+
 -- source include/master-slave-reset.inc
 -- source include/master-slave-end.inc

=== added file 'mysql-test/suite/rpl/t/rpl_change_master_dbug.test'
--- a/mysql-test/suite/rpl/t/rpl_change_master_dbug.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_change_master_dbug.test	2010-07-29 01:51:38 +0000
@@ -0,0 +1,38 @@
+-- source include/master-slave.inc
+# there is no point in running this in more than one binlog format
+-- source include/have_binlog_format_row.inc
+-- source include/have_debug.inc
+
+#
+# BUG#44209: MASTER_CONNECT_RETRY and --master-retry-count disconnected from each other
+#
+# Second part of the tests. Requires debug build.
+#
+
+## Checks that the slave actually gives up after retrying N times, where
+## N was set with CHANGE MASTER TO master_retry_count=N
+
+-- connection slave
+-- source include/stop_slave.inc
+SET @old_debug= @@global.debug;
+SET GLOBAL debug="+d,connect_to_master_always_report_error";
+CHANGE MASTER TO master_retry_count=3, master_host='dummy', master_connect_retry=1;
+START SLAVE io_thread;
+
+# We wait for slave to stop and inspect the number of retries in 
+# the error message. Given that we force the slave to always report
+# the error with the err_count exported in the retries field, we should
+# get 3 retries (one per second) when the IO thread gives up, ie, 
+# when it stops.
+-- source include/wait_for_slave_io_to_stop.inc
+-- let $error= query_get_value("SHOW SLAVE STATUS", Last_IO_Error, 1)
+if (!`SELECT "$error" LIKE "%retries: 3"`)
+{
+  -- echo Unexpected retry count value! Got: $error
+  -- echo Expected number of retries was: 3
+  -- die
+}
+SET @@global.debug= @old_debug;
+
+-- source include/master-slave-reset.inc
+-- source include/master-slave-end.inc

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2010-07-29 01:21:15 +0000
+++ b/sql/rpl_slave.cc	2010-07-29 01:51:38 +0000
@@ -4513,7 +4513,9 @@ static int connect_to_master(THD* thd, M
                              mi->port, 0, client_flag) == 0))
   {
     /* Don't repeat last error */
-    if ((int)mysql_errno(mysql) != last_errno)
+    if ((int)mysql_errno(mysql) != last_errno || 
+        DBUG_EVALUATE_IF("connect_to_master_always_report_error", 
+                         TRUE, FALSE))
     {
       /*
         TODO: would be great that when issuing SHOW SLAVE STATUS
@@ -4532,7 +4534,10 @@ static int connect_to_master(THD* thd, M
                  " - retry-time: %d  retries: %lu",
                  (reconnect ? "reconnecting" : "connecting"),
                  mi->user, mi->host, mi->port,
-                 mi->connect_retry, mi->retry_count);
+                 mi->connect_retry, 
+                 DBUG_EVALUATE_IF("connect_to_master_always_report_error", 
+                                  err_count+1, 
+                                  mi->retry_count));
     }
     /*
       By default we try forever. The reason is that failure will trigger


Attachment: [text/bzr-bundle] bzr/luis.soares@sun.com-20100729015138-jhlhisy13gh5ynkc.bundle
Thread
bzr commit into mysql-next-mr branch (luis.soares:3170) Bug#44209Luis Soares29 Jul