Bug #40304 Backup: Errors reported during BACKUP show as warnings on the error stack
Submitted: 24 Oct 2008 13:09 Modified: 13 Dec 2008 17:40
Reporter: Rafal Somla Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:6.0-backup OS:Any
Assigned to: Rafal Somla CPU Architecture:Any

[24 Oct 2008 13:09] Rafal Somla
Description:
When error is reported by BACKUP/RESTORE operation, it shows as a warning in SHOW WARNINGS but it should show as an error.

Note. This is bacause backup kernel code used 

  push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
		      error_code, msg);

To push error on the error stack. However, it is not correct to use push_warning_printf(...) with WARN_LEVEL_ERROR and because of that it was changed to 

  push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARNING,
		      error_code, msg);

Note BUG#36635 with a different idea how BACKUP problems should be reported. However, it should be consistent - either problems are reported as errors or as warnings. Current code does both and the original intention was to report them as errors.

How to repeat:
Execute:

sql> backup database foo to 'foo.bkp';
ERROR 42000: Unknown database 'foo'

sql> show warnings;
Level   Code    Message
Warning 1049    Unknown database 'foo'

Suggested fix:
Dont use push_warning_printf() for reporting errors - use my_error() and friends.
[5 Nov 2008 12: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/57880

2721 Rafal Somla	2008-11-05
      BUG#40303 (Backup: Wrong error send to client if several errors reported)
      BUG#40304 (Backup: Errors reported during BACKUP show as warnings on the 
                 error stack)
      
      Before: Errors reported using backup::Logger class could be saved and in 
      case several errors are reported, the last one was sent to client as an
      error reply from BACKUP/RESTORE command.
      
      After: Errors reported with backup::Logger are reported to the server 
      using my_printf_error(..) function. This function pushes error on the 
      error stack (unles told otherwise) and stores the first reported error
      so that it is send to the client.
      
      Additionally.
      
      - Function log_error(..) is moved to the Logger class.
      
      - Code is changed do consistently use Logger::report/log_error() for error 
      reporting.
      
      - Semantics of Backup_restore_ctx::fatal_error() has been changed to 
      discourage its use as an error reporting facility. Now it is an internal helper 
      method which moves the context object into error state. It is used only by the 
      class methods and it is made private. The idea is that context object should 
      move into error state only as a result of executing one of its methods (not 
      externally).
      
      - Improved error reporting in few places.
[12 Nov 2008 11:21] 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/58536

2731 Rafal Somla	2008-11-12
      BUG#40303 (Backup: Wrong error send to client if several errors reported)
      BUG#40304 (Backup: Errors reported during BACKUP show as warnings on the 
                 error stack)
      
      Before: Errors reported using backup::Logger class could be saved and in 
      case several errors are reported, the last one was sent to client as an
      error reply from BACKUP/RESTORE command.
      
      After: Errors reported with backup::Logger are reported to the server 
      using my_printf_error(..) function. This function pushes error on the 
      error stack (unles told otherwise) and stores the first reported error
      so that it is send to the client.
      
      Additionally.
      
      - Function log_error(..) is moved to the Logger class.
      
      - Code is changed do consistently use Logger::report/log_error() for error 
      reporting.
      
      - Semantics of Backup_restore_ctx::fatal_error() has been changed to 
      discourage its use as an error reporting facility. Now it is an internal helper 
      method which moves the context object into error state. It is used only by the 
      class methods and it is made private. The idea is that context object should 
      move into error state only as a result of executing one of its methods (not 
      externally).
      
      - Improved error reporting in few places.
[19 Nov 2008 10:19] 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/59184

2731 Rafal Somla	2008-11-19
      BUG#40303 (Backup: Wrong error send to client if several errors reported)
      BUG#40304 (Backup: Errors reported during BACKUP show as warnings on the 
                 error stack)
      
      Before: Errors reported using backup::Logger class could be saved and in 
      case several errors are reported, the last one was sent to client as an
      error reply from BACKUP/RESTORE command.
      
      After: Errors reported with backup::Logger are reported to the server 
      using my_printf_error(..) function. This function pushes error on the 
      error stack (unles told otherwise) and stores the first reported error
      so that it is send to the client.
      
      Additionally.
      
      - Function log_error(..) is moved to the Logger class.
      
      - Code is changed to consistently use Logger::report/log_error() for error 
      reporting.
      
      - Semantics of Backup_restore_ctx::fatal_error() has been changed to 
      discourage its use as an error reporting facility. Now it is an internal helper 
      method which moves the context object into error state. It is used only by the 
      class methods and it is made private. The idea is that context object should 
      move into error state only as a result of executing one of its methods (not 
      externally).
      
      - Improved error reporting in few places.
[19 Nov 2008 13:08] 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/59221

2736 Rafal Somla	2008-11-19
      BUG#40303 (Backup: Wrong error send to client if several errors reported)
      BUG#40304 (Backup: Errors reported during BACKUP show as warnings on the 
                 error stack)
      
      Before: Errors reported using backup::Logger class could be saved and in 
      case several errors are reported, the last one was sent to client as an
      error reply from BACKUP/RESTORE command.
      
      After: Errors reported with backup::Logger are reported to the server 
      using my_printf_error(..) function. This function pushes error on the 
      error stack (unles told otherwise) and stores the first reported error
      so that it is send to the client.
      
      Additionally.
      
      - Function log_error(..) is moved to the Logger class.
      
      - Code is changed to consistently use Logger::report/log_error() for error 
      reporting.
      
      - Semantics of Backup_restore_ctx::fatal_error() has been changed to 
      discourage its use as an error reporting facility. Now it is an internal helper 
      method which moves the context object into error state. It is used only by the 
      class methods and it is made private. The idea is that context object should 
      move into error state only as a result of executing one of its methods (not 
      externally).
      
      - Improved error reporting in few places.
[20 Nov 2008 12:42] 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/59364

2738 Rafal Somla	2008-11-20
      BUG#40303 (Backup: Wrong error send to client if several errors reported)
      BUG#40304 (Backup: Errors reported during BACKUP show as warnings on the 
                 error stack)
      
      Before: Errors reported using backup::Logger class could be saved and in 
      case several errors are reported, the last one was sent to client as an
      error reply from BACKUP/RESTORE command.
      
      After: Errors reported with backup::Logger are reported to the server 
      using my_printf_error(..) function. This function pushes error on the 
      error stack (unles told otherwise) and stores the first reported error
      so that it is send to the client.
      
      Additionally.
      
      - Function log_error(..) is moved to the Logger class.
      
      - Code is changed to consistently use Logger::report/log_error() for error 
      reporting.
      
      - Semantics of Backup_restore_ctx::fatal_error() has been changed to 
      discourage its use as an error reporting facility. Now it is an internal helper 
      method which moves the context object into error state. It is used only by the 
      class methods and it is made private. The idea is that context object should 
      move into error state only as a result of executing one of its methods (not 
      externally).
      
      - Improved error reporting in few places.
[20 Nov 2008 14:41] Øystein Grøvlen
Patch approved.
[21 Nov 2008 8:21] Rafal Somla
The patch is reviewed on BUG#40303 page.
[24 Nov 2008 9: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/59661

2745 Rafal Somla	2008-11-24
      BUG#40303 (Backup: Wrong error send to client if several errors reported)
      BUG#40304 (Backup: Errors reported during BACKUP show as warnings on the 
                 error stack)
      
      Before: Errors reported using backup::Logger class could be saved and in 
      case several errors are reported, the last one was sent to client as an
      error reply from BACKUP/RESTORE command.
      
      After: Errors reported with backup::Logger are reported to the server 
      using my_printf_error(..) function. This function pushes error on the 
      error stack (unles told otherwise) and stores the first reported error
      so that it is send to the client.
      
      Additionally.
      
      - Function log_error(..) is moved to the Logger class.
      
      - Code is changed to consistently use Logger::report/log_error() for error 
      reporting.
      
      - Semantics of Backup_restore_ctx::fatal_error() has been changed to 
      discourage its use as an error reporting facility. Now it is an internal helper 
      method which moves the context object into error state. It is used only by the 
      class methods and it is made private. The idea is that context object should 
      move into error state only as a result of executing one of its methods (not 
      externally).
      
      - Improved error reporting in few places.
[25 Nov 2008 17:45] 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/59832

2746 Rafal Somla	2008-11-25
      BUG#40303 (Backup: Wrong error send to client if several errors reported)
      BUG#40304 (Backup: Errors reported during BACKUP show as warnings on the 
                 error stack)
      
      Before: Errors reported using backup::Logger class could be saved and in 
      case several errors are reported, the last one was sent to client as an
      error reply from BACKUP/RESTORE command.
      
      After: Errors reported with backup::Logger are reported to the server 
      using my_printf_error(..) function. This function pushes error on the 
      error stack (unles told otherwise) and stores the first reported error
      so that it is send to the client.
      
      Additionally.
      
      - Function log_error(..) is moved to the Logger class.
      
      - Code is changed to consistently use Logger::report/log_error() for error 
      reporting.
      
      - Semantics of Backup_restore_ctx::fatal_error() has been changed to 
      discourage its use as an error reporting facility. Now it is an internal helper 
      method which moves the context object into error state. It is used only by the 
      class methods and it is made private. The idea is that context object should 
      move into error state only as a result of executing one of its methods (not 
      externally).
      
      - Improved error reporting in few places.
[26 Nov 2008 8:25] Rafal Somla
Fixed by the patch for BUG#40303, pushed into team tree on Tue Nov 25 20:44:28 2008.
[12 Dec 2008 6:25] Bugs System
Pushed into 6.0.9-alpha  (revid:rafal.somla@sun.com-20081125174419-gy7zbs1otdbtylz1) (version source revid:jorgen.loland@sun.com-20081128091358-4518qjv1cnz0f8vb) (pib:5)
[13 Dec 2008 17:40] Paul DuBois
Noted in 6.0.9 changelog.

Errors from a BACKUP DATABASE or RESTORE operation were shown by SHOW
WARNINGS as warnings, not errors.