Bug #36586 Online backup stream library can miss end of a stream.
Submitted: 8 May 2008 7:34 Modified: 11 Aug 2008 23:47
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: Øystein Grøvlen CPU Architecture:Any

[8 May 2008 7:34] Rafal Somla
Description:
There is a low level function bstream_read_part() function in backup/stream_v1_transport.c which reads bytes from an underlying stream and stores them in a given buffer. This function uses as_read() macro to read from the underlying stream but it doesn't check for end of stream condition which can lead to problems.

How to repeat:
Code inspection (backup/stream_v1_transport.c, around line 1480).

Suggested fix:
Something like this:

@@ -1480,7 +1480,8 @@ int bstream_read_part(backup_stream *s, 
     saved= *data;
     data->end= data->begin + howmuch;
 
-    as_read(&s->stream,data,buf);
+    if (as_read(&s->stream,data,buf) == BSTREAM_EOS)
+      s->state= EOS;
 
     s->buf.begin += data->begin - saved.begin;
     s->buf.pos= s->buf.begin;
[13 May 2008 5:43] Rafal Somla
After closing this, check if it fixes BUG#36571.
[9 Jun 2008 8:27] Øystein Grøvlen
Made new version of test that changes mysql-test/lib/mtr_report.pl in order to ignore restore failure in test.
[16 Jun 2008 9:33] 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/47897

2638 Oystein Grovlen	2008-06-16
      BUG#36586 Online backup stream library can miss end of a stream.
      Make sure end-of-stream is detected.
[17 Jun 2008 11:28] 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/47989

2638 Oystein Grovlen	2008-06-17
      BUG#36586 Online backup stream library can miss end of a stream.
      Make sure end-of-stream is detected.
[18 Jun 2008 10:09] Sergey Vojtovich
Approved with wishlist.
[19 Jun 2008 9:15] 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/48147

2638 Oystein Grovlen	2008-06-19
      BUG#36586 Online backup stream library can miss end of a stream.
      Make sure end-of-stream is detected.  Before this fix, a restore
      of a multi-block backup image would never complete.
[19 Jun 2008 13:13] Chuck Bell
Patch approved pending one mandatory correction in the test.

+---source include/have_64bit.inc

should be

+--source include/have_64bit.inc

^^^
[23 Jun 2008 14:53] 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/48338

2638 Oystein Grovlen	2008-06-23
      BUG#36586 Online backup stream library can miss end of a stream.
      Make sure end-of-stream is detected.  Before this fix, a restore
      of a multi-block backup image would never complete.
[23 Jun 2008 15:01] 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/48339

2638 Oystein Grovlen	2008-06-23
      BUG#36586 Online backup stream library can miss end of a stream.
      Make sure end-of-stream is detected.  Before this fix, a restore
      of a multi-block backup image would never complete.
[23 Jun 2008 15:15] Øystein Grøvlen
Patch has been push to mysql-6.0-backup branch.
[7 Aug 2008 12:28] Øystein Grøvlen
Patch has been pushed to 6.0-main.
[8 Aug 2008 12:44] Øystein Grøvlen
This bug is fixed in 6.0.6.
[11 Aug 2008 23:47] Paul DuBois
Noted in 6.0.6 changelog.

The online backup stream library could fail to detect the end of a
backup stream.
[12 Aug 2008 16:28] Paul DuBois
Updated changelog entry:

On 64-bit platforms, BACKUP DATABASE hung for backups of more than
32KB.
[14 Sep 2008 3:38] Bugs System
Pushed into 6.0.8-alpha  (revid:oystein.grovlen@sun.com-20080623145335-nd4wqfbqe5rzgtsx) (version source revid:konstantin@mysql.com-20080911140522-3cmh8tsfep5j6dsj) (pib:3)