Bug #24954 Last_errno and Last_error not set after master_retry_count has been reached
Submitted: 11 Dec 2006 12:53 Modified: 25 Jul 2007 13:02
Reporter: Johan Andersson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: Mats Kindahl CPU Architecture:Any

[11 Dec 2006 12:53] Johan Andersson
Description:
if reconnect from slave to a master fails after master_connect_retry and master-retry-count has been reached, then only an error is written in the error log, but Last_Errno  and Last_Error are not set in "show slave status", making it impossible to know when the slave has given up due to master_retry_* has been reached.

How to repeat:
[mysqld]
master_retry_count=3
master_retry_connect=10
...

replication running
kill master mysqld

Only this is written to the error log file:
061211 13:43:57 [Note] Slave I/O thread killed while connecting to master
061211 13:43:57 [Note] Slave I/O thread exiting, read up to log 'stingray-bin.000003', position 41214

but Last_error and last_errno is not set:
            Slave_IO_State:
...
           Slave_IO_Running: No
          Slave_SQL_Running: Yes
..
                 Last_Errno: 0
                 Last_Error:

This makes it quite difficult to implement various monitoring things

Suggested fix:
Fix it
[12 Dec 2006 13:40] MySQL Verification Team
Thank you for the bug report. Changing the test case settings:
master_retry_connect=10 to master_connect_retry=10.
[13 Dec 2006 8:17] Mats Kindahl
The message you showed is not an error message, and only error messages are displayed as Last_errno and Last_error in the SHOW SLAVE STATUS.  I think it makes sense to upgrade this informational message to an error, since it stops replication (and personally I wouldn't consider anything that stops replication to be anything but an error).
[22 Dec 2006 13:47] Mats Kindahl
This bug is solved by adding four new fields to the end of the listing for SHOW SLAVE STATUS. The fields are added last in the list to allow applications that use positional references into the row to use the same positional argument as before.

The fields are:

Last_IO_Error    The last error that caused the I/O thread to stop
Last_IO_Errno    The error number of the last that caused the I/O thread to stop
Last_SQL_Error   The last error that caused the SQL thread to stop
Last_SQL_Errno   The error number of the last that caused the SQL thread to stop

In addition, the old fields Last_Error and Last_Errno are aliases for Last_SQL_Error and Last_SQL_Errno respectively.
[3 Jan 2007 5:11] James Day
Looks good to me - welcome extra clarity.
[8 Jan 2007 11:52] 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/17722

ChangeSet@1.2361, 2007-01-08 12:52:08+01:00, mats@romeo.(none) +34 -0
  BUG#24954 (Last_errno and Last_error not set after master_retry_count was reached):
  Adding new fields Last_{IO,SQL}_Errno and Last_{IO,SQL}_Error to output
  of SHOW SLAVE STATUS to hold errors from I/O and SQL thread respectively.
  Old fields Last_Error and Last_Errno are aliases for Last_SQL_Error and
  Last_SQL_Errno respectively.
  
  Fields are added last to output of SHOW SLAVE STATUS to allow old applications
  to use the same positional arguments into the row, while allowing new
  application to benefit from the added information.
[11 Jan 2007 16:35] 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/17958

ChangeSet@1.2361, 2007-01-11 17:35:21+01:00, mats@romeo.(none) +70 -0
  BUG#24954 (Last_errno and Last_error not set after master_retry_count was reached):
  Adding new fields Last_{IO,SQL}_Errno and Last_{IO,SQL}_Error to output
  of SHOW SLAVE STATUS to hold errors from I/O and SQL thread respectively.
  Old fields Last_Error and Last_Errno are aliases for Last_SQL_Error and
  Last_SQL_Errno respectively.
  
  Fields are added last to output of SHOW SLAVE STATUS to allow old applications
  to use the same positional arguments into the row, while allowing new
  application to benefit from the added information.
[15 Jan 2007 16:58] 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/18129

ChangeSet@1.2361, 2007-01-15 17:18:05+01:00, mats@romeo.(none) +71 -0
  BUG#24954 (Last_errno and Last_error not set after master_retry_count was reached):
  Adding new fields Last_{IO,SQL}_Errno and Last_{IO,SQL}_Error to output
  of SHOW SLAVE STATUS to hold errors from I/O and SQL thread respectively.
  Old fields Last_Error and Last_Errno are aliases for Last_SQL_Error and
  Last_SQL_Errno respectively.
  
  Fields are added last to output of SHOW SLAVE STATUS to allow old applications
  to use the same positional arguments into the row, while allowing new
  application to benefit from the added information.
  
  Adding new replication error codes to existing replication error
  messages and using them.
[25 Jan 2007 20:41] Guilhem Bichot
review sent by email
[27 Jan 2007 7:17] 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/18897

ChangeSet@1.2361, 2007-01-27 08:17:33+01:00, mats@romeo.(none) +69 -0
  BUG#24954 (Last_errno and Last_error not set after master_retry_count was reached):
  Adding new fields Last_{IO,SQL}_Errno and Last_{IO,SQL}_Error to output
  of SHOW SLAVE STATUS to hold errors from I/O and SQL thread respectively.
  Old fields Last_Error and Last_Errno are aliases for Last_SQL_Error and
  Last_SQL_Errno respectively.
  
  Fields are added last to output of SHOW SLAVE STATUS to allow old applications
  to use the same positional arguments into the row, while allowing new
  application to benefit from the added information.
  
  Adding new replication error codes to existing replication error
  messages and using them.
[30 Jan 2007 13:54] Guilhem Bichot
comments sent by mail
[24 Feb 2007 21:40] 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/20538

ChangeSet@1.2361, 2007-02-24 22:40:15+01:00, mats@romeo.(none) +69 -0
  BUG#24954 (Last_errno and Last_error not set after master_retry_count was reached):
  Adding new fields Last_{IO,SQL}_Errno and Last_{IO,SQL}_Error to output
  of SHOW SLAVE STATUS to hold errors from I/O and SQL thread respectively.
  Old fields Last_Error and Last_Errno are aliases for Last_SQL_Error and
  Last_SQL_Errno respectively.
  
  Fields are added last to output of SHOW SLAVE STATUS to allow old applications
  to use the same positional arguments into the row, while allowing new
  application to benefit from the added information.
  
  In addition, some new error codes are added (especially for the I/O
  thread) to be able to provide sensible error message.
[26 Feb 2007 7:40] 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/20549

ChangeSet@1.2361, 2007-02-26 08:40:24+01:00, mats@romeo.(none) +69 -0
  BUG#24954 (Last_errno and Last_error not set after master_retry_count was reached):
  Adding new fields Last_{IO,SQL}_Errno and Last_{IO,SQL}_Error to output
  of SHOW SLAVE STATUS to hold errors from I/O and SQL thread respectively.
  Old fields Last_Error and Last_Errno are aliases for Last_SQL_Error and
  Last_SQL_Errno respectively.
  
  Fields are added last to output of SHOW SLAVE STATUS to allow old applications
  to use the same positional arguments into the row, while allowing new
  application to benefit from the added information.
  
  In addition, some new error codes are added (especially for the I/O
  thread) to be able to provide sensible error message.
[31 May 2007 22:11] Lars Thalmann
See also BUG#26201.
[2 Jun 2007 8:43] 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/27982

ChangeSet@1.2362, 2007-06-02 10:43:23+02:00, mats@kindahl-laptop.dnsalias.net +12 -0
  BUG#24954 (Last_errno and Last_error not set after master_retry_count
  has been reached):
  
  - Fixing slave fatal error message.
  - Adding debug code to generate a fatal error message.
  - Adding test to ensure that message is generated and correct.
[7 Jun 2007 11:34] Guilhem Bichot
only minor comments remain, we are close to pushing.
[9 Jun 2007 5:14] 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/28448

ChangeSet@1.2363, 2007-06-09 07:13:53+02:00, mats@kindahl-laptop.dnsalias.net +1 -0
  BUG#24954 (Last_errno and Last_error not set after master_retry_count
  has been reached):
  
  Minor changes based on comments from the review.
[9 Jun 2007 5: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/28449

ChangeSet@1.2361, 2007-06-09 07:19:37+02:00, mats@kindahl-laptop.dnsalias.net +73 -0
  BUG#24954 (Last_errno and Last_error not set after master_retry_count was reached):
  Adding new fields Last_{IO,SQL}_Errno and Last_{IO,SQL}_Error to output
  of SHOW SLAVE STATUS to hold errors from I/O and SQL thread respectively.
  Old fields Last_Error and Last_Errno are aliases for Last_SQL_Error and
  Last_SQL_Errno respectively.
  
  Fields are added last to output of SHOW SLAVE STATUS to allow old applications
  to use the same positional arguments into the row, while allowing new
  application to benefit from the added information.
  
  In addition, some new error codes are added (especially for the I/O
  thread) to be able to provide sensible error message.
[11 Jun 2007 20:16] 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/28525

ChangeSet@1.2551, 2007-06-11 22:15:39+02:00, mats@kindahl-laptop.dnsalias.net +69 -0
  BUG#24954 (Last_errno and Last_error not set after master_retry_count has
  been reached):
  
  Post-merge patch to handle all the changes to the tree since the tree
  was cloned.
[21 Jun 2007 20:15] Bugs System
Pushed into 5.1.20-beta
[24 Jul 2007 19:59] Paul DuBois
Noted in 5.1.20 changelog.

In SHOW SLAVE STATUS output, Last_Errno and Last_Error
were not set after master_retry_count errors had
occurred. To provide additional information, the
statement now displays four additional columns:

- Last_IO_Errno: The number of the last error that
  caused the I/O thread to stop
- Last_IO_Error: A description of the last error that
  caused the I/O thread to stop
- Last_SQL_Errno: The number of the last error that
  caused the SQL thread to stop
- Last_SQL_Error: A description of the last error that
  caused the SQL thread to stop

Also, the Last_Errno and Last_Error now are aliases for
Last_SQL_Errno and Last_SQL_Error.