Bug #28908 Replication: set global server_id is not setting the session server_id ....
Submitted: 5 Jun 2007 22:31 Modified: 6 Feb 2008 17:43
Reporter: Jonathan Miller Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:5.1-telco OS:Linux (32 bit)
Assigned to: Zhenxing He CPU Architecture:Any
Triage: D2 (Serious)

[5 Jun 2007 22:31] Jonathan Miller
Description:
setting the  global server_id is not setting the session server_id which cause changed to follow to record the old sever id.

The docs state that Var Scope is both (session/global) and that it is Dynamic.

If you try to set the session id you get back:

mysql> set server_id = 5;
ERROR 1229 (HY000): Variable 'server_id' is a GLOBAL variable and should be set with SET GLOBAL

So we have issues here of inconstancy. 

How to repeat:
Setup mysqld using binlog with server_id=1.
Create table
show binlog event (see id = 1)
set global server_id=2
create table 
show binlog event (see id = 1)
set server_id = 3;
read error message
ERROR 1229 (HY000): Variable 'server_id' is a GLOBAL variable and should be set with SET GLOBAL
log out of mysql
log into mysql
create table 
show binlog event (see id = 2)

Suggested fix:
Do away with session server_id and have global server_id only
[5 Jun 2007 22:35] Matthew Montgomery
Doing SET GLOBAL server_id=N does not change the SESSION server_id value.  For all subsequent changes during that session the old server_id value is used.  There is no way to set the SESSION server_id dynamically.
[20 Dec 2007 6:49] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/40249

ChangeSet@1.2657, 2007-12-20 13:23:38+08:00, hezx@hezx.(none) +3 -0
  BUG#28908 Replication: set global server_id is not setting the session server_id 
  
  When set the server-id dynamically, the server_id member of current thread is not updated.
  
  Update the server_id member of current thread after updated the global variable value.
[21 Dec 2007 3:03] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/40318

ChangeSet@1.2560, 2007-12-21 11:02:48+08:00, hezx@mail.hezx.com +3 -0
  BUG#28908 Replication: set global server_id is not setting the session server_id 
  
  When set the server-id dynamically, the server_id member of current thread is not updated.
  
  Update the server_id member of current thread after updated the global variable value.
[5 Feb 2008 12:45] Bugs System
Pushed into 5.0.56
[5 Feb 2008 13:03] Bugs System
Pushed into 5.1.24-rc
[5 Feb 2008 13:07] Bugs System
Pushed into 6.0.5-alpha
[6 Feb 2008 17:43] Jon Stephens
Documented bugfix in the 5.0.56, 5.1.24, and 6.0.5 changelogs as follows:

        Setting server_id did not update its value
        for the current session.

(NOTE: I checked the docs and they show server_id as being global, not session.)
[6 Mar 2008 5:58] Jon Stephens
Fix also documented for 5.1.23-ndb-6.2.14.
[30 Mar 2008 9:28] Jon Stephens
Fix also documented for 5.1.23-ndb-6.3.11.