summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorAndrei Elkin <aelkin@mysql.com>2010-02-25 12:39:43 +0200
committerAndrei Elkin <aelkin@mysql.com>2010-02-25 12:39:43 +0200
commit9a29bd543e664e87a923e0e1529223cefc6607f9 (patch)
tree64c3db88d6dbc8eb09d5225cb3405ac7e190506a /mysql-test
parent6f78ef71d485fb3968355941860d012fc17a9c59 (diff)
downloadmariadb-git-9a29bd543e664e87a923e0e1529223cefc6607f9.tar.gz
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.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/include/test_fieldsize.inc2
-rw-r--r--mysql-test/suite/rpl/r/rpl_show_slave_running.result42
-rw-r--r--mysql-test/suite/rpl/t/rpl_show_slave_running.test76
3 files changed, 119 insertions, 1 deletions
diff --git a/mysql-test/include/test_fieldsize.inc b/mysql-test/include/test_fieldsize.inc
index cbe63e26318..606bc63779d 100644
--- a/mysql-test/include/test_fieldsize.inc
+++ b/mysql-test/include/test_fieldsize.inc
@@ -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
diff --git a/mysql-test/suite/rpl/r/rpl_show_slave_running.result b/mysql-test/suite/rpl/r/rpl_show_slave_running.result
new file mode 100644
index 00000000000..d8450607185
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_show_slave_running.result
@@ -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
diff --git a/mysql-test/suite/rpl/t/rpl_show_slave_running.test b/mysql-test/suite/rpl/t/rpl_show_slave_running.test
new file mode 100644
index 00000000000..9dc93ed7056
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_show_slave_running.test
@@ -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