Bug #47956 backup history log columns show diff values when logged in FILE and TABLE mode
Submitted: 9 Oct 2009 19:00 Modified: 2 Mar 2010 2:26
Reporter: Hema Sridharan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:6.0-backup OS:Any
Assigned to: Chuck Bell CPU Architecture:Any

[9 Oct 2009 19:00] Hema Sridharan
Description:
Set global log_backup_output='FILE';
Create database db1;
Backup database db1 to 'db1.bak';
Check the backup_history.log file and verify that all columns show correct values.

We can notice that both backup_state and operation column value shows '1' when backup is performed. Also when restore is performed, operation column shows '2'.

When the log_backup_output is set to 'TABLE' the values shown for backup_state will be 'complete', 'running', 'error' etc and for operation will be 'backup' or 'restore'.

This shows that the column values can change when log_backup_output is set to FILE or TABLE. This has to be fixed or at least needs to be documented in the MySQL backup manuals.

How to repeat:
Perform the steps mentioned above.
[9 Oct 2009 23:33] MySQL Verification Team
Thank you for the bug report. Could you please specify the server version and source tree you have tested. Thanks in advance.
[9 Oct 2009 23:40] Hema Sridharan
I used mysql-6.0-backup tree
[11 Oct 2009 5:50] Sveta Smirnova
Thank you for the report.

But table mysql.backup_history has following definition of backup_state column:

 `backup_state` enum('complete','starting','validity point','running','error','cancel') NOT NULL COMMENT 'Status of current operation'

So it really contains "1" for complete operation.

This still can be considered as valid feature request, so setting to "Verified".
[10 Nov 2009 18:48] Chuck Bell
The problem is in the MYSQL_BACKUP_LOG::write(THD *thd, st_backup_history *history_data) method. This method writes the log information to a file but uses the numeric value for the enumerated columns. Since the table has enumerated columns, we 'see' in the logs things like 'restore', 'backup', 'completed' but in fact these are just numbers in the table itself. 

To satisfy this bug, one merely needs to change the code in log.cc @ #3913 to use the enumerated names rather than the numeric values for all enumerated fields. These include the following columns in the backup_history table:

backup_state ENUM('complete', 'starting', 'validity point', 'running', 'error', 'cancel')

operation ENUM('backup', 'restore')
[10 Nov 2009 18:49] Chuck Bell
Chuck steals a bug since it is an easy fix.
[10 Nov 2009 18:56] Chuck Bell
Note that there is no easy way to test the patch. We do not have a reliable way to dump a text file across platforms. Thus, manual inspection is the only method to ensure this patch works.
[10 Nov 2009 19:37] 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/90001

2889 Chuck Bell	2009-11-10
      BUG#47956 : backup history log columns show diff values when logged in FILE and TABLE mode
      
      The backup log files are not writing the enumerated values to the file.
      Instead, they are writing the numeric representation for the columns.
      This affects the backup_history log file and columns 'backup_state'
      and 'operation'.
      
      This patch changes the log writing method to use the enumerated 
      values (strings) instead of the numeric values.
     @ sql/log.cc
        Write string equivalent for each of the two enumerated columns.
[10 Nov 2009 20:09] 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/90004

2889 Chuck Bell	2009-11-10
      BUG#47956 : backup history log columns show diff values when logged in 
                  FILE and TABLE mode
      
      The backup log files are not writing the enumerated values to the file.
      Instead, they are writing the numeric representation for the columns.
      This affects the backup_history log file and columns 'backup_state'
      and 'operation'.
      
      This patch changes the log writing method to use the enumerated 
      values (strings) instead of the numeric values.
     @ sql/log.cc
        Write string equivalent for each of the two enumerated columns.
     @ sql/si_logs.h
        Corrected enumeration for the operation and backup_state columns.
[12 Nov 2009 6:14] Rafal Somla
"Note that there is no easy way to test the patch. We do not have a reliable way to dump a text file across platforms". 

You can try MTRs command --cat_file which should be platform independent.
[12 Nov 2009 14:34] Chuck Bell
The command cat_file was considered but given the file will contain dates, it makes for a non-deterministic result. What is needed is a way to search a text file to make compares.
[16 Nov 2009 18:18] Thava Alagu
Patch approved.
[16 Nov 2009 18:37] 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/90561

2889 Chuck Bell	2009-11-16
      BUG#47956 : backup history log columns show diff values when logged in 
                  FILE and TABLE mode
      
      The backup log files are not writing the enumerated values to the file.
      Instead, they are writing the numeric representation for the columns.
      This affects the backup_history log file and columns 'backup_state'
      and 'operation'.
      
      This patch changes the log writing method to use the enumerated 
      values (strings) instead of the numeric values.
     @ sql/log.cc
        Write string equivalent for each of the two enumerated columns.
     @ sql/si_logs.h
        Corrected enumeration for the operation and backup_state columns.
[16 Nov 2009 18:41] 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/90564

2890 Chuck Bell	2009-11-16 [merge]
      local merge before push of BUG#47956
[20 Feb 2010 9:18] Bugs System
Pushed into 6.0.14-alpha (revid:ingo.struewing@sun.com-20100218152520-s4v1ld76bif06eqn) (version source revid:ingo.struewing@sun.com-20100119103538-wtp5alpz4p2jayl5) (merge vers: 6.0.14-alpha) (pib:16)
[2 Mar 2010 2:26] Paul DuBois
Noted in 6.0.14 changelog.

MySQL Backup logged information differently to the table and file
backup log destinations.