Bug #28796 CHANGE MASTER TO MASTER_HOST="" leads to invalid master.info
Submitted: 31 May 2007 8:00 Modified: 12 Nov 2009 14:34
Reporter: Jan Kneschke Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.1.17, 5.0, 4.1 OS:Any
Assigned to: Luis Soares CPU Architecture:Any

[31 May 2007 8:00] Jan Kneschke
Description:
CHANGE MASTER TO MASTER_HOST="" creates a master.info with a empty "host" field. 

The configuration is not working and no error is generated at CHANGE MASTER when is executed.

How to repeat:
> CHANGE MASTER TO MASTER_HOST="", MASTER_PORT=3306, MASTER_USER="repl", MASTER_PASSWORD="secret", MASTER_LOG_FILE="hostname-bin.000011", Master_Log_Pos=389524268;
Query OK, 0 rows affected (0.18 sec)

> show slave status\G
Empty set (0.00 sec)

> start slave;
ERROR 1200 (HY000): The server is not configured as slave; fix in config file or with CHANGE MASTER TO

Suggested fix:
Either support a empty Host field (and use unix domain sockets) or throw an error on CHANGE MASTER TO time.
[31 May 2007 9:42] Sveta Smirnova
Thank you for the report.

Verified as described.
[4 Sep 2007 12:37] Lars Thalmann
SHOW SLAVE STATUS should always work if there is defined information,
so I think just adding the error message if setting the hostname to ""
is good.
[1 Nov 2008 1: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/57608

2689 Luis Soares	2008-11-01
      BUG#28796: Checks wether host argument is an empty string or not. If empty, reports an error to the client and returns, otherwise continue normally.
[19 Nov 2008 14:14] Sven Sandberg
Patch not approved, I suggest another solution.

Internally, master_host="" currently has a special meaning, namely that no host has been assigned. This is ambiguous since master_host="" can also be set by the user, and this ambiguity caused the bug. From the user's view, master_host="" should not be more wrong than master_host="non-existing host", so it seems logical to have the same error detection mechanism for both.

Therefore, I suggest to use a flag internally that indicates if master_host is undefined, and remove the special meaning of host_name="".
[4 Dec 2008 12:50] 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/60596

2732 Luis Soares	2008-12-04
      Bug #28796 CHANGE MASTER TO MASTER_HOST="" leads to invalid master.info
      
      Description:
      When setting master_host to empty string there was no explicit error thrown regarding this. Furthermore, show slave status would not output data despite having valid information to report.
      
      Solution: 
      Allow setting master_host to empty string and output error when connecting to master. This allows show slave status to still output information.
      
      Details:
      The empty mi->host (!*mi->host[0]) has semantics associated with it in many places (including when connecting to master). It is the default value (when no options are set for instance and no change master has been issued). As such I have added the flag that is just turned on when explicit master_host is assigned. Furthermore should empty string be assigned, it just turns on the flag if it was assigned using: i) change master to master_host or ii) read from the master.info file.
      
      When connecting to master it checks if there is an empty string for master hostname. This was done because removing the existing test for empty string would lead to a different error (dumped in the error log) when compared to invalid hostname.
      
      Basically, with the patch you can assign empty string to master_host and still have show slave status to work. When issuing start slave; you get a error with invalid hostname instead of the previous error "The server is not configured as slave..."
[15 Dec 2008 13:06] Sven Sandberg
OK, please ignore my last comment. I, Luis, and Alfranio agreed that the changes needed for that were too complicated and risky. I will approve the first patch (throw error on "CHANGE MASTER TO master_host = ''"), if it gets a test case.

In the future, we should consider making "SHOW SLAVE STATUS" always print all information, and never return an empty result set. But that is not part of this bug report.
[20 Dec 2008 3:20] 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/62176

2746 Luis Soares	2008-12-20
      BUG#28796: CHANGE MASTER TO MASTER_HOST="" leads to invalid master.info
      
      This patch addresses the bug reported by checking wether 
      host argument is an empty string or not. If empty, an error is
      reported to the client, otherwise continue normally.
      
      This commit is based on the originally proposed patch and adds 
      a test case as requested during review.
[20 Dec 2008 15:12] 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/62182

2746 Luis Soares	2008-12-20
      BUG#28796: CHANGE MASTER TO MASTER_HOST="" leads to invalid master.info
            
      This patch addresses the bug reported by checking wether 
      host argument is an empty string or not. If empty, an error is
      reported to the client, otherwise continue normally.
           
      This commit is based on the originally proposed patch and adds 
      a test case as requested during review as well as refines comments, 
      and makes test case result file less verbose (compared to previous patch).
[4 Feb 2009 9:11] 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/65100

2810 Luis Soares	2009-02-04
      BUG#28796: CHANGE MASTER TO MASTER_HOST="" leads to invalid master.info
                  
      This patch addresses the bug reported by checking wether 
      host argument is an empty string or not. If empty, an error is
      reported to the client, otherwise continue normally.
                 
      This commit is based on the originally proposed patch and adds 
      a test case as requested during review as well as refines comments, 
      and makes test case result file less verbose (compared to previous patch).
[4 Feb 2009 9:14] Luis Soares
Pushed to 6.0-rpl tree.
[13 Feb 2009 3:24] 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/66136

2840 He Zhenxing	2009-02-13 [merge]
      Auto merge 6.0-rpl -> 6.0
[24 Mar 2009 17:20] Bugs System
Pushed into 6.0.11-alpha (revid:alik@sun.com-20090324171507-s5aac9guj21l0jz6) (version source revid:luis.soares@sun.com-20090204091034-tutzywcis50ib9nq) (merge vers: 6.0.10-alpha) (pib:6)
[25 Mar 2009 10:34] Jon Stephens
Documented bugfix in the 6.0.11 changelog as follows:

        CHANGE MASTER TO ... MASTER_HOST="" (explicitly setting
        MASTER_HOST equal to an empty string) created a master.info file
        with an empty host field. This led to a The server is not
        configured as slave error when attempting to execute a START
        SLAVE statement. Now, if MASTER_HOST is set to an empty string,
        the CHANGE MASTER TO statement fails with an error.

Also noted this issue in the 4.1-5.1 versions of the "CHANGE MASTER TO Syntax" section of the Manual as a known issue, and noted its 6.0 resolution in the 5.1 and 6.0 versions of that section.

Closed.
[29 Sep 2009 13:28] 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/85007

3113 Luis Soares	2009-09-29
      BUG#28796: CHANGE MASTER TO MASTER_HOST="" leads to invalid master.info
              
      NOTE: this is the backport to next-mr.
                
      This patch addresses the bug reported by checking wether 
      host argument is an empty string or not. If empty, an error is
      reported to the client, otherwise continue normally.
                       
      This commit is based on the originally proposed patch and adds 
      a test case as requested during review as well as refines comments, 
      and makes test case result file less verbose (compared to previous patch).
[29 Sep 2009 14:10] 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/85027

3115 Luis Soares	2009-09-29
      BUG#28796: CHANGE MASTER TO MASTER_HOST="" leads to invalid master.info
                    
      NOTE: this is the backport to next-mr.
                      
      This patch addresses the bug reported by checking wether 
      host argument is an empty string or not. If empty, an error is
      reported to the client, otherwise continue normally.
                             
      This commit is based on the originally proposed patch and adds 
      a test case as requested during review as well as refines comments, 
      and makes test case result file less verbose (compared to previous patch).
[27 Oct 2009 9:48] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091027094604-9p7kplu1vd2cvcju) (version source revid:zhenxing.he@sun.com-20091026140226-uhnqejkyqx1aeilc) (merge vers: 6.0.14-alpha) (pib:13)
[27 Oct 2009 18:43] Jon Stephens
Already documented in the 6.0.11 changelog.

Closed.
[12 Nov 2009 8:19] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091110093229-0bh5hix780cyeicl) (version source revid:alik@sun.com-20091027095744-rf45u3x3q5d1f5y0) (merge vers: 5.5.0-beta) (pib:13)
[12 Nov 2009 14:34] Jon Stephens
Also documented bugfix in the 5.5.0 changelog, and noted resolution of issue in 5.5 Manual. Closed.
[5 Jan 2011 0:39] Roel Van de Paar
See also bug #49785