Bug #38425 Online backup: RESTORE confused if summary section present in the preamble
Submitted: 29 Jul 2008 11:35 Modified: 30 Sep 2009 13:21
Reporter: Rafal Somla Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:mysql-6.0-backup OS:Any
Assigned to: Rafal Somla CPU Architecture:Any

[29 Jul 2008 11:35] Rafal Somla
Description:
When RESTORE command is started, backup image preamble is read. First the header and catalogue are read inside Backup_restore_ctx::preapre_for_restore() with read_header() and read_catalog().

However, according to the backup stream format, the backup image summary section can be present between the header and catalogue. If this happens, the code in prepare_for_restore() would not detect that and will confuse the summary section with image's catalogue. This can lead to serious problems including server crash.

How to repeat:
Code inspection.

This problem can't be reproduced in the current tree, because BACKUP command always appends the summary section at the end of the backup image.

Suggested fix:
Add the code detecting presence of summary section in the preamble and reading it. Like this:

  if (info->flags & BSTREAM_FLAG_INLINE_SUMMARY)
    if (read_summary(*info,*s))
    {
      info.fatal_error(...);
      return NULL
    }

Also, reading the summary section at the end of RESTORE should be guarded by BSTREAM_FLAG_INLINE_SUMMARY. This happens at the end of Backup_restore_ctx::do_restore() method.
[30 Sep 2009 13:21] Rafal Somla
It has been clarified recently, that the summary section of a backup image
can appear only at the end of a backup image - never in the preamble. Thus the reported problem does not exist any more.

A possibility for having the summary section earlier in the image is postponed for later versions of the image format.

See the "Backup Image Format (v1)" page in the doxygen docs of backup code for the most up-to-date documentation of the backup image format.