Commit a06a844d authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-4712 : Fix "shutdown" test.

There is a race condition during shutdown, that happens when "show status" runs during shutdown. 
Functions show_slave_running(), show_slave_received_heartbeats(), show_heartbeat_period() would dereference NULL pointer master_info_index, after this variable is  set to NULL in slave_end() during shutdown.
Fix introduces check for master_info_index == NULL in the affected functions.
parent 159866b6
...@@ -11,13 +11,14 @@ shutdown; ...@@ -11,13 +11,14 @@ shutdown;
connection default; connection default;
disconnect c1; disconnect c1;
--connect (c1,localhost,root,,)
--let $_server_id= `SELECT @@server_id` --let $_server_id= `SELECT @@server_id`
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
--exec echo "wait" > $_expect_file_name --exec echo "wait" > $_expect_file_name
shutdown; --send shutdown
--connection default
--source include/wait_until_disconnected.inc --source include/wait_until_disconnected.inc
--exec echo "restart" > $_expect_file_name --exec echo "restart" > $_expect_file_name
......
...@@ -6993,7 +6993,7 @@ static int show_rpl_status(THD *thd, SHOW_VAR *var, char *buff) ...@@ -6993,7 +6993,7 @@ static int show_rpl_status(THD *thd, SHOW_VAR *var, char *buff)
static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff) static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff)
{ {
Master_info *mi; Master_info *mi= NULL;
bool tmp; bool tmp;
LINT_INIT(tmp); LINT_INIT(tmp);
...@@ -7001,12 +7001,15 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff) ...@@ -7001,12 +7001,15 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff)
var->value= buff; var->value= buff;
mysql_mutex_unlock(&LOCK_status); mysql_mutex_unlock(&LOCK_status);
mysql_mutex_lock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_active_mi);
mi= master_info_index-> if (master_info_index)
get_master_info(&thd->variables.default_master_connection, {
Sql_condition::WARN_LEVEL_NOTE); mi= master_info_index->
if (mi) get_master_info(&thd->variables.default_master_connection,
tmp= (my_bool) (mi->slave_running == MYSQL_SLAVE_RUN_CONNECT && Sql_condition::WARN_LEVEL_NOTE);
mi->rli.slave_running); if (mi)
tmp= (my_bool) (mi->slave_running == MYSQL_SLAVE_RUN_CONNECT &&
mi->rli.slave_running);
}
mysql_mutex_unlock(&LOCK_active_mi); mysql_mutex_unlock(&LOCK_active_mi);
mysql_mutex_lock(&LOCK_status); mysql_mutex_lock(&LOCK_status);
if (mi) if (mi)
...@@ -7019,7 +7022,7 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff) ...@@ -7019,7 +7022,7 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff)
static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff) static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff)
{ {
Master_info *mi; Master_info *mi= NULL;
longlong tmp; longlong tmp;
LINT_INIT(tmp); LINT_INIT(tmp);
...@@ -7027,11 +7030,14 @@ static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff) ...@@ -7027,11 +7030,14 @@ static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff)
var->value= buff; var->value= buff;
mysql_mutex_unlock(&LOCK_status); mysql_mutex_unlock(&LOCK_status);
mysql_mutex_lock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_active_mi);
mi= master_info_index-> if (master_info_index)
get_master_info(&thd->variables.default_master_connection, {
Sql_condition::WARN_LEVEL_NOTE); mi= master_info_index->
if (mi) get_master_info(&thd->variables.default_master_connection,
tmp= mi->received_heartbeats; Sql_condition::WARN_LEVEL_NOTE);
if (mi)
tmp= mi->received_heartbeats;
}
mysql_mutex_unlock(&LOCK_active_mi); mysql_mutex_unlock(&LOCK_active_mi);
mysql_mutex_lock(&LOCK_status); mysql_mutex_lock(&LOCK_status);
if (mi) if (mi)
...@@ -7044,7 +7050,7 @@ static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff) ...@@ -7044,7 +7050,7 @@ static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff)
static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff) static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff)
{ {
Master_info *mi; Master_info *mi= NULL;
float tmp; float tmp;
LINT_INIT(tmp); LINT_INIT(tmp);
...@@ -7052,11 +7058,14 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff) ...@@ -7052,11 +7058,14 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff)
var->value= buff; var->value= buff;
mysql_mutex_unlock(&LOCK_status); mysql_mutex_unlock(&LOCK_status);
mysql_mutex_lock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_active_mi);
mi= master_info_index-> if (master_info_index)
get_master_info(&thd->variables.default_master_connection, {
mi= master_info_index->
get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE); Sql_condition::WARN_LEVEL_NOTE);
if (mi) if (mi)
tmp= mi->heartbeat_period; tmp= mi->heartbeat_period;
}
mysql_mutex_unlock(&LOCK_active_mi); mysql_mutex_unlock(&LOCK_active_mi);
mysql_mutex_lock(&LOCK_status); mysql_mutex_lock(&LOCK_status);
if (mi) if (mi)
......
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