From a9b9ec249234b9106f7c8a7615e227d1b7783a07 Mon Sep 17 00:00:00 2001 From: David Steele Date: Tue, 21 Apr 2015 09:45:03 -0400 Subject: [PATCH] v0.61: bug fix for uncompressed remote destination * Fixed a buffering error that could occur on large, highly-compressible files when copying to an uncompressed remote destination. The error was detected in the decompression code and resulted in a failed backup rather than corruption so it should not affect successful backups made with previous versions. --- README.md | 4 ++++ VERSION | 2 +- doc/doc.xml | 8 +++++++ lib/BackRest/Remote.pm | 4 ++-- test/lib/BackRestTest/FileTest.pm | 35 +++++++++++++++++++++++-------- 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 336234248..680e409c2 100644 --- a/README.md +++ b/README.md @@ -698,6 +698,10 @@ example: db-path=/data/db ## Release Notes +### v0.61: bug fix for uncompressed remote destination + +* Fixed a buffering error that could occur on large, highly-compressible files when copying to an uncompressed remote destination. The error was detected in the decompression code and resulted in a failed backup rather than corruption so it should not affect successful backups made with previous versions. + ### v0.60: better version support and WAL improvements * Pushing duplicate WAL now generates an error. This worked before only if checksums were disabled. diff --git a/VERSION b/VERSION index 08072c181..6e8cb1efc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.60 +0.61 diff --git a/doc/doc.xml b/doc/doc.xml index acc630b8a..913fc5b06 100644 --- a/doc/doc.xml +++ b/doc/doc.xml @@ -656,6 +656,14 @@ Run a full backup on the db stanza. --type can + + + + Fixed a buffering error that could occur on large, highly-compressible files when copying to an uncompressed remote destination. The error was detected in the decompression code and resulted in a failed backup rather than corruption so it should not affect successful backups made with previous versions. + + + + diff --git a/lib/BackRest/Remote.pm b/lib/BackRest/Remote.pm index 7689e6cbf..e964016ed 100644 --- a/lib/BackRest/Remote.pm +++ b/lib/BackRest/Remote.pm @@ -755,7 +755,7 @@ sub binary_xfer last; } } - while ($iZLibStatus == Z_OK && $iUncompressedBufferSize > 0 && $iBlockSize > 0); + while ($iZLibStatus != Z_STREAM_END && $iUncompressedBufferSize > 0 && $iBlockSize > 0); } } while ($iBlockSize > 0); @@ -1003,7 +1003,7 @@ sub binary_xfer $iBlockSize = 0; } } - while ($iZLibStatus == Z_OK && $iUncompressedBufferSize > 0 && $iBlockSize > 0); + while ($iZLibStatus != Z_STREAM_END && $iUncompressedBufferSize > 0 && $iBlockSize > 0); } } } diff --git a/test/lib/BackRestTest/FileTest.pm b/test/lib/BackRestTest/FileTest.pm index 25cffe385..676435dc0 100755 --- a/test/lib/BackRestTest/FileTest.pm +++ b/test/lib/BackRestTest/FileTest.pm @@ -1042,7 +1042,7 @@ sub BackRestTestFile_Test $iRun = 0; # Loop through small/large - for (my $bLarge = false; $bLarge <= 2; $bLarge++) + for (my $iLarge = 0; $iLarge <= 3; $iLarge++) { # Loop through backup local vs remote for (my $bBackupRemote = 0; $bBackupRemote <= 1; $bBackupRemote++) @@ -1075,13 +1075,13 @@ sub BackRestTestFile_Test for (my $bDestinationPathType = 0; $bDestinationPathType <= 1; $bDestinationPathType++) { # Loop through source missing/present - for (my $bSourceMissing = 0; $bSourceMissing <= !$bLarge; $bSourceMissing++) + for (my $bSourceMissing = 0; $bSourceMissing <= !$iLarge; $bSourceMissing++) { # Loop through source ignore/require - for (my $bSourceIgnoreMissing = 0; $bSourceIgnoreMissing <= !$bLarge; $bSourceIgnoreMissing++) + for (my $bSourceIgnoreMissing = 0; $bSourceIgnoreMissing <= !$iLarge; $bSourceIgnoreMissing++) { # Loop through checksum append - for (my $bChecksumAppend = 0; $bChecksumAppend <= !$bLarge; $bChecksumAppend++) + for (my $bChecksumAppend = 0; $bChecksumAppend <= !$iLarge; $bChecksumAppend++) { # Loop through source compression for (my $bSourceCompressed = 0; $bSourceCompressed <= !$bSourceMissing; $bSourceCompressed++) @@ -1096,7 +1096,7 @@ sub BackRestTestFile_Test my $strDestinationPath = $bDestinationPathType ? 'db' : 'backup'; if (!BackRestTestCommon_Run(++$iRun, - "lrg ${bLarge}, rmt " . + "lrg ${iLarge}, rmt " . (defined($strRemote) && ($strRemote eq $strSourcePath || $strRemote eq $strDestinationPath) ? 1 : 0) . ', srcpth ' . (defined($strRemote) && $strRemote eq $strSourcePath ? 'rmt' : 'lcl') . @@ -1124,12 +1124,24 @@ sub BackRestTestFile_Test if (!$bSourceMissing) { - if ($bLarge) + if ($iLarge) { $strSourceFile .= '.bin'; $strDestinationFile .= '.bin'; - BackRestTestCommon_Execute('cp ' . BackRestTestCommon_DataPathGet() . "/test.archive${bLarge}.bin ${strSourceFile}"); + if ($iLarge < 3) + { + BackRestTestCommon_Execute('cp ' . BackRestTestCommon_DataPathGet() . + "/test.archive${iLarge}.bin ${strSourceFile}"); + } + else + { + for (my $iTableSizeIdx = 0; $iTableSizeIdx < 100; $iTableSizeIdx++) + { + BackRestTestCommon_Execute('cat ' . BackRestTestCommon_DataPathGet() . + "/test.table.bin >> ${strSourceFile}"); + } + } } else { @@ -1139,16 +1151,21 @@ sub BackRestTestFile_Test system("echo 'TESTDATA' > ${strSourceFile}"); } - if ($bLarge == 1) + if ($iLarge == 1) { $strSourceHash = 'c2e63b6a49d53a53d6df1aa6b70c7c16747ca099'; $iSourceSize = 16777216; } - elsif ($bLarge == 2) + elsif ($iLarge == 2) { $strSourceHash = '1c7e00fd09b9dd11fc2966590b3e3274645dd031'; $iSourceSize = 16777216; } + elsif ($iLarge == 3) + { + $strSourceHash = 'c23a89d47c7a006fcda51da0cc95993dc9aad995'; + $iSourceSize = 104857600; + } else { $strSourceHash = '06364afe79d801433188262478a76d19777ef351';