Commit c23aee47 authored by Andrei Elkin's avatar Andrei Elkin

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.
parent a341ec74
...@@ -22,7 +22,7 @@ eval $test_insert; ...@@ -22,7 +22,7 @@ eval $test_insert;
connection slave; connection slave;
START SLAVE; START SLAVE;
wait_for_slave_to_stop; --source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 # --replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
......
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
#
# 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
...@@ -7162,7 +7162,8 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff) ...@@ -7162,7 +7162,8 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff)
var->type= SHOW_MY_BOOL; var->type= SHOW_MY_BOOL;
pthread_mutex_lock(&LOCK_active_mi); pthread_mutex_lock(&LOCK_active_mi);
var->value= buff; 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); active_mi->rli.slave_running);
pthread_mutex_unlock(&LOCK_active_mi); pthread_mutex_unlock(&LOCK_active_mi);
return 0; return 0;
......
...@@ -2557,6 +2557,7 @@ pthread_handler_t handle_slave_io(void *arg) ...@@ -2557,6 +2557,7 @@ pthread_handler_t handle_slave_io(void *arg)
connected: connected:
DBUG_SYNC_POINT("debug_lock.before_get_running_status_yes", 10);
// TODO: the assignment below should be under mutex (5.0) // TODO: the assignment below should be under mutex (5.0)
mi->slave_running= MYSQL_SLAVE_RUN_CONNECT; mi->slave_running= MYSQL_SLAVE_RUN_CONNECT;
thd->slave_net = &mysql->net; thd->slave_net = &mysql->net;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment