Commit 66c96f2c authored by unknown's avatar unknown

Fix for BUG#3829 "Setting server_id on fly doesn't allow replication to start"

(fix by our Harrison Fisk): when one does SET GLOBAL SERVER_ID=x, we must set
server_id_supplied to 1.


sql/mysql_priv.h:
  server_id_supplied must be here to be visible in set_var.cc
sql/mysqld.cc:
  rephrasing warnings when server id is not set explicitely.
sql/set_var.cc:
  when one does SET GLOBAL SERVER_ID=x; it should be considered as explicitely setting
  the server id, so do server_id_supplied=1.
sql/slave.cc:
  Correcting wrong comment
parent efbf373b
......@@ -703,7 +703,7 @@ extern uint protocol_version,dropping_tables;
extern uint delay_key_write_options, lower_case_table_names;
extern bool opt_endinfo, using_udf_functions, locked_in_memory;
extern bool opt_using_transactions, mysql_embedded;
extern bool using_update_log, opt_large_files;
extern bool using_update_log, opt_large_files, server_id_supplied;
extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log, opt_error_log;
extern bool opt_disable_networking, opt_skip_show_db;
extern bool volatile abort_loop, shutdown_in_progress, grant_option;
......
......@@ -2354,15 +2354,15 @@ You should consider changing lower_case_table_names to 1 or 2",
#ifdef EXTRA_DEBUG
case 1:
sql_print_error("\
Warning: You have enabled the binary log, but you haven't set server-id:\n\
Updates will be logged to the binary log, but connections to slaves will\n\
not be accepted.");
Warning: You have enabled the binary log, but you haven't set server-id to \
a non-zero value: we force server id to 1; updates will be logged to the \
binary log, but connections from slaves will not be accepted.");
break;
#endif
case 2:
sql_print_error("\
Warning: You should set server-id to a non-0 value if master_host is set.\n\
The server will not act as a slave.");
Warning: You should set server-id to a non-0 value if master_host is set; \
we force server id to 2, but this MySQL server will not act as a slave.");
break;
}
}
......
......@@ -90,6 +90,7 @@ static void fix_max_relay_log_size(THD *thd, enum_var_type type);
static void fix_max_connections(THD *thd, enum_var_type type);
static void fix_thd_mem_root(THD *thd, enum_var_type type);
static void fix_trans_mem_root(THD *thd, enum_var_type type);
static void fix_server_id(THD *thd, enum_var_type type);
/*
Variable definition list
......@@ -235,7 +236,7 @@ sys_var_thd_bool
sys_query_cache_wlock_invalidate("query_cache_wlock_invalidate",
&SV::query_cache_wlock_invalidate);
#endif /* HAVE_QUERY_CACHE */
sys_var_long_ptr sys_server_id("server_id",&server_id);
sys_var_long_ptr sys_server_id("server_id", &server_id, fix_server_id);
sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol",
&opt_slave_compressed_protocol);
sys_var_long_ptr sys_slave_net_timeout("slave_net_timeout",
......@@ -811,6 +812,10 @@ static void fix_trans_mem_root(THD *thd, enum_var_type type)
thd->variables.trans_prealloc_size);
}
static void fix_server_id(THD *thd, enum_var_type type)
{
server_id_supplied = 1;
}
bool sys_var_long_ptr::update(THD *thd, set_var *var)
{
......
......@@ -143,13 +143,11 @@ int init_slave()
goto err;
}
/*
make sure slave thread gets started if server_id is set,
valid master.info is present, and master_host has not been specified
*/
if (server_id && !master_host && active_mi->host[0])
master_host= active_mi->host;
/* If server id is not set, start_slave_thread() will say it */
if (master_host && !opt_skip_slave_start)
{
if (start_slave_threads(1 /* need mutex */,
......
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