Bug #48563 si_objects.h uses local constants for incident event types.
Submitted: 5 Nov 2009 11:46 Modified: 5 Nov 2009 11:54
Reporter: Rafal Somla Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[5 Nov 2009 11:46] Rafal Somla
Description:
Header sql/si_objects.h declares function write_incident_event() which is supposed to write to binlog an incident event of type INCIDENT_RESTORE_EVENT. Incident event types are defined in sql/rpl_constants.h. However, si_objects.h uses a local version of the enumeration:

/**
  Enumeration of the incidents that can occur on the master.
*/
enum incident_events {
  NONE,          // Indicates there was no incident 
  LOST_EVENTS,   // Indicates lost events 
  RESTORE_EVENT, // Indicates a restore has executed on the master
  COUNT          // Value counts the enumerations
};

This means that if the value of RESTORE_EVENT equals that of INCIDENT_RESTORE_EVENT then this is by pure coincidence. As soon as someone changes enumeration in rpl_constants.h the constant used by si_objects.h can become wrong leading to wrong incident event being written to the binlog.

How to repeat:
Code inspection.

Suggested fix:
Include rpl_constants.h from si_objects.h.
[5 Nov 2009 11:54] Rafal Somla
I must apologize - it is not a bug. Looking closer at the implementation I can see that local incident event codes are correctly translated into the types defined in rpl_constants.h. Since si_objects is an interface layer, it makes sense to use local codes for the write_incident_event() function and do explicit conversion.