Bug #3829 Setting server_id on fly doesn't allow replication to start
Submitted: 19 May 2004 6:30 Modified: 19 May 2004 15:06
Reporter: Harrison Fisk Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:4.0.18 OS:Linux (Redhat Linux)
Assigned to: Guilhem Bichot CPU Architecture:Any

[19 May 2004 6:30] Harrison Fisk
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 @@
 #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",
 sys_var_long_ptr       sys_slave_net_timeout("slave_net_timeout",
@@ -811,6 +812,10 @@
+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)
[19 May 2004 15:06] Guilhem Bichot
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at

Additional info:

Thanks a lot for the patch, Harrison! It (almost compiled, and after adding a line in mysql_priv.h, it) fixes the bug well.
ChangeSet@1.1837.1.1, 2004-05-19 15:03:32+02:00, guilhem@mysql.com