Bug #44270 RESET SLAVE does not reset Last_IO_Error or Last_IO_Errno
Submitted: 14 Apr 2009 17:35 Modified: 9 Jul 2009 12:06
Reporter: Kyle Joiner Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.1 OS:Linux (5.1.33)
Assigned to: Luis Soares CPU Architecture:Any
Tags: Last_IO_Errno, replication, RESET SLAVE

[14 Apr 2009 17:35] Kyle Joiner
Description:
RESET SLAVE does not reset the Last_IO_Error or Last_IO_Errno in SHOW SLAVE STATUS.  

How to repeat:
Example:
Master server:  127.0.0.1 Port 3306
Slave server: 127.0.0.1 Port 3307
mysql> stop slave;
Query OK, 0 rows affected (45.23 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State:
                  Master_Host: 127.0.0.1
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: kjoiner-PC-bin.000001
          Read_Master_Log_Pos: 222
               Relay_Log_File: kjoiner-PC-relay-bin.000002
                Relay_Log_Pos: 256
        Relay_Master_Log_File: kjoiner-PC-bin.000001
             Slave_IO_Running: No
            Slave_SQL_Running: No
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 222
              Relay_Log_Space: 416
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 2003
                Last_IO_Error: error connecting to master 'repl@127.0.0.1:3306'
- retry-time: 60  retries: 86400
               Last_SQL_Errno: 0
               Last_SQL_Error:
1 row in set (0.00 sec)

mysql> reset slave;
Query OK, 0 rows affected (0.03 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State:
                  Master_Host: 127.0.0.1
                  Master_User: test
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File:
          Read_Master_Log_Pos: 4
               Relay_Log_File: kjoiner-PC-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File:
             Slave_IO_Running: No
            Slave_SQL_Running: No
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 0
              Relay_Log_Space: 125
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 2003
                Last_IO_Error: error connecting to master 'repl@127.0.0.1:3306'
- retry-time: 60  retries: 86400
               Last_SQL_Errno: 0
               Last_SQL_Error:
1 row in set (0.00 sec)

mysql> change master to
    -> master_user='repl',
    -> master_log_pos=222,
    -> master_log_file='kjoiner-PC-bin.000001',
    -> master_port=3306,
    -> master_password='repl';
Query OK, 0 rows affected (0.02 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 127.0.0.1
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: kjoiner-PC-bin.000002
          Read_Master_Log_Pos: 106
               Relay_Log_File: kjoiner-PC-relay-bin.000003
                Relay_Log_Pos: 256
        Relay_Master_Log_File: kjoiner-PC-bin.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 106
              Relay_Log_Space: 566
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 2003
                Last_IO_Error: error connecting to master 'repl@127.0.0.1:3306'
- retry-time: 60  retries: 86400
               Last_SQL_Errno: 0
               Last_SQL_Error:
1 row in set (0.00 sec)

mysql>

Suggested fix:
Reset the values when RESET SLAVE is issued.
[2 Jun 2009 13:55] Luis Soares
See also: BUG#34654.
[3 Jun 2009 14:15] 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/75532

2917 Luis Soares	2009-06-03
      BUG#44270: RESET SLAVE does not reset Last_IO_Error or Last_IO_Errno
      
      The server was not cleaning the last IO error and error number when
      resetting slave.
      
      This patch addresses this issue by backporting into 5.1 part of the
      patch in BUG 34654. A fix for this issue had already been pushed into
      6.0 as part of the aforementioned bug, however the patch also included
      some refactoring. The fix for 5.1 does not take into account the
      refactoring part.
     @ mysql-test/extra/rpl_tests/rpl_reset_slave.test
        Backported the test case and improved with deploying include/start_slave.inc
        in relevant spots.
     @ sql/slave.cc
        Backported part of patch from 6.0 that includes cleaning 
        mi->clear_error() at:
          1. beginning of handle_slave_io
          2. on successful connection
        
        Also, backported the assertion added in the original patch.
     @ sql/sql_repl.cc
        Backported the call to mi->clear_error() on reset_slave().
[25 Jun 2009 23:50] Luis Soares
Pushed to mysql-5.1-bugteam and mysql-pe.
[25 Jun 2009 23:54] Luis Soares
Given the previous comment, just want to clarify that push to mysql-pe was a null merge as this was a backport from 6.0 to 5.1.
[26 Jun 2009 11:06] 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/77309

2980 Luis Soares	2009-06-26
      BUG#44270: Post-push fix
      
      The test case added failed sporadically on PB. This is due to the
      fact that the user thread in some cases is waiting for slave IO
      to stop and then check the error number. Thence, sometimes the
      user thread would race for the error number with IO thread.
      
      This post push fix addresses this by replacing the wait for slave
      io to stop with a wait for slave io error (as it seems it was
      added in 6.0 also after patch on which this is based was
      pushed). This implied backporting wait_for_slave_io_error.inc
      from 6.0 also.
[8 Jul 2009 13:30] Bugs System
Pushed into 5.1.37 (revid:joro@sun.com-20090708131116-kyz8iotbum8w9yic) (version source revid:luis.soares@sun.com-20090626111850-p00u59p44oa0qtvt) (merge vers: 5.1.37) (pib:11)
[9 Jul 2009 7:37] Bugs System
Pushed into 5.1.37 (revid:joro@sun.com-20090708131116-kyz8iotbum8w9yic) (version source revid:luis.soares@sun.com-20090626111850-p00u59p44oa0qtvt) (merge vers: 5.1.37) (pib:11)
[9 Jul 2009 12:06] Jon Stephens
Documented bugfix in the 5.1.37 changelog as follows:

        RESET MASTER and RESET SLAVE now reset the values
        shown for Last_IO_Error, Last_IO_Errno, Last_SQL_Error, 
        and Last_SQL_Errno in the output of SHOW SLAVE STATUS.

Also noted in the descriptions of these columns given in the SHOW SLAVE STATUS
Syntax section of the 5.1 Manual that this change also now applies in MySQL 5.1.37?.
[10 Jul 2009 11:20] Bugs System
Pushed into 5.4.4-alpha (revid:anozdrin@bk-internal.mysql.com-20090710111017-bnh2cau84ug1hvei) (version source revid:luis.soares@sun.com-20090626113019-1j4mn1jos480u9f3) (merge vers: 5.4.4-alpha) (pib:11)
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers: 5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48] Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers: 5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:32] Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)