Description:
If you set the server_id variable on the fly using:
SET GLOBAL server_id = #;
Then one can not start replication using SLAVE START; even if it is properly configured. It will always give an error saying it isn't properly configured even if it is properly setup. You can only start up replication, if you start up the server with server_id being set, not doing it on the fly.
How to repeat:
1. Start up a normal mysqld server that does not have a default server_id.
2. Setup replication by setting server_id on the fly using:
SET GLOBAL server_id = #;
3. Setup everything else needed for replication using CHANGE MASTER TO.
4. Try to do a SLAVE START;
5. Notice that you get an error saying it isn't configured to be a slave, even though it actually is.
Suggested fix:
It looks like the internal variable server_id_supplied isn't getting changed when the server_id is set on the fly. I believe something similar to the below patch should fix it. However I haven't tested it to know if it will work exactly (or even will compiled actually). It should at least give you an idea of the right direction.
===== sql/set_var.cc 1.52 vs edited =====
--- 1.52/sql/set_var.cc Wed Mar 17 10:40:34 2004
+++ edited/sql/set_var.cc Wed May 19 00:22:50 2004
@@ -90,6 +90,7 @@
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_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 @@
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)
{