Commit a4982223 authored by unknown's avatar unknown

Do not give an error when the user does START SLAVE on an already

running slave, just give a warning. Same thing for STOP SLAVE.
This will make scripts writing easier for users.


include/mysqld_error.h:
  New error codes (warning codes in fact) to warn that the slave was already started or stopped
mysql-test/include/master-slave.inc:
  STOP SLAVE now prints a warning, not an error, so we should expect a warning here
sql/share/czech/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/danish/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/dutch/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/english/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/estonian/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/french/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/german/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/greek/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/hungarian/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/italian/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/japanese/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/korean/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/norwegian-ny/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/norwegian/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/polish/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/portuguese/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/romanian/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/russian/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/serbian/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/slovak/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/spanish/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/swedish/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/share/ukrainian/errmsg.txt:
  New messages to warn that the slave was already started or stopped
sql/sql_repl.cc:
  Do not give an error when the user does START SLAVE on an already
  running slave, just give a warning. Same thing for STOP SLAVE.
parent c68620e6
......@@ -268,4 +268,6 @@
#define ER_NOT_SUPPORTED_AUTH_MODE 1249
#define ER_SPATIAL_CANT_HAVE_NULL 1250
#define ER_COLLATION_CHARSET_MISMATCH 1251
#define ER_ERROR_MESSAGES 252
#define ER_SLAVE_WAS_RUNNING 1252
#define ER_SLAVE_WAS_NOT_RUNNING 1253
#define ER_ERROR_MESSAGES 254
......@@ -3,8 +3,11 @@ connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,);
connection slave;
--error 0,1199
!stop slave;
#we expect STOP SLAVE to produce a warning as the slave is stopped
#(the server was started with skip-slave-start)
--disable_warnings
stop slave;
--enable_warnings
@r/slave-stopped.result show status like 'Slave_running';
connection master;
--disable_warnings
......
......@@ -262,3 +262,5 @@ v/*
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -256,3 +256,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -264,3 +264,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -253,3 +253,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -258,3 +258,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -253,3 +253,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -263,3 +263,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client",
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -253,3 +253,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -255,3 +255,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -253,3 +253,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -255,3 +255,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -253,3 +253,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -255,3 +255,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -255,3 +255,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -257,3 +257,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -253,3 +253,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -257,3 +257,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -256,3 +256,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -249,3 +249,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -261,3 +261,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -254,3 +254,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -253,3 +253,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -258,3 +258,5 @@
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"All parts of a SPATIAL KEY must be NOT NULL"
"COLLATION '%s' is not valid for CHARACTER SET '%s'"
"The slave was already running"
"The slave was already stopped"
......@@ -622,7 +622,7 @@ Increase max_allowed_packet on master";
int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
{
int slave_errno = 0;
int slave_errno;
if (!thd)
thd = current_thd;
int thread_mask;
......@@ -631,10 +631,17 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
if (check_access(thd, SUPER_ACL, any_db))
DBUG_RETURN(1);
lock_slave_threads(mi); // this allows us to cleanly read slave_running
// Get a mask of _stopped_ threads
init_thread_mask(&thread_mask,mi,1 /* inverse */);
/*
Below we will start all stopped threads.
But if the user wants to start only one thread, do as if the other thread
was running (as we don't wan't to touch the other thread), so set the
bit to 0 for the other thread
*/
if (thd->lex.slave_thd_opt)
thread_mask &= thd->lex.slave_thd_opt;
if (thread_mask)
if (thread_mask) //some threads are stopped, start them
{
if (init_master_info(mi,master_info_file,relay_log_info_file, 0))
slave_errno=ER_MASTER_INFO;
......@@ -648,7 +655,12 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
slave_errno = ER_BAD_SLAVE;
}
else
slave_errno = ER_SLAVE_MUST_STOP;
{
//no error if all threads are already started, only a warning
slave_errno= 0;
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SLAVE_WAS_RUNNING,
ER(ER_SLAVE_WAS_RUNNING));
}
unlock_slave_threads(mi);
......@@ -667,7 +679,7 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report )
{
int slave_errno = 0;
int slave_errno;
if (!thd)
thd = current_thd;
......@@ -676,12 +688,29 @@ int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report )
thd->proc_info = "Killing slave";
int thread_mask;
lock_slave_threads(mi);
// Get a mask of _running_ threads
init_thread_mask(&thread_mask,mi,0 /* not inverse*/);
/*
Below we will stop all running threads.
But if the user wants to stop only one thread, do as if the other thread
was stopped (as we don't wan't to touch the other thread), so set the
bit to 0 for the other thread
*/
if (thd->lex.slave_thd_opt)
thread_mask &= thd->lex.slave_thd_opt;
slave_errno = (thread_mask) ?
terminate_slave_threads(mi,thread_mask,
1 /*skip lock */) : ER_SLAVE_NOT_RUNNING;
if (thread_mask)
{
slave_errno= terminate_slave_threads(mi,thread_mask,
1 /*skip lock */);
}
else
{
//no error if both threads are already stopped, only a warning
slave_errno= 0;
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SLAVE_WAS_NOT_RUNNING,
ER(ER_SLAVE_WAS_NOT_RUNNING));
}
unlock_slave_threads(mi);
thd->proc_info = 0;
......
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