MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Andrei Elkin Date:February 25 2010 10:39am
Subject:bzr commit into mysql-5.1-bugteam branch (aelkin:3354) Bug#51089
View as plain text  
#At file:///home/andrei/MySQL/BZR/FIXES/5.1-bt-bug51089-slave_running-backport/ based on revid:magne.mahre@stripped

 3354 Andrei Elkin	2010-02-25
      Bug #51089   SHOW STATUS LIKE 'Slave_running' is not compatible with `SHOW SLAVE STATUS' 
      
      backporting of bug@30703 to 5.1.
      The fixes are backed up with a regression test.
     @ mysql-test/include/test_fieldsize.inc
        waiting to stop is to be actually exclusively for SQL thread.
     @ mysql-test/suite/rpl/r/rpl_show_slave_running.result
        new results file is added.
     @ mysql-test/suite/rpl/t/rpl_show_slave_running.test
        regression test for bug#30703 is added.
     @ sql/mysqld.cc
        refining `show status like slave_running' handler to correspond to one of
        `show slave status'.
     @ sql/slave.cc
        A dbug-sync point is added to complement the regression test.

    added:
      mysql-test/suite/rpl/r/rpl_show_slave_running.result
      mysql-test/suite/rpl/t/rpl_show_slave_running.test
    modified:
      mysql-test/include/test_fieldsize.inc
      sql/mysqld.cc
      sql/slave.cc
=== modified file 'mysql-test/include/test_fieldsize.inc'
--- a/mysql-test/include/test_fieldsize.inc	2007-08-10 16:48:01 +0000
+++ b/mysql-test/include/test_fieldsize.inc	2010-02-25 10:39:43 +0000
@@ -22,7 +22,7 @@ eval $test_insert;
 
 connection slave;
 START SLAVE;
-wait_for_slave_to_stop;
+--source include/wait_for_slave_sql_to_stop.inc
 --replace_result $MASTER_MYPORT MASTER_PORT
 --replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
 --query_vertical SHOW SLAVE STATUS

=== added file 'mysql-test/suite/rpl/r/rpl_show_slave_running.result'
--- a/mysql-test/suite/rpl/r/rpl_show_slave_running.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_show_slave_running.result	2010-02-25 10:39:43 +0000
@@ -0,0 +1,42 @@
+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
+SELECT GET_LOCK("debug_lock.before_get_running_status_yes", 1000);
+GET_LOCK("debug_lock.before_get_running_status_yes", 1000)
+1
+set global debug= 'd,debug_lock.before_get_running_status_yes';
+Slave_running, Slave_IO_Running, Slave_SQL_Running, must be OFF, NO, NO in three following queries
+SHOW STATUS LIKE 'Slave_running';
+Variable_name	Value
+Slave_running	OFF
+Slave_IO_Running= No
+Slave_IO_Running= No
+start slave io_thread;
+Slave_running, Slave_IO_Running, Slave_SQL_Running must be OFF NO NO in three following queries
+SHOW STATUS LIKE 'Slave_running';
+Variable_name	Value
+Slave_running	OFF
+Slave_IO_Running= No
+Slave_IO_Running= No
+SELECT RELEASE_LOCK("debug_lock.before_get_running_status_yes");
+RELEASE_LOCK("debug_lock.before_get_running_status_yes")
+1
+Slave_running, Slave_IO_Running, Slave_SQL_Running must be OFF YES NO in three following queries
+SHOW STATUS LIKE 'Slave_running';
+Variable_name	Value
+Slave_running	OFF
+Slave_IO_Running= Yes
+Slave_IO_Running= No
+start slave sql_thread;
+Slave_running, Slave_IO_Running, Slave_SQL_Running must be ON, YES, YES in three following queries
+SHOW STATUS LIKE 'Slave_running';
+Variable_name	Value
+Slave_running	ON
+Slave_IO_Running= Yes
+Slave_IO_Running= Yes
+set global debug= '';
+End of tests

=== added file 'mysql-test/suite/rpl/t/rpl_show_slave_running.test'
--- a/mysql-test/suite/rpl/t/rpl_show_slave_running.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_show_slave_running.test	2010-02-25 10:39:43 +0000
@@ -0,0 +1,76 @@
+#
+# Bug #30703  SHOW STATUS LIKE 'Slave_running' is not compatible with `SHOW SLAVE STATUS'
+# The test verifies that  SHOW STATUS LIKE 'Slave_running' displays ON
+# if and only if `SHOW SLAVE STATUS' displays YES for Slave_IO_Running and  Slave_SQL_Running
+#
+source include/master-slave.inc;
+source include/have_debug.inc;
+
+connection slave;
+
+source include/stop_slave.inc;
+let $debug_saved= `select @@global.debug`;
+let $debug_lock= "debug_lock.before_get_running_status_yes";
+eval SELECT GET_LOCK($debug_lock, 1000);
+set global debug= 'd,debug_lock.before_get_running_status_yes';
+
+# Test 1. Slave is stopped
+
+--echo Slave_running, Slave_IO_Running, Slave_SQL_Running, must be OFF, NO, NO in three following queries
+
+SHOW STATUS LIKE 'Slave_running';
+let $status= query_get_value("show slave status", Slave_IO_Running, 1);
+echo Slave_IO_Running= $status;
+let $status= query_get_value("show slave status", Slave_SQL_Running, 1);
+echo Slave_IO_Running= $status;
+
+# Test 2. The slave IO thread is started but not yet got connected to master
+#         and SQL thread is not started
+
+start slave io_thread;
+
+--echo Slave_running, Slave_IO_Running, Slave_SQL_Running must be OFF NO NO in three following queries
+
+SHOW STATUS LIKE 'Slave_running';
+let $status= query_get_value("show slave status", Slave_IO_Running, 1);
+echo Slave_IO_Running= $status;
+let $status= query_get_value("show slave status", Slave_SQL_Running, 1);
+echo Slave_IO_Running= $status;
+
+# Test 3. The slave IO thread is started and got connected to master
+#         and SQL thread is still not started
+
+eval SELECT RELEASE_LOCK($debug_lock);
+let $slave_param= Slave_IO_Running;
+let $slave_param_value= YES;
+source include/wait_for_slave_param.inc;
+
+--echo Slave_running, Slave_IO_Running, Slave_SQL_Running must be OFF YES NO in three following queries
+
+SHOW STATUS LIKE 'Slave_running';
+let $status= query_get_value("show slave status", Slave_IO_Running, 1);
+echo Slave_IO_Running= $status;
+let $status= query_get_value("show slave status", Slave_SQL_Running, 1);
+echo Slave_IO_Running= $status;
+
+# Test 4. The slave IO thread is started and got connected to master
+#         and SQL thread is started
+
+start slave sql_thread;
+source include/wait_for_slave_sql_to_start.inc;
+
+--echo Slave_running, Slave_IO_Running, Slave_SQL_Running must be ON, YES, YES in three following queries
+
+SHOW STATUS LIKE 'Slave_running';
+let $status= query_get_value("show slave status", Slave_IO_Running, 1);
+echo Slave_IO_Running= $status;
+let $status= query_get_value("show slave status", Slave_SQL_Running, 1);
+echo Slave_IO_Running= $status;
+
+# cleanup
+
+connection slave;
+
+eval set global debug= '$debug_saved';
+
+--echo End of tests

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-02-05 12:55:20 +0000
+++ b/sql/mysqld.cc	2010-02-25 10:39:43 +0000
@@ -7162,7 +7162,8 @@ static int show_slave_running(THD *thd, 
   var->type= SHOW_MY_BOOL;
   pthread_mutex_lock(&LOCK_active_mi);
   var->value= buff;
-  *((my_bool *)buff)= (my_bool) (active_mi && active_mi->slave_running &&
+  *((my_bool *)buff)= (my_bool) (active_mi && 
+                                 active_mi->slave_running == MYSQL_SLAVE_RUN_CONNECT &&
                                  active_mi->rli.slave_running);
   pthread_mutex_unlock(&LOCK_active_mi);
   return 0;

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2009-12-14 16:32:22 +0000
+++ b/sql/slave.cc	2010-02-25 10:39:43 +0000
@@ -2557,6 +2557,7 @@ pthread_handler_t handle_slave_io(void *
 
 connected:
 
+  DBUG_SYNC_POINT("debug_lock.before_get_running_status_yes", 10);
   // TODO: the assignment below should be under mutex (5.0)
   mi->slave_running= MYSQL_SLAVE_RUN_CONNECT;
   thd->slave_net = &mysql->net;


Attachment: [text/bzr-bundle] bzr/aelkin@mysql.com-20100225103943-ho5car2k7mpnyg7i.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (aelkin:3354) Bug#51089Andrei Elkin25 Feb
  • Re: bzr commit into mysql-5.1-bugteam branch (aelkin:3354) Bug#51089Luís Soares25 Feb