summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlfranio Correia <alfranio.correia@oracle.com>2011-07-18 18:18:03 +0100
committerAlfranio Correia <alfranio.correia@oracle.com>2011-07-18 18:18:03 +0100
commite94de17f951582de66e6dad29b1304506daf4305 (patch)
tree045e03de93e7d0ce497903a3edb125a6b87f45d4 /sql
parent25df755040116e3bc95c3d21cbabf0bbe309aa00 (diff)
downloadmariadb-git-e94de17f951582de66e6dad29b1304506daf4305.tar.gz
BUG#11809016 - NO WAY TO DISCOVER AN INSTANCE IS NO LONGER A SLAVE FOLLOWING MYSQL BUG#28796
Before BUG#28796, an empty host was used to identify that an instance was no longer a slave. However, BUG#28796 changed this behavior and one cannot set an empty host. Besides, a RESET SLAVE only cleans up information on the next event to retrieve from the master, disables ssl and resets heartbeat period. So a call to SHOW SLAVE STATUS after issuing a RESET SLAVE still returns some valid information, such as host, port, user and password. To fix this problem, we have introduced the command RESET SLAVE ALL that does what a regular RESET SLAVE does and also clears host, port, user and password information thus allowing users to identify when an instance is no longer a slave.
Diffstat (limited to 'sql')
-rw-r--r--sql/rpl_mi.cc14
-rw-r--r--sql/rpl_mi.h2
-rw-r--r--sql/sql_lex.h5
-rw-r--r--sql/sql_repl.cc5
-rw-r--r--sql/sql_yacc.yy6
5 files changed, 28 insertions, 4 deletions
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index d1fd6bac41c..0060bcb6b1e 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -31,6 +31,8 @@ int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
int init_floatvar_from_file(float* var, IO_CACHE* f, float default_val);
int init_dynarray_intvar_from_file(DYNAMIC_ARRAY* arr, IO_CACHE* f);
+static void init_master_log_pos(Master_info* mi);
+
Master_info::Master_info(bool is_slave_recovery)
:Slave_reporting_capability("I/O"),
ssl(0), ssl_verify_server_cert(0), fd(-1), io_thd(0),
@@ -100,6 +102,16 @@ bool Master_info::shall_ignore_server_id(ulong s_id)
!= NULL;
}
+void Master_info::clear_in_memory_info(bool all)
+{
+ init_master_log_pos(this);
+ if (all)
+ {
+ port= MYSQL_PORT;
+ host[0] = 0; user[0] = 0; password[0] = 0;
+ }
+}
+
void init_master_log_pos(Master_info* mi)
{
DBUG_ENTER("init_master_log_pos");
@@ -234,7 +246,7 @@ file '%s')", fname);
}
mi->fd = fd;
- init_master_log_pos(mi);
+ mi->clear_in_memory_info(false);
}
else // file exists
diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h
index 2e06d3e8b94..1434ba45519 100644
--- a/sql/rpl_mi.h
+++ b/sql/rpl_mi.h
@@ -62,6 +62,7 @@ class Master_info : public Slave_reporting_capability
Master_info(bool is_slave_recovery);
~Master_info();
bool shall_ignore_server_id(ulong s_id);
+ void clear_in_memory_info(bool all);
/* the variables below are needed because we can change masters on the fly */
char master_log_name[FN_REFLEN];
@@ -113,7 +114,6 @@ class Master_info : public Slave_reporting_capability
DYNAMIC_ARRAY ignore_server_ids;
ulong master_id;
};
-void init_master_log_pos(Master_info* mi);
int init_master_info(Master_info* mi, const char* master_info_fname,
const char* slave_info_fname,
bool abort_if_no_master_info_file,
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index accbd78246e..d3b0f578007 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -294,6 +294,10 @@ typedef struct st_lex_master_info
DYNAMIC_ARRAY repl_ignore_server_ids;
} LEX_MASTER_INFO;
+typedef struct st_lex_reset_slave
+{
+ bool all;
+} LEX_RESET_SLAVE;
enum sub_select_type
{
@@ -2232,6 +2236,7 @@ struct LEX: public Query_tables_list
LEX_MASTER_INFO mi; // used by CHANGE MASTER
LEX_SERVER_OPTIONS server_options;
USER_RESOURCES mqh;
+ LEX_RESET_SLAVE reset_slave_info;
ulong type;
/*
This variable is used in post-parse stage to declare that sum-functions,
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 001c4cec678..8653607263f 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1285,8 +1285,9 @@ int reset_slave(THD *thd, Master_info* mi)
goto err;
}
- /* Clear master's log coordinates */
- init_master_log_pos(mi);
+ /* Clear master's log coordinates and associated information */
+ mi->clear_in_memory_info(thd->lex->reset_slave_info.all);
+
/*
Reset errors (the idea is that we forget about the
old master).
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 564250a9bf2..90a55471792 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -11337,10 +11337,16 @@ reset_options:
reset_option:
SLAVE { Lex->type|= REFRESH_SLAVE; }
+ slave_reset_options { }
| MASTER_SYM { Lex->type|= REFRESH_MASTER; }
| QUERY_SYM CACHE_SYM { Lex->type|= REFRESH_QUERY_CACHE;}
;
+slave_reset_options:
+ /* empty */ { Lex->reset_slave_info.all= false; }
+ | ALL { Lex->reset_slave_info.all= true; }
+ ;
+
purge:
PURGE
{