Bug #56739 | binary log activation sets server_id implicitly, but replication fails | ||
---|---|---|---|
Submitted: | 12 Sep 2010 22:19 | Modified: | 21 Oct 2013 13:04 |
Reporter: | Giuseppe Maxia | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Replication | Severity: | S3 (Non-critical) |
Version: | 5.1.50 | OS: | Any (Mac OSX, Linux) |
Assigned to: | Assigned Account | CPU Architecture: | Any |
Tags: | binary logs., replication, server-id |
[12 Sep 2010 22:19]
Giuseppe Maxia
[17 Sep 2010 19:03]
Sveta Smirnova
Thank you for the report. Verified as described.
[21 Oct 2013 13:04]
Jon Stephens
Fixed in 5.7. Documented in the 5.7.3 changelog as follows: Formerly, it was possible to start the server with binary logging enabled but no server ID specified; in such cases, the server would set server_id to 1 (rather than 0) while slaves remained unable to connect. Now the --server-id option must be used when starting the server with binary logging enabled, otherwise the server is unable to start. If --server-id=0 is used, this value is no longer changed by the server; in this case, updates are written to the binary log, but slaves are unable to connect. Using --server-id without specifying a value has the same effect as setting it explicitly to 0. Also added relevant/version-specific info to --server-id and --log-bin option descriptions in the 5.0-5.7 versions of the Manual. Closed.
[4 Dec 2013 10:42]
Laurynas Biveinis
mysql-server$ bzr log -r 6591 ------------------------------------------------------------ revno: 6591 committer: Tiago Jorge <tiago.jorge@oracle.com> branch nick: mysql-trunk timestamp: Mon 2013-09-30 18:08:27 +0100 message: BUG#11763963 - BINARY LOG ACTIVATION SETS SERVER_ID IMPLICITLY, BUT REPLICATION FAILS Problem: When one enables binary logging without setting a server id, letting it default to 0, the server changes it to 1, but replication does not work. According to the documentation, a server id > 0, should be a legal configuration to allow slave to connect and replication to work. Analysis: Apparently, this happens since the dawn of time as a design decision, meaning that binlog => server_id. In mysqld.cc::main() [...] if (opt_bin_log && server_id == 0) { server_id= 1; #ifdef EXTRA_DEBUG sql_print_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."); #endif } [...] What happened is that, when a slave tried to connect, it would get an error stating that the master was misconfigured, even with server-id = 1. After some testing we concluded that not even the documentation was accurate enough. The test conducted were: 1) Start master with no options. Make sure that slave cannot connect (control experience) 2) Start master with only binlog active. Make sure that slave cannot connect (the bug situation) 3) Start master with binlog active and server-id == 0 in the command line. Make sure that slave cannot connect. (as documented) 4) Start master with binlog active and server-id == 1 in the command line. Change server_id to 0 using SQL before connecting slave. Make sure that slave cannot connect.(as documented) Situations 1) and 2) are OK and according with expected and analyzed behavior. With 3) and 4) things are not as documented. In Situation 3) the server starts and implicitly sets server id to 1. When one starts a slave after configuring the master, there is no error in "SHOW SLAVE STATUS". It connects and works. Bin and Relay log have a server id of 1. In Situation 4) in which one explicitly change the server_id in runtime, the behavior is the same as in Situation 3). Contents of the relay log and bin log have a server id == 0 Fix: For trunk only the decision was: - Server_id must be explicitly set if binlog is active. If not, the server will not start. - if you set server_id=0, no slaves can connect, but your statements will be binlogged with the provided server_id. - if no server_id is set, it will have the default configured value and have the same behaviour as the above, if the default is 0. This patch will bring the code closer to which is documented. The dynamic change of server-id was not addressed here. For the previous version, one thinks that the documentation should be augmented according to the information detailed in the bug page.