From 0df1b7c4733cd354b2e6e55e2de7e034fb3fe1c9 Mon Sep 17 00:00:00 2001 From: David Steele Date: Sun, 1 Mar 2015 22:43:32 -0500 Subject: [PATCH] Changed file sizes are now detected and stored in the manifest. Remove thread file minimums - they are unrealistic for a real db and hinder unit tests. --- lib/BackRest/Backup.pm | 22 ++++++++++++++++------ test/lib/BackRestTest/BackupTest.pm | 3 +++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/BackRest/Backup.pm b/lib/BackRest/Backup.pm index e51f326ba..c37e24803 100644 --- a/lib/BackRest/Backup.pm +++ b/lib/BackRest/Backup.pm @@ -33,7 +33,7 @@ my $bCompress; my $bHardLink; my $iThreadMax; my $iThreadLocalMax; -my $iThreadThreshold = 10; +#my $iThreadThreshold = 10; my $iSmallFileThreshold = 65536; my $bArchiveRequired; my $bNoStartStop; @@ -546,7 +546,7 @@ sub archive_compress &log(INFO, "archive to be compressed total ${lFileTotal}, size " . file_size_format($lFileSize)); # Init the thread variables - $iThreadLocalMax = thread_init(int($lFileTotal / $iThreadThreshold) + 1); + $iThreadLocalMax = thread_init($iThreadMax); my $iThreadIdx = 0; # Distribute files among the threads @@ -977,7 +977,7 @@ sub backup_file } # Build the thread queues - $iThreadLocalMax = thread_init(int($lFileTotal / $iThreadThreshold) + 1); + $iThreadLocalMax = thread_init($iThreadMax); &log(DEBUG, "actual threads ${iThreadLocalMax}/${iThreadMax}"); # Initialize the thread size array @@ -1093,7 +1093,8 @@ sub backup_file # If command is 'checksum' then record the checksum in the manifest elsif ($strCommand eq 'checksum') { - my $strChecksum = $strSplit[3]; # File checksum calculated by the thread + my $strChecksum = $strSplit[3]; # File checksum calculated by the thread + my $lFileSize = $strSplit[4]; # File size calculated by the thread # Checksum must be defined if (!defined($strChecksum)) @@ -1101,10 +1102,17 @@ sub backup_file confess &log(ASSERT, 'thread checksum messages must have strChecksum defined'); } + # Checksum must be defined + if (!defined($lFileSize)) + { + confess &log(ASSERT, 'thread checksum messages must have lFileSize defined'); + } + $oBackupManifest->set($strFileSection, $strFile, MANIFEST_SUBKEY_CHECKSUM, $strChecksum); + $oBackupManifest->set($strFileSection, $strFile, MANIFEST_SUBKEY_SIZE, $lFileSize + 0); # Log the checksum - &log (DEBUG, "write checksum ${strFileSection}:${strFile} into manifest: ${strChecksum}"); + &log (DEBUG, "write checksum ${strFileSection}:${strFile} into manifest: ${strChecksum} (${lFileSize})"); } } } @@ -1202,13 +1210,15 @@ sub backup_file_thread { # Write the checksum message into the master queue $oMasterQueue[$iThreadIdx]->enqueue("checksum|$oFileCopyMap{$strFile}{file_section}|" . - "$oFileCopyMap{$strFile}{file}|${strCopyChecksum}"); + "$oFileCopyMap{$strFile}{file}|${strCopyChecksum}|${lCopySize}"); } else { # Write it directly $oBackupManifest->set($oFileCopyMap{$strFile}{file_section}, $oFileCopyMap{$strFile}{file}, MANIFEST_SUBKEY_CHECKSUM, $strCopyChecksum); + $oBackupManifest->set($oFileCopyMap{$strFile}{file_section}, $oFileCopyMap{$strFile}{file}, + MANIFEST_SUBKEY_SIZE, $lCopySize + 0); } # Output information about the file to be checksummed diff --git a/test/lib/BackRestTest/BackupTest.pm b/test/lib/BackRestTest/BackupTest.pm index 994bab6db..e3c74d05e 100755 --- a/test/lib/BackRestTest/BackupTest.pm +++ b/test/lib/BackRestTest/BackupTest.pm @@ -1723,6 +1723,9 @@ sub BackRestTestBackup_Test BackRestTestBackup_BackupBegin($strType, $strStanza, $bRemote, "remove files during backup", true, true, 1); BackRestTestCommon_ExecuteEnd(TEST_MANIFEST_BUILD); + BackRestTestBackup_ManifestFileCreate(\%oManifest, "tablespace:2", 'tablespace2c.txt', 'TBLSPCBIGGER', + 'dfcb8679956b734706cf87259d50c88f83e80e66', $lTime); + BackRestTestBackup_ManifestFileRemove(\%oManifest, 'base', 'base/base2.txt', true); $strBackup = BackRestTestBackup_BackupEnd($strType, $oFile, $bRemote, undef, \%oManifest, true);