pgbackrest.git / summary / log / commit / refs

commit    6ef2167e972039e67668d7f7700aab505d0ea595
Author:   David Steele <david@pgmasters.net>
Date:     Thu Nov 16 22:18:51 2017 +0000

    Fixed an issue retrieving WAL for old database versions.
    
    After a stanza-upgrade it should still be possible to restore backups from the previous version and perform recovery with archive-get. However, archive-get only checked the most recent db version/id and failed.
    
    Also clean up some issues when the same db version/id appears multiple times in the history.
    
    Fixed by Cynthia Shang.
    Reported by Clinton Adams.


doc/xml/release.xml | 16 +- lib/pgBackRest/Archive/Base.pm | 52 +++- lib/pgBackRest/Archive/Get/Get.pm | 9 +- lib/pgBackRest/Archive/Info.pm | 59 ++++- test/expect/mock-archive-001.log | 25 +- test/expect/mock-archive-002.log | 18 +- test/expect/mock-archive-003.log | 9 +- test/expect/mock-stanza-001.log | 99 ++++++- test/expect/mock-stanza-002.log | 77 +++++- test/expect/mock-stanza-003.log | 98 ++++++- test/lib/pgBackRestTest/Common/DefineTest.pm | 13 +- .../Module/Archive/ArchiveGetTest.pm | 284 +++++++++++++++++++++ .../Module/Archive/ArchiveInfoUnitTest.pm | 52 ++++ .../pgBackRestTest/Module/Mock/MockArchiveTest.pm | 42 ++- .../pgBackRestTest/Module/Mock/MockStanzaTest.pm | 28 +- 15 files changed, 815 insertions(+), 66 deletions(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 342738f16..764241960 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -26,7 +26,16 @@ <release-item-contributor id="wilson.javier"/> </release-item-contributor-list> - <p>Fix incorrect WAL offset for 32-bit architectures.</p> + <p>Fixed incorrect WAL offset for 32-bit architectures.</p> + </release-item> + + <release-item> + <release-item-contributor-list> + <release-item-ideator id="adams.clinton"/> + <release-item-contributor id="shang.cynthia"/> + </release-item-contributor-list> + + <p>Fixed an issue retrieving WAL for old database versions. After a <cmd>stanza-upgrade</cmd> it should still be possible to restore backups from the previous version and perform recovery with <cmd>archive-get</cmd>. However, archive-get only checked the most recent db version/id and failed. Also clean up some issues when the same db version/id appears multiple times in the history.</p> </release-item> </release-bug-list> @@ -3530,6 +3539,11 @@ </contributor> <!-- The order of other contributors is alpha by name --> + <contributor id="adams.clinton"> + <contributor-name-display>Clinton Adams</contributor-name-display> + <contributor-id type="github">clad</contributor-id> + </contributor> + <contributor id="avellar.leonardo"> <contributor-name-display>Leonardo GG Avellar</contributor-name-display> <contributor-id type="github">L30Bola</contributor-id> diff --git a/lib/pgBackRest/Archive/Base.pm b/lib/pgBackRest/Archive/Base.pm index e863e30d8..f90d00b62 100644 --- a/lib/pgBackRest/Archive/Base.pm +++ b/lib/pgBackRest/Archive/Base.pm @@ -55,7 +55,8 @@ sub new } #################################################################################################################################### -# getCheck +# getCheck - Given a specific database version and system-id, find a file in the archive. If no database info was passed, the +# current database will be used. #################################################################################################################################### sub getCheck { @@ -67,16 +68,19 @@ sub getCheck $strOperation, $strDbVersion, $ullDbSysId, - $strWalFile, + $strFile, + $bCheck, ) = logDebugParam ( __PACKAGE__ . '->getCheck', \@_, {name => 'strDbVersion', required => false}, {name => 'ullDbSysId', required => false}, - {name => 'strWalFile', required => false}, + {name => 'strFile', required => false}, + {name => 'bCheck', required => false, default => true}, ); + my @stryArchiveId = (); my $strArchiveId; my $strArchiveFile; my $strCipherPass; @@ -92,18 +96,50 @@ sub getCheck if (!isRepoLocal()) { ($strArchiveId, $strArchiveFile, $strCipherPass) = protocolGet(CFGOPTVAL_REMOTE_TYPE_BACKUP)->cmdExecute( - OP_ARCHIVE_GET_CHECK, [$strDbVersion, $ullDbSysId, $strWalFile], true); + OP_ARCHIVE_GET_CHECK, [$strDbVersion, $ullDbSysId, $strFile, $bCheck], true); } else { my $oArchiveInfo = new pgBackRest::Archive::Info(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE), true); - # check that the archive info is compatible with the database - $strArchiveId = $oArchiveInfo->check($strDbVersion, $ullDbSysId); + # Check that the archive info is compatible with the database if required (not required for archive-get) + if ($bCheck) + { + push(@stryArchiveId, $oArchiveInfo->check($strDbVersion, $ullDbSysId)); + } + # Else if the database version and system-id are in the info history list then get a list of corresponding archiveIds + else + { + @stryArchiveId = $oArchiveInfo->archiveIdList($strDbVersion, $ullDbSysId); + } + + # Default the returned archiveId to the newest in the event the WAL segment is not found then the most recent archiveID will + # be returned. If none were found, then the preceding calls will error. + $strArchiveId = $stryArchiveId[0]; - if (defined($strWalFile)) + # If a file was passed to look for, then look for the file starting in the newest matching archiveId to the oldest + if (defined($strFile)) { - $strArchiveFile = walSegmentFind(storageRepo(), ${strArchiveId}, $strWalFile); + foreach my $strId (@stryArchiveId) + { + # Then if it is a WAL segment, try to find it + if (walIsSegment($strFile)) + { + $strArchiveFile = walSegmentFind(storageRepo(), $strId, $strFile); + } + # Else if not a WAL segment, see if it exists in the archive dir + elsif (storageRepo()->exists(STORAGE_REPO_ARCHIVE . "/${strId}/${strFile}")) + { + $strArchiveFile = $strFile; + } + + # If the file was found, then return the archiveId where it was found + if (defined($strArchiveFile)) + { + $strArchiveId = $strId; + last; + } + } } # Get the encryption passphrase to read/write files (undefined if the repo is not encrypted) diff --git a/lib/pgBackRest/Archive/Get/Get.pm b/lib/pgBackRest/Archive/Get/Get.pm index cc6054eec..a976b69f9 100644 --- a/lib/pgBackRest/Archive/Get/Get.pm +++ b/lib/pgBackRest/Archive/Get/Get.pm @@ -100,14 +100,7 @@ sub get $strDestinationFile = walPath($strDestinationFile, cfgOption(CFGOPT_DB_PATH, false), cfgCommandName(cfgCommandGet())); # Get the wal segment filename - my ($strArchiveId, $strArchiveFile, $strCipherPass) = $self->getCheck( - undef, undef, walIsSegment($strSourceArchive) ? $strSourceArchive : undef); - - if (!defined($strArchiveFile) && !walIsSegment($strSourceArchive) && - $oStorageRepo->exists(STORAGE_REPO_ARCHIVE . "/${strArchiveId}/${strSourceArchive}")) - { - $strArchiveFile = $strSourceArchive; - } + my ($strArchiveId, $strArchiveFile, $strCipherPass) = $self->getCheck(undef, undef, $strSourceArchive, false); # If there are no matching archive files then there are two possibilities: # 1) The end of the archive stream has been reached, this is normal and a 1 will be returned diff --git a/lib/pgBackRest/Archive/Info.pm b/lib/pgBackRest/Archive/Info.pm index 876527261..b2bf71982 100644 --- a/lib/pgBackRest/Archive/Info.pm +++ b/lib/pgBackRest/Archive/Info.pm @@ -233,31 +233,66 @@ sub archiveId # If both the optional version and system-id are passed elsif (defined($strDbVersion) && defined($ullDbSysId)) { - # Get the version and system-id for all known databases - my $hDbList = $self->dbHistoryList(); + # Get the newest archiveId for the version/system-id passed + $strArchiveId = ($self->archiveIdList($strDbVersion, $ullDbSysId))[0]; + } + + # Return from function and log return values if any + return logDebugReturn + ( + $strOperation, + {name => 'strArchiveId', value => $strArchiveId} + ); +} - foreach my $iDbHistoryId (sort(keys(%$hDbList))) +#################################################################################################################################### +# archiveIdList +# +# Get a sorted list of the archive ids for the db-version and db-system-id passed. +#################################################################################################################################### +sub archiveIdList +{ + my $self = shift; + + # Assign function parameters, defaults, and log debug info + my + ( + $strOperation, + $strDbVersion, + $ullDbSysId, + ) = logDebugParam + ( + __PACKAGE__ . '->archiveIdList', \@_, + {name => 'strDbVersion'}, + {name => 'ullDbSysId'}, + ); + + my @stryArchiveId; + + # Get the version and system-id for all known databases + my $hDbList = $self->dbHistoryList(); + + foreach my $iDbHistoryId (sort {$a <=> $b} keys %$hDbList) + { + # If the version and system-id match then construct the archive id so that the constructed array has the newest match first + if (($hDbList->{$iDbHistoryId}{&INFO_DB_VERSION} eq $strDbVersion) && + ($hDbList->{$iDbHistoryId}{&INFO_SYSTEM_ID} eq $ullDbSysId)) { - # If the version and system-id match then construct the archive id - if (($hDbList->{$iDbHistoryId}{&INFO_DB_VERSION} eq $strDbVersion) && - ($hDbList->{$iDbHistoryId}{&INFO_SYSTEM_ID} eq $ullDbSysId)) - { - $strArchiveId = $strDbVersion . "-" . $iDbHistoryId; - } + unshift(@stryArchiveId, $strDbVersion . "-" . $iDbHistoryId); } } # If the archive id has still not been found, then error - if (!defined($strArchiveId)) + if (@stryArchiveId == 0) { - confess &log(ERROR, 'unable to retrieve the archive id'); + confess &log(ERROR, "unable to retrieve the archive id for database version '$strDbVersion' and system-id '$ullDbSysId'"); } # Return from function and log return values if any return logDebugReturn ( $strOperation, - {name => 'strArchiveId', value => $strArchiveId} + {name => 'stryArchiveId', value => \@stryArchiveId} ); } diff --git a/test/expect/mock-archive-001.log b/test/expect/mock-archive-001.log index d9eb9c83d..40fd174c3 100644 --- a/test/expect/mock-archive-001.log +++ b/test/expect/mock-archive-001.log @@ -116,7 +116,7 @@ P00 INFO: get WAL segment 000000010000000100000001 P00 DEBUG: Archive::Get::Get->get(): strDestinationFile = [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG, strSourceArchive = 000000010000000100000001 P00 DEBUG: Storage::Posix::Driver->new(): bFileSync = <true>, bPathSync = <true> P00 DEBUG: Storage::Local->new(): bAllowTemp = <true>, hRule = [hash], lBufferMax = 4194304, oDriver = [object], strCipherPassUser = <redacted>, strCipherType = aes-256-cbc, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strPathBase = [TEST_PATH]/db-master/repo, strTempExtension = pgbackrest.tmp -P00 DEBUG: Archive::Base->getCheck(): strDbVersion = [undef], strWalFile = 000000010000000100000001, ullDbSysId = [undef] +P00 DEBUG: Archive::Base->getCheck(): bCheck = false, strDbVersion = [undef], strFile = 000000010000000100000001, ullDbSysId = [undef] P00 DEBUG: Db::dbObjectGet(): bMasterOnly = true P00 DEBUG: Db->new(): iRemoteIdx = 1 P00 DEBUG: Db::dbObjectGet=>: iDbMasterIdx = 1, iDbStandbyIdx = [undef], oDbMaster = [object], oDbStandby = [undef] @@ -129,10 +129,9 @@ P00 DEBUG: Storage::Local->encryptionValid(): bEncrypted = true P00 DEBUG: Storage::Local->encryptionValid=>: bValid = true P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = true, rhyFilter = [undef], strCipherPass = <redacted>, xFileExp = [TEST_PATH]/db-master/repo/archive/db/archive.info P00 DEBUG: Storage::Base->get(): strCipherPass = [undef], xFile = [object] -P00 DEBUG: Archive::Info->check(): bRequired = <true>, strDbVersion = 9.4, ullDbSysId = 6353949018581704918 -P00 DEBUG: Archive::Info->archiveId(): strDbVersion = [undef], ullDbSysId = [undef] -P00 DEBUG: Archive::Info->archiveId=>: strArchiveId = 9.4-1 -P00 DEBUG: Archive::Info->check=>: strArchiveId = 9.4-1 +P00 DEBUG: Archive::Info->archiveIdList(): strDbVersion = 9.4, ullDbSysId = 6353949018581704918 +P00 DEBUG: Archive::Info->dbHistoryList=>: hDbHash = [hash] +P00 DEBUG: Archive::Info->archiveIdList=>: stryArchiveId = (9.4-1) P00 DEBUG: Archive::Common::walSegmentFind(): iWaitSeconds = [undef], oStorageRepo = [object], strArchiveId = 9.4-1, strWalSegment = 000000010000000100000001 P00 DEBUG: Storage::Local->list(): bIgnoreMissing = true, strExpression = ^000000010000000100000001-[0-f]{40}(\.gz){0,1}$, strPathExp = <REPO:ARCHIVE>/9.4-1/0000000100000001, strSortOrder = <forward> P00 DEBUG: Storage::Local->list=>: stryFileList = (000000010000000100000001-72b9da071c13957fb4ca31f05dbd5c644297c2f7) @@ -168,9 +167,14 @@ P00 INFO: archive-push command end: aborted with exception [044] ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: archive-get command begin [BACKREST-VERSION]: --no-compress --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --repo-cipher-pass=<redacted> --repo-cipher-type=aes-256-cbc --repo-path=[TEST_PATH]/db-master/repo --stanza=db P00 INFO: get WAL segment 000000010000000100000001 -P00 ERROR: [044]: WAL segment version 9.4 does not match archive version 8.0 - HINT: are you archiving to the correct stanza? -P00 INFO: archive-get command end: aborted with exception [044] +P00 INFO: archive-get command end: completed successfully + +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000001 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG +------------------------------------------------------------------------------------------------------------------------------------ +P00 INFO: archive-get command begin [BACKREST-VERSION]: --no-compress --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --repo-cipher-pass=<redacted> --repo-cipher-type=aes-256-cbc --repo-path=[TEST_PATH]/db-master/repo --stanza=db +P00 INFO: get WAL segment 000000010000000100000001 +P00 ERROR: [125]: unable to retrieve the archive id for database version '9.4' and system-id '6353949018581704918' +P00 INFO: archive-get command end: aborted with exception [125] > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 ------------------------------------------------------------------------------------------------------------------------------------ @@ -183,9 +187,8 @@ P00 INFO: archive-push command end: aborted with exception [044] ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: archive-get command begin [BACKREST-VERSION]: --no-compress --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --repo-cipher-pass=<redacted> --repo-cipher-type=aes-256-cbc --repo-path=[TEST_PATH]/db-master/repo --stanza=db P00 INFO: get WAL segment 000000010000000100000001 -P00 ERROR: [044]: WAL segment system-id 6353949018581704918 does not match archive system-id 5000900090001855000 - HINT: are you archiving to the correct stanza? -P00 INFO: archive-get command end: aborted with exception [044] +P00 ERROR: [125]: unable to retrieve the archive id for database version '9.4' and system-id '6353949018581704918' +P00 INFO: archive-get command end: aborted with exception [125] stop db stanza (db-master host) > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db stop diff --git a/test/expect/mock-archive-002.log b/test/expect/mock-archive-002.log index 3be95a0e6..ace45f029 100644 --- a/test/expect/mock-archive-002.log +++ b/test/expect/mock-archive-002.log @@ -103,7 +103,7 @@ P00 DEBUG: Protocol::Helper::protocolGet: create (cached) remote protocol P00 DEBUG: Protocol::Remote::Master->new(): iBufferMax = 4194304, iCompressLevel = 3, iCompressLevelNetwork = 1, iProtocolTimeout = 60, iSshPort = [undef], strCommand = [BACKREST-BIN] --buffer-size=4194304 --command=archive-get --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/backup/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --protocol-timeout=60 --stanza=db --type=backup remote, strCommandSSH = ssh, strHost = backup, strUser = [USER-1] P00 DEBUG: Protocol::Command::Master->new(): iBufferMax = 4194304, iCompressLevel = 3, iCompressLevelNetwork = 1, iProtocolTimeout = 60, strCommand = ssh -o LogLevel=error -o Compression=no -o PasswordAuthentication=no backrest@backup '[BACKREST-BIN] --buffer-size=4194304 --command=archive-get --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/backup/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --protocol-timeout=60 --stanza=db --type=backup remote', strId = remote process on 'backup', strName = remote P00 DEBUG: Protocol::Storage::Remote->new(): oProtocol = [object] -P00 DEBUG: Archive::Base->getCheck(): strDbVersion = [undef], strWalFile = 000000010000000100000001, ullDbSysId = [undef] +P00 DEBUG: Archive::Base->getCheck(): bCheck = false, strDbVersion = [undef], strFile = 000000010000000100000001, ullDbSysId = [undef] P00 DEBUG: Db::dbObjectGet(): bMasterOnly = true P00 DEBUG: Db->new(): iRemoteIdx = 1 P00 DEBUG: Db::dbObjectGet=>: iDbMasterIdx = 1, iDbStandbyIdx = [undef], oDbMaster = [object], oDbStandby = [undef] @@ -144,9 +144,14 @@ P00 INFO: archive-push command end: aborted with exception [044] ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: archive-get command begin [BACKREST-VERSION]: --backup-cmd=[BACKREST-BIN] --backup-config=[TEST_PATH]/backup/pgbackrest.conf --backup-host=backup --backup-user=[USER-1] --no-compress --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --stanza=db P00 INFO: get WAL segment 000000010000000100000001 -P00 ERROR: [044]: raised from remote process on 'backup': WAL segment version 9.4 does not match archive version 8.0 - HINT: are you archiving to the correct stanza? -P00 INFO: archive-get command end: aborted with exception [044] +P00 INFO: archive-get command end: completed successfully + +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000001 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG +------------------------------------------------------------------------------------------------------------------------------------ +P00 INFO: archive-get command begin [BACKREST-VERSION]: --backup-cmd=[BACKREST-BIN] --backup-config=[TEST_PATH]/backup/pgbackrest.conf --backup-host=backup --backup-user=[USER-1] --no-compress --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --stanza=db +P00 INFO: get WAL segment 000000010000000100000001 +P00 ERROR: [125]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '6353949018581704918' +P00 INFO: archive-get command end: aborted with exception [125] > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 ------------------------------------------------------------------------------------------------------------------------------------ @@ -159,9 +164,8 @@ P00 INFO: archive-push command end: aborted with exception [044] ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: archive-get command begin [BACKREST-VERSION]: --backup-cmd=[BACKREST-BIN] --backup-config=[TEST_PATH]/backup/pgbackrest.conf --backup-host=backup --backup-user=[USER-1] --no-compress --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --stanza=db P00 INFO: get WAL segment 000000010000000100000001 -P00 ERROR: [044]: raised from remote process on 'backup': WAL segment system-id 6353949018581704918 does not match archive system-id 5000900090001855000 - HINT: are you archiving to the correct stanza? -P00 INFO: archive-get command end: aborted with exception [044] +P00 ERROR: [125]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '6353949018581704918' +P00 INFO: archive-get command end: aborted with exception [125] stop db stanza (db-master host) > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db stop diff --git a/test/expect/mock-archive-003.log b/test/expect/mock-archive-003.log index 8a466d899..4525b184b 100644 --- a/test/expect/mock-archive-003.log +++ b/test/expect/mock-archive-003.log @@ -69,8 +69,10 @@ P00 ERROR: [044]: raised from remote process on 'backup': WAL segment version 9 > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000001 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG ------------------------------------------------------------------------------------------------------------------------------------ -P00 ERROR: [044]: raised from remote process on 'backup': WAL segment version 9.4 does not match archive version 8.0 - HINT: are you archiving to the correct stanza? + +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000001 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG +------------------------------------------------------------------------------------------------------------------------------------ +P00 ERROR: [125]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '6353949018581704918' > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 ------------------------------------------------------------------------------------------------------------------------------------ @@ -79,8 +81,7 @@ P00 ERROR: [044]: raised from remote process on 'backup': WAL segment system-id > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000001 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG ------------------------------------------------------------------------------------------------------------------------------------ -P00 ERROR: [044]: raised from remote process on 'backup': WAL segment system-id 6353949018581704918 does not match archive system-id 5000900090001855000 - HINT: are you archiving to the correct stanza? +P00 ERROR: [125]: raised from remote process on 'backup': unable to retrieve the archive id for database version '9.4' and system-id '6353949018581704918' stop db stanza (db-master host) > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db stop diff --git a/test/expect/mock-stanza-001.log b/test/expect/mock-stanza-001.log index 0f291b5f4..b34b2c5fc 100644 --- a/test/expect/mock-stanza-001.log +++ b/test/expect/mock-stanza-001.log @@ -461,6 +461,49 @@ db-version="9.3" [db:history] 1={"db-id":6395542721432104958,"db-version":"9.3"} +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +------------------------------------------------------------------------------------------------------------------------------------ +P00 INFO: archive-push command begin [BACKREST-VERSION]: --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=debug --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --repo-path=[TEST_PATH]/db-master/repo --stanza=db +P00 DEBUG: Archive::Push::Push->process(): strWalPathFile = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Archive::Push::File::archivePushFile(): bCompress = true, iCompressLevel = 3, strWalFile = 000000010000000100000002, strWalPath = [TEST_PATH]/db-master/db/base/pg_xlog +P00 DEBUG: Storage::Posix::Driver->new(): bFileSync = <true>, bPathSync = <true> +P00 DEBUG: Storage::Local->new(): bAllowTemp = <true>, hRule = [hash], lBufferMax = 4194304, oDriver = [object], strCipherPassUser = [undef], strCipherType = [undef], strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strPathBase = [TEST_PATH]/db-master/repo, strTempExtension = pgbackrest.tmp +P00 DEBUG: Archive::Common::walInfo(): strWalFile = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Archive::Common::walInfo=>: strDbVersion = 9.3, ullDbSysId = 6395542721432104958 +P00 DEBUG: Archive::Push::File::archivePushCheck(): strArchiveFile = 000000010000000100000002, strDbVersion = 9.3, strWalFile = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002, ullDbSysId = 6395542721432104958 +P00 DEBUG: Archive::Info->new(): bIgnoreMissing = <false>, bLoad = <true>, bRequired = <true>, strArchiveClusterPath = [TEST_PATH]/db-master/repo/archive/db, strCipherPassSub = [undef] +P00 DEBUG: Storage::Local->encrypted(): bIgnoreMissing = true, strFileName = [TEST_PATH]/db-master/repo/archive/db/archive.info +P00 DEBUG: Storage::Local->encrypted=>: bEncrypted = false +P00 DEBUG: Storage::Local->encryptionValid(): bEncrypted = false +P00 DEBUG: Storage::Local->encryptionValid=>: bValid = true +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = true, rhyFilter = [undef], strCipherPass = [undef], xFileExp = [TEST_PATH]/db-master/repo/archive/db/archive.info +P00 DEBUG: Storage::Base->get(): strCipherPass = [undef], xFile = [object] +P00 DEBUG: Archive::Info->check(): bRequired = <true>, strDbVersion = 9.3, ullDbSysId = 6395542721432104958 +P00 DEBUG: Archive::Info->archiveId(): strDbVersion = [undef], ullDbSysId = [undef] +P00 DEBUG: Archive::Info->archiveId=>: strArchiveId = 9.3-1 +P00 DEBUG: Archive::Info->check=>: strArchiveId = 9.3-1 +P00 DEBUG: Archive::Common::walSegmentFind(): iWaitSeconds = [undef], oStorageRepo = [object], strArchiveId = 9.3-1, strWalSegment = 000000010000000100000002 +P00 DEBUG: Storage::Local->list(): bIgnoreMissing = true, strExpression = ^000000010000000100000002-[0-f]{40}(\.gz){0,1}$, strPathExp = <REPO:ARCHIVE>/9.3-1/0000000100000001, strSortOrder = <forward> +P00 DEBUG: Storage::Local->list=>: stryFileList = () +P00 DEBUG: Archive::Common::walSegmentFind=>: strWalFileName = [undef] +P00 DEBUG: Archive::Push::File::archivePushCheck=>: strArchiveId = 9.3-1, strChecksum = [undef], strCipherPass = [undef], strWarning = [undef] +P00 DEBUG: Storage::Posix::Driver->new(): bFileSync = <true>, bPathSync = <true> +P00 DEBUG: Storage::Local->new(): bAllowTemp = <true>, hRule = [undef], lBufferMax = 4194304, oDriver = [object], strCipherPassUser = [undef], strCipherType = [undef], strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strPathBase = [TEST_PATH]/db-master/db/base, strTempExtension = pgbackrest.tmp +P00 DEBUG: Storage::Local->hashSize(): xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = <false>, rhyFilter = [undef], strCipherPass = [undef], xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Storage::Local->hashSize=>: lSize = 16777216, strHash = f5035e2c3b83a9c32660f959b23451e78f7438f7 +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = <false>, rhyFilter = ({rxyParam => ({iLevel => 3}), strClass => pgBackRest::Storage::Filter::Gzip}), strCipherPass = [undef], xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Storage::Local->openWrite(): bAtomic = true, bPathCreate = true, lTimestamp = [undef], rhyFilter = [undef], strCipherPass = [undef], strGroup = [undef], strMode = <0640>, strUser = [undef], xFileExp = <REPO:ARCHIVE>/9.3-1/000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz +P00 DEBUG: Storage::Base->copy(): xDestinationFile = [object], xSourceFile = [object] +P00 DEBUG: Archive::Push::File::archivePushFile=>: strWarning = [undef] +P00 INFO: pushed WAL segment 000000010000000100000002 +P00 DEBUG: Common::Exit::exitSafe(): iExitCode = 0, oException = [undef], strSignal = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy(): bComplete = true, iRemoteIdx = [undef], strRemoteType = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy=>: iExitStatus = 0 +P00 DEBUG: Common::Lock::lockRelease(): bFailOnNoLock = false +P00 INFO: archive-push command end: completed successfully +P00 DEBUG: Common::Exit::exitSafe=>: iExitCode = 0 + > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --log-level-console=warn --archive-queue-max=33554432 --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 ------------------------------------------------------------------------------------------------------------------------------------ P00 ERROR: [044]: WAL segment version 9.4 does not match archive version 9.3 @@ -507,6 +550,47 @@ db-version="9.4" 1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000002 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG +------------------------------------------------------------------------------------------------------------------------------------ +P00 INFO: archive-get command begin [BACKREST-VERSION]: --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=debug --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --repo-path=[TEST_PATH]/db-master/repo --stanza=db +P00 INFO: get WAL segment 000000010000000100000002 +P00 DEBUG: Archive::Get::Get->get(): strDestinationFile = [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG, strSourceArchive = 000000010000000100000002 +P00 DEBUG: Storage::Posix::Driver->new(): bFileSync = <true>, bPathSync = <true> +P00 DEBUG: Storage::Local->new(): bAllowTemp = <true>, hRule = [hash], lBufferMax = 4194304, oDriver = [object], strCipherPassUser = [undef], strCipherType = [undef], strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strPathBase = [TEST_PATH]/db-master/repo, strTempExtension = pgbackrest.tmp +P00 DEBUG: Archive::Base->getCheck(): bCheck = false, strDbVersion = [undef], strFile = 000000010000000100000002, ullDbSysId = [undef] +P00 DEBUG: Db::dbObjectGet(): bMasterOnly = true +P00 DEBUG: Db->new(): iRemoteIdx = 1 +P00 DEBUG: Db::dbObjectGet=>: iDbMasterIdx = 1, iDbStandbyIdx = [undef], oDbMaster = [object], oDbStandby = [undef] +P00 DEBUG: Db->info(): strDbPath = <[TEST_PATH]/db-master/db/base> +P00 DEBUG: Db->info=>: iDbCatalogVersion = 201306121, iDbControlVersion = 937, strDbVersion = 9.3, ullDbSysId = 6395542721432104958 +P00 DEBUG: Archive::Info->new(): bIgnoreMissing = <false>, bLoad = <true>, bRequired = true, strArchiveClusterPath = [TEST_PATH]/db-master/repo/archive/db, strCipherPassSub = [undef] +P00 DEBUG: Storage::Local->encrypted(): bIgnoreMissing = true, strFileName = [TEST_PATH]/db-master/repo/archive/db/archive.info +P00 DEBUG: Storage::Local->encrypted=>: bEncrypted = false +P00 DEBUG: Storage::Local->encryptionValid(): bEncrypted = false +P00 DEBUG: Storage::Local->encryptionValid=>: bValid = true +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = true, rhyFilter = [undef], strCipherPass = [undef], xFileExp = [TEST_PATH]/db-master/repo/archive/db/archive.info +P00 DEBUG: Storage::Base->get(): strCipherPass = [undef], xFile = [object] +P00 DEBUG: Archive::Info->archiveIdList(): strDbVersion = 9.3, ullDbSysId = 6395542721432104958 +P00 DEBUG: Archive::Info->dbHistoryList=>: hDbHash = [hash] +P00 DEBUG: Archive::Info->archiveIdList=>: stryArchiveId = (9.3-1) +P00 DEBUG: Archive::Common::walSegmentFind(): iWaitSeconds = [undef], oStorageRepo = [object], strArchiveId = 9.3-1, strWalSegment = 000000010000000100000002 +P00 DEBUG: Storage::Local->list(): bIgnoreMissing = true, strExpression = ^000000010000000100000002-[0-f]{40}(\.gz){0,1}$, strPathExp = <REPO:ARCHIVE>/9.3-1/0000000100000001, strSortOrder = <forward> +P00 DEBUG: Storage::Local->list=>: stryFileList = (000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz) +P00 DEBUG: Archive::Common::walSegmentFind=>: strWalFileName = 000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz +P00 DEBUG: Archive::Base->getCheck=>: strArchiveFile = 000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz, strArchiveId = 9.3-1, strCipherPass = [undef] +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = <false>, rhyFilter = [undef], strCipherPass = [undef], xFileExp = <REPO:ARCHIVE>/9.3-1/000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz +P00 DEBUG: Storage::Posix::Driver->new(): bFileSync = <true>, bPathSync = <true> +P00 DEBUG: Storage::Local->new(): bAllowTemp = <true>, hRule = [undef], lBufferMax = 4194304, oDriver = [object], strCipherPassUser = [undef], strCipherType = [undef], strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strPathBase = [TEST_PATH]/db-master/db/base, strTempExtension = pgbackrest.tmp +P00 DEBUG: Storage::Local->openWrite(): bAtomic = <false>, bPathCreate = <false>, lTimestamp = [undef], rhyFilter = ({rxyParam => ({strCompressType => decompress}), strClass => pgBackRest::Storage::Filter::Gzip}), strCipherPass = [undef], strGroup = [undef], strMode = <0640>, strUser = [undef], xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG +P00 DEBUG: Storage::Base->copy(): xDestinationFile = [object], xSourceFile = [object] +P00 DEBUG: Archive::Get::Get->get=>: iResult = 0 +P00 DEBUG: Common::Exit::exitSafe(): iExitCode = 0, oException = [undef], strSignal = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy(): bComplete = true, iRemoteIdx = [undef], strRemoteType = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy=>: iExitStatus = 0 +P00 DEBUG: Common::Lock::lockRelease(): bFailOnNoLock = false +P00 INFO: archive-get command end: completed successfully +P00 DEBUG: Common::Exit::exitSafe=>: iExitCode = 0 + > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --log-level-console=warn --archive-queue-max=33554432 --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 ------------------------------------------------------------------------------------------------------------------------------------ @@ -514,7 +598,6 @@ stanza-create db - use force to recreate the stanza producing mismatched info hi > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db --log-level-console=detail --no-online --force stanza-create ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: stanza-create command begin [BACKREST-VERSION]: --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --force --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-path=[TEST_PATH]/db-master/log --no-online --protocol-timeout=60 --repo-path=[TEST_PATH]/db-master/repo --stanza=db -P00 WARN: found empty directory [TEST_PATH]/db-master/repo/archive/db/9.3-1 P00 INFO: stanza-create command end: completed successfully + supplemental file: [TEST_PATH]/db-master/repo/backup/db/backup.info @@ -548,13 +631,13 @@ db-system-id=6353949018581704918 db-version="9.4" [db:history] +1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} stanza-create db - use force to recreate the stanza producing mismatched db-id (db-master host) > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db --log-level-console=detail --no-online --force stanza-create ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: stanza-create command begin [BACKREST-VERSION]: --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --force --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-path=[TEST_PATH]/db-master/log --no-online --protocol-timeout=60 --repo-path=[TEST_PATH]/db-master/repo --stanza=db -P00 WARN: found empty directory [TEST_PATH]/db-master/repo/archive/db/9.3-1 P00 INFO: stanza-create command end: completed successfully + supplemental file: [TEST_PATH]/db-master/repo/backup/db/backup.info @@ -587,16 +670,19 @@ db-system-id=6353949018581704918 db-version="9.4" [db:history] +1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} full backup - create first full backup (db-master host) > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --retention-full=2 --no-online --log-level-console=detail --type=full --stanza=db backup ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: backup command begin [BACKREST-VERSION]: --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --no-online --protocol-timeout=60 --repo-path=[TEST_PATH]/db-master/repo --retention-full=2 --stanza=db --start-fast --type=full +P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG (16MB, 33%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 +P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 (16MB, 66%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 (16MB, 99%) checksum 1e34fa1c833090d94b9bb14f2a8d3153dca6ea27 P01 INFO: backup file [TEST_PATH]/db-master/db/base/global/pg_control (8KB, 100%) checksum 89373d9f2973502940de06bc5212489df3f8a912 P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/archive_status/000000010000000100000001.ready (0B, 100%) -P00 INFO: full backup size = 16MB +P00 INFO: full backup size = 48MB P00 INFO: new backup label = [BACKUP-FULL-1] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin [BACKREST-VERSION]: --config=[TEST_PATH]/db-master/pgbackrest.conf --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --repo-path=[TEST_PATH]/db-master/repo --retention-archive=2 --retention-full=2 --stanza=db @@ -646,6 +732,7 @@ db-system-id=6353949018581704918 db-version="9.4" [db:history] +1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} stanza-create db - use force to recreate the stanza from backups (db-master host) @@ -687,6 +774,7 @@ db-system-id=6353949018581704918 db-version="9.4" [db:history] +1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} stanza-upgrade db - successfully upgrade with XX.Y-Z (db-master host) @@ -729,6 +817,7 @@ db-system-id=6392579261579036436 db-version="9.5" [db:history] +1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} 3={"db-id":35184388866048,"db-version":"10.0"} 4={"db-id":6392579261579036436,"db-version":"9.5"} @@ -741,10 +830,12 @@ diff backup - diff changed to full backup (db-master host) ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: backup command begin [BACKREST-VERSION]: --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --no-online --protocol-timeout=60 --repo-path=[TEST_PATH]/db-master/repo --retention-full=2 --stanza=db --start-fast --type=diff P00 WARN: no prior backup exists, diff backup has been changed to full +P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG (16MB, 33%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 +P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 (16MB, 66%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 (16MB, 99%) checksum 15b1a1a35c26b17570aca7920980f0ad11c6d858 P01 INFO: backup file [TEST_PATH]/db-master/db/base/global/pg_control (8KB, 100%) checksum e28bf39d0a56bf9fabd4049b329fcae8878bfec6 P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/archive_status/000000010000000100000001.ready (0B, 100%) -P00 INFO: full backup size = 16MB +P00 INFO: full backup size = 48MB P00 INFO: new backup label = [BACKUP-FULL-2] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin [BACKREST-VERSION]: --config=[TEST_PATH]/db-master/pgbackrest.conf --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --repo-path=[TEST_PATH]/db-master/repo --retention-archive=2 --retention-full=2 --stanza=db diff --git a/test/expect/mock-stanza-002.log b/test/expect/mock-stanza-002.log index 4519dd468..10e996db2 100644 --- a/test/expect/mock-stanza-002.log +++ b/test/expect/mock-stanza-002.log @@ -316,6 +316,41 @@ db-version="9.3" [db:history] 1={"db-catalog-version":201306121,"db-control-version":937,"db-system-id":6395542721432104958,"db-version":"9.3"} +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +------------------------------------------------------------------------------------------------------------------------------------ +P00 INFO: archive-push command begin [BACKREST-VERSION]: --backup-cmd=[BACKREST-BIN] --backup-config=[TEST_PATH]/backup/pgbackrest.conf --backup-host=backup --backup-user=[USER-2] --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=debug --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --stanza=db +P00 DEBUG: Archive::Push::Push->process(): strWalPathFile = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Archive::Push::File::archivePushFile(): bCompress = true, iCompressLevel = 3, strWalFile = 000000010000000100000002, strWalPath = [TEST_PATH]/db-master/db/base/pg_xlog +P00 DEBUG: Protocol::Helper::protocolGet(): bCache = <true>, iProcessIdx = [undef], iRemoteIdx = <1>, strBackRestBin = [undef], strCommand = <archive-push>, strRemoteType = backup +P00 DEBUG: Protocol::Helper::protocolGet: create (cached) remote protocol +P00 DEBUG: Protocol::Remote::Master->new(): iBufferMax = 4194304, iCompressLevel = 3, iCompressLevelNetwork = 1, iProtocolTimeout = 60, iSshPort = [undef], strCommand = [BACKREST-BIN] --buffer-size=4194304 --command=archive-push --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/backup/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --protocol-timeout=60 --stanza=db --type=backup remote, strCommandSSH = ssh, strHost = backup, strUser = [USER-2] +P00 DEBUG: Protocol::Command::Master->new(): iBufferMax = 4194304, iCompressLevel = 3, iCompressLevelNetwork = 1, iProtocolTimeout = 60, strCommand = ssh -o LogLevel=error -o Compression=no -o PasswordAuthentication=no backrest@backup '[BACKREST-BIN] --buffer-size=4194304 --command=archive-push --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/backup/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --protocol-timeout=60 --stanza=db --type=backup remote', strId = remote process on 'backup', strName = remote +P00 DEBUG: Protocol::Storage::Remote->new(): oProtocol = [object] +P00 DEBUG: Archive::Common::walInfo(): strWalFile = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Archive::Common::walInfo=>: strDbVersion = 9.3, ullDbSysId = 6395542721432104958 +P00 DEBUG: Archive::Push::File::archivePushCheck(): strArchiveFile = 000000010000000100000002, strDbVersion = 9.3, strWalFile = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002, ullDbSysId = 6395542721432104958 +P00 DEBUG: Protocol::Helper::protocolGet(): bCache = <true>, iProcessIdx = [undef], iRemoteIdx = <1>, strBackRestBin = [undef], strCommand = <archive-push>, strRemoteType = backup +P00 DEBUG: Protocol::Helper::protocolGet: found cached protocol +P00 DEBUG: Archive::Push::File::archivePushCheck=>: strArchiveId = 9.3-1, strChecksum = [undef], strCipherPass = <redacted>, strWarning = [undef] +P00 DEBUG: Storage::Posix::Driver->new(): bFileSync = <true>, bPathSync = <true> +P00 DEBUG: Storage::Local->new(): bAllowTemp = <true>, hRule = [undef], lBufferMax = 4194304, oDriver = [object], strCipherPassUser = [undef], strCipherType = [undef], strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strPathBase = [TEST_PATH]/db-master/db/base, strTempExtension = pgbackrest.tmp +P00 DEBUG: Storage::Local->hashSize(): xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = <false>, rhyFilter = [undef], strCipherPass = [undef], xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Storage::Local->hashSize=>: lSize = 16777216, strHash = f5035e2c3b83a9c32660f959b23451e78f7438f7 +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = <false>, rhyFilter = ({rxyParam => ({iLevel => 3}), strClass => pgBackRest::Storage::Filter::Gzip}), strCipherPass = [undef], xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Protocol::Storage::Remote->openWrite(): rhParam = [hash], strFileExp = <REPO:ARCHIVE>/9.3-1/000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz +P00 DEBUG: Storage::Base->copy(): xDestinationFile = [object], xSourceFile = [object] +P00 DEBUG: Archive::Push::File::archivePushFile=>: strWarning = [undef] +P00 INFO: pushed WAL segment 000000010000000100000002 +P00 DEBUG: Common::Exit::exitSafe(): iExitCode = 0, oException = [undef], strSignal = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy(): bComplete = true, iRemoteIdx = [undef], strRemoteType = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy: found cached protocol: iRemoteIdx = 1, strRemoteType = backup +P00 DEBUG: Protocol::Command::Master->close=>: iExitStatus = 0 +P00 DEBUG: Protocol::Helper::protocolDestroy=>: iExitStatus = 0 +P00 DEBUG: Common::Lock::lockRelease(): bFailOnNoLock = false +P00 INFO: archive-push command end: completed successfully +P00 DEBUG: Common::Exit::exitSafe=>: iExitCode = 0 + > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --log-level-console=warn --archive-queue-max=33554432 --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 ------------------------------------------------------------------------------------------------------------------------------------ P00 ERROR: [044]: raised from remote process on 'backup': WAL segment version 9.4 does not match archive version 9.3 @@ -368,6 +403,40 @@ db-version="9.4" 1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000002 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG +------------------------------------------------------------------------------------------------------------------------------------ +P00 INFO: archive-get command begin [BACKREST-VERSION]: --backup-cmd=[BACKREST-BIN] --backup-config=[TEST_PATH]/backup/pgbackrest.conf --backup-host=backup --backup-user=[USER-2] --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=debug --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --stanza=db +P00 INFO: get WAL segment 000000010000000100000002 +P00 DEBUG: Archive::Get::Get->get(): strDestinationFile = [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG, strSourceArchive = 000000010000000100000002 +P00 DEBUG: Protocol::Helper::protocolGet(): bCache = <true>, iProcessIdx = [undef], iRemoteIdx = <1>, strBackRestBin = [undef], strCommand = <archive-get>, strRemoteType = backup +P00 DEBUG: Protocol::Helper::protocolGet: create (cached) remote protocol +P00 DEBUG: Protocol::Remote::Master->new(): iBufferMax = 4194304, iCompressLevel = 3, iCompressLevelNetwork = 1, iProtocolTimeout = 60, iSshPort = [undef], strCommand = [BACKREST-BIN] --buffer-size=4194304 --command=archive-get --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/backup/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --protocol-timeout=60 --stanza=db --type=backup remote, strCommandSSH = ssh, strHost = backup, strUser = [USER-2] +P00 DEBUG: Protocol::Command::Master->new(): iBufferMax = 4194304, iCompressLevel = 3, iCompressLevelNetwork = 1, iProtocolTimeout = 60, strCommand = ssh -o LogLevel=error -o Compression=no -o PasswordAuthentication=no backrest@backup '[BACKREST-BIN] --buffer-size=4194304 --command=archive-get --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/backup/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --protocol-timeout=60 --stanza=db --type=backup remote', strId = remote process on 'backup', strName = remote +P00 DEBUG: Protocol::Storage::Remote->new(): oProtocol = [object] +P00 DEBUG: Archive::Base->getCheck(): bCheck = false, strDbVersion = [undef], strFile = 000000010000000100000002, ullDbSysId = [undef] +P00 DEBUG: Db::dbObjectGet(): bMasterOnly = true +P00 DEBUG: Db->new(): iRemoteIdx = 1 +P00 DEBUG: Db::dbObjectGet=>: iDbMasterIdx = 1, iDbStandbyIdx = [undef], oDbMaster = [object], oDbStandby = [undef] +P00 DEBUG: Db->info(): strDbPath = <[TEST_PATH]/db-master/db/base> +P00 DEBUG: Db->info=>: iDbCatalogVersion = 201306121, iDbControlVersion = 937, strDbVersion = 9.3, ullDbSysId = 6395542721432104958 +P00 DEBUG: Protocol::Helper::protocolGet(): bCache = <true>, iProcessIdx = [undef], iRemoteIdx = <1>, strBackRestBin = [undef], strCommand = <archive-get>, strRemoteType = backup +P00 DEBUG: Protocol::Helper::protocolGet: found cached protocol +P00 DEBUG: Archive::Base->getCheck=>: strArchiveFile = 000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz, strArchiveId = 9.3-1, strCipherPass = <redacted> +P00 DEBUG: Protocol::Storage::Remote->openRead(): rhParam = [hash], strFileExp = <REPO:ARCHIVE>/9.3-1/000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz +P00 DEBUG: Storage::Posix::Driver->new(): bFileSync = <true>, bPathSync = <true> +P00 DEBUG: Storage::Local->new(): bAllowTemp = <true>, hRule = [undef], lBufferMax = 4194304, oDriver = [object], strCipherPassUser = [undef], strCipherType = [undef], strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strPathBase = [TEST_PATH]/db-master/db/base, strTempExtension = pgbackrest.tmp +P00 DEBUG: Storage::Local->openWrite(): bAtomic = <false>, bPathCreate = <false>, lTimestamp = [undef], rhyFilter = ({rxyParam => ({strCompressType => decompress}), strClass => pgBackRest::Storage::Filter::Gzip}), strCipherPass = [undef], strGroup = [undef], strMode = <0640>, strUser = [undef], xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG +P00 DEBUG: Storage::Base->copy(): xDestinationFile = [object], xSourceFile = [object] +P00 DEBUG: Archive::Get::Get->get=>: iResult = 0 +P00 DEBUG: Common::Exit::exitSafe(): iExitCode = 0, oException = [undef], strSignal = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy(): bComplete = true, iRemoteIdx = [undef], strRemoteType = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy: found cached protocol: iRemoteIdx = 1, strRemoteType = backup +P00 DEBUG: Protocol::Command::Master->close=>: iExitStatus = 0 +P00 DEBUG: Protocol::Helper::protocolDestroy=>: iExitStatus = 0 +P00 DEBUG: Common::Lock::lockRelease(): bFailOnNoLock = false +P00 INFO: archive-get command end: completed successfully +P00 DEBUG: Common::Exit::exitSafe=>: iExitCode = 0 + > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --log-level-console=warn --archive-queue-max=33554432 --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 ------------------------------------------------------------------------------------------------------------------------------------ @@ -375,10 +444,12 @@ full backup - create first full backup (backup host) > [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --retention-full=2 --no-online --log-level-console=detail --type=full --stanza=db backup ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: backup command begin [BACKREST-VERSION]: --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/backup/pgbackrest.conf --db1-cmd=[BACKREST-BIN] --db1-config=[TEST_PATH]/db-master/pgbackrest.conf --db1-host=db-master --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --db1-user=[USER-1] --lock-path=[TEST_PATH]/backup/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/log --no-online --protocol-timeout=60 --repo-cipher-pass=<redacted> --repo-cipher-type=aes-256-cbc --repo-path=[TEST_PATH]/backup/repo --retention-full=2 --stanza=db --start-fast --type=full +P01 INFO: backup file db-master:[TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG (16MB, 33%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 +P01 INFO: backup file db-master:[TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 (16MB, 66%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 P01 INFO: backup file db-master:[TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 (16MB, 99%) checksum 1e34fa1c833090d94b9bb14f2a8d3153dca6ea27 P01 INFO: backup file db-master:[TEST_PATH]/db-master/db/base/global/pg_control (8KB, 100%) checksum 89373d9f2973502940de06bc5212489df3f8a912 P01 INFO: backup file db-master:[TEST_PATH]/db-master/db/base/pg_xlog/archive_status/000000010000000100000001.ready (0B, 100%) -P00 INFO: full backup size = 16MB +P00 INFO: full backup size = 48MB P00 INFO: new backup label = [BACKUP-FULL-1] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin [BACKREST-VERSION]: --config=[TEST_PATH]/backup/pgbackrest.conf --db1-cmd=[BACKREST-BIN] --db1-config=[TEST_PATH]/db-master/pgbackrest.conf --db1-host=db-master --lock-path=[TEST_PATH]/backup/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/log --repo-cipher-pass=<redacted> --repo-cipher-type=aes-256-cbc --repo-path=[TEST_PATH]/backup/repo --retention-archive=2 --retention-full=2 --stanza=db @@ -546,10 +617,12 @@ diff backup - diff changed to full backup (backup host) ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: backup command begin [BACKREST-VERSION]: --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/backup/pgbackrest.conf --db1-cmd=[BACKREST-BIN] --db1-config=[TEST_PATH]/db-master/pgbackrest.conf --db1-host=db-master --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --db1-user=[USER-1] --lock-path=[TEST_PATH]/backup/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/log --no-online --protocol-timeout=60 --repo-cipher-pass=<redacted> --repo-cipher-type=aes-256-cbc --repo-path=[TEST_PATH]/backup/repo --retention-full=2 --stanza=db --start-fast --type=diff P00 WARN: no prior backup exists, diff backup has been changed to full +P01 INFO: backup file db-master:[TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG (16MB, 33%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 +P01 INFO: backup file db-master:[TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 (16MB, 66%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 P01 INFO: backup file db-master:[TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 (16MB, 99%) checksum 15b1a1a35c26b17570aca7920980f0ad11c6d858 P01 INFO: backup file db-master:[TEST_PATH]/db-master/db/base/global/pg_control (8KB, 100%) checksum e28bf39d0a56bf9fabd4049b329fcae8878bfec6 P01 INFO: backup file db-master:[TEST_PATH]/db-master/db/base/pg_xlog/archive_status/000000010000000100000001.ready (0B, 100%) -P00 INFO: full backup size = 16MB +P00 INFO: full backup size = 48MB P00 INFO: new backup label = [BACKUP-FULL-2] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin [BACKREST-VERSION]: --config=[TEST_PATH]/backup/pgbackrest.conf --db1-cmd=[BACKREST-BIN] --db1-config=[TEST_PATH]/db-master/pgbackrest.conf --db1-host=db-master --lock-path=[TEST_PATH]/backup/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/backup/log --repo-cipher-pass=<redacted> --repo-cipher-type=aes-256-cbc --repo-path=[TEST_PATH]/backup/repo --retention-archive=2 --retention-full=2 --stanza=db diff --git a/test/expect/mock-stanza-003.log b/test/expect/mock-stanza-003.log index 0f2ff049d..8d0bca5ef 100644 --- a/test/expect/mock-stanza-003.log +++ b/test/expect/mock-stanza-003.log @@ -436,6 +436,49 @@ db-version="9.3" [db:history] 1={"db-id":6395542721432104958,"db-version":"9.3"} +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +------------------------------------------------------------------------------------------------------------------------------------ +P00 INFO: archive-push command begin [BACKREST-VERSION]: --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=debug --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --repo-path=/ --repo-s3-bucket=pgbackrest-dev --repo-s3-endpoint=s3.amazonaws.com --repo-s3-key=<redacted> --repo-s3-key-secret=<redacted> --repo-s3-region=us-east-1 --no-repo-s3-verify-ssl --repo-type=s3 --stanza=db +P00 DEBUG: Archive::Push::Push->process(): strWalPathFile = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Archive::Push::File::archivePushFile(): bCompress = true, iCompressLevel = 3, strWalFile = 000000010000000100000002, strWalPath = [TEST_PATH]/db-master/db/base/pg_xlog +P00 DEBUG: Storage::S3::Request->new(): bVerifySsl = false, iPort = [undef], lBufferMax = 4194304, strAccessKeyId = <redacted>, strBucket = pgbackrest-dev, strCaFile = [undef], strCaPath = [undef], strEndPoint = s3.amazonaws.com, strHost = [undef], strRegion = us-east-1, strSecretAccessKey = <redacted> +P00 DEBUG: Storage::Local->new(): bAllowTemp = <true>, hRule = [hash], lBufferMax = 4194304, oDriver = [object], strCipherPassUser = [undef], strCipherType = [undef], strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strPathBase = /, strTempExtension = pgbackrest.tmp +P00 DEBUG: Archive::Common::walInfo(): strWalFile = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Archive::Common::walInfo=>: strDbVersion = 9.3, ullDbSysId = 6395542721432104958 +P00 DEBUG: Archive::Push::File::archivePushCheck(): strArchiveFile = 000000010000000100000002, strDbVersion = 9.3, strWalFile = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002, ullDbSysId = 6395542721432104958 +P00 DEBUG: Archive::Info->new(): bIgnoreMissing = <false>, bLoad = <true>, bRequired = <true>, strArchiveClusterPath = /archive/db, strCipherPassSub = [undef] +P00 DEBUG: Storage::Local->encrypted(): bIgnoreMissing = true, strFileName = /archive/db/archive.info +P00 DEBUG: Storage::Local->encrypted=>: bEncrypted = false +P00 DEBUG: Storage::Local->encryptionValid(): bEncrypted = false +P00 DEBUG: Storage::Local->encryptionValid=>: bValid = true +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = true, rhyFilter = [undef], strCipherPass = [undef], xFileExp = /archive/db/archive.info +P00 DEBUG: Storage::Base->get(): strCipherPass = [undef], xFile = [object] +P00 DEBUG: Archive::Info->check(): bRequired = <true>, strDbVersion = 9.3, ullDbSysId = 6395542721432104958 +P00 DEBUG: Archive::Info->archiveId(): strDbVersion = [undef], ullDbSysId = [undef] +P00 DEBUG: Archive::Info->archiveId=>: strArchiveId = 9.3-1 +P00 DEBUG: Archive::Info->check=>: strArchiveId = 9.3-1 +P00 DEBUG: Archive::Common::walSegmentFind(): iWaitSeconds = [undef], oStorageRepo = [object], strArchiveId = 9.3-1, strWalSegment = 000000010000000100000002 +P00 DEBUG: Storage::Local->list(): bIgnoreMissing = true, strExpression = ^000000010000000100000002-[0-f]{40}(\.gz){0,1}$, strPathExp = <REPO:ARCHIVE>/9.3-1/0000000100000001, strSortOrder = <forward> +P00 DEBUG: Storage::Local->list=>: stryFileList = () +P00 DEBUG: Archive::Common::walSegmentFind=>: strWalFileName = [undef] +P00 DEBUG: Archive::Push::File::archivePushCheck=>: strArchiveId = 9.3-1, strChecksum = [undef], strCipherPass = [undef], strWarning = [undef] +P00 DEBUG: Storage::Posix::Driver->new(): bFileSync = <true>, bPathSync = <true> +P00 DEBUG: Storage::Local->new(): bAllowTemp = <true>, hRule = [undef], lBufferMax = 4194304, oDriver = [object], strCipherPassUser = [undef], strCipherType = [undef], strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strPathBase = [TEST_PATH]/db-master/db/base, strTempExtension = pgbackrest.tmp +P00 DEBUG: Storage::Local->hashSize(): xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = <false>, rhyFilter = [undef], strCipherPass = [undef], xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Storage::Local->hashSize=>: lSize = 16777216, strHash = f5035e2c3b83a9c32660f959b23451e78f7438f7 +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = <false>, rhyFilter = ({rxyParam => ({iLevel => 3}), strClass => pgBackRest::Storage::Filter::Gzip}), strCipherPass = [undef], xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 +P00 DEBUG: Storage::Local->openWrite(): bAtomic = true, bPathCreate = true, lTimestamp = [undef], rhyFilter = [undef], strCipherPass = [undef], strGroup = [undef], strMode = <0640>, strUser = [undef], xFileExp = <REPO:ARCHIVE>/9.3-1/000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz +P00 DEBUG: Storage::Base->copy(): xDestinationFile = [object], xSourceFile = [object] +P00 DEBUG: Archive::Push::File::archivePushFile=>: strWarning = [undef] +P00 INFO: pushed WAL segment 000000010000000100000002 +P00 DEBUG: Common::Exit::exitSafe(): iExitCode = 0, oException = [undef], strSignal = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy(): bComplete = true, iRemoteIdx = [undef], strRemoteType = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy=>: iExitStatus = 0 +P00 DEBUG: Common::Lock::lockRelease(): bFailOnNoLock = false +P00 INFO: archive-push command end: completed successfully +P00 DEBUG: Common::Exit::exitSafe=>: iExitCode = 0 + > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --log-level-console=warn --archive-queue-max=33554432 --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 ------------------------------------------------------------------------------------------------------------------------------------ P00 ERROR: [044]: WAL segment version 9.4 does not match archive version 9.3 @@ -482,6 +525,47 @@ db-version="9.4" 1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get 000000010000000100000002 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG +------------------------------------------------------------------------------------------------------------------------------------ +P00 INFO: archive-get command begin [BACKREST-VERSION]: --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=debug --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --protocol-timeout=60 --repo-path=/ --repo-s3-bucket=pgbackrest-dev --repo-s3-endpoint=s3.amazonaws.com --repo-s3-key=<redacted> --repo-s3-key-secret=<redacted> --repo-s3-region=us-east-1 --no-repo-s3-verify-ssl --repo-type=s3 --stanza=db +P00 INFO: get WAL segment 000000010000000100000002 +P00 DEBUG: Archive::Get::Get->get(): strDestinationFile = [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG, strSourceArchive = 000000010000000100000002 +P00 DEBUG: Storage::S3::Request->new(): bVerifySsl = false, iPort = [undef], lBufferMax = 4194304, strAccessKeyId = <redacted>, strBucket = pgbackrest-dev, strCaFile = [undef], strCaPath = [undef], strEndPoint = s3.amazonaws.com, strHost = [undef], strRegion = us-east-1, strSecretAccessKey = <redacted> +P00 DEBUG: Storage::Local->new(): bAllowTemp = <true>, hRule = [hash], lBufferMax = 4194304, oDriver = [object], strCipherPassUser = [undef], strCipherType = [undef], strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strPathBase = /, strTempExtension = pgbackrest.tmp +P00 DEBUG: Archive::Base->getCheck(): bCheck = false, strDbVersion = [undef], strFile = 000000010000000100000002, ullDbSysId = [undef] +P00 DEBUG: Db::dbObjectGet(): bMasterOnly = true +P00 DEBUG: Db->new(): iRemoteIdx = 1 +P00 DEBUG: Db::dbObjectGet=>: iDbMasterIdx = 1, iDbStandbyIdx = [undef], oDbMaster = [object], oDbStandby = [undef] +P00 DEBUG: Db->info(): strDbPath = <[TEST_PATH]/db-master/db/base> +P00 DEBUG: Db->info=>: iDbCatalogVersion = 201306121, iDbControlVersion = 937, strDbVersion = 9.3, ullDbSysId = 6395542721432104958 +P00 DEBUG: Archive::Info->new(): bIgnoreMissing = <false>, bLoad = <true>, bRequired = true, strArchiveClusterPath = /archive/db, strCipherPassSub = [undef] +P00 DEBUG: Storage::Local->encrypted(): bIgnoreMissing = true, strFileName = /archive/db/archive.info +P00 DEBUG: Storage::Local->encrypted=>: bEncrypted = false +P00 DEBUG: Storage::Local->encryptionValid(): bEncrypted = false +P00 DEBUG: Storage::Local->encryptionValid=>: bValid = true +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = true, rhyFilter = [undef], strCipherPass = [undef], xFileExp = /archive/db/archive.info +P00 DEBUG: Storage::Base->get(): strCipherPass = [undef], xFile = [object] +P00 DEBUG: Archive::Info->archiveIdList(): strDbVersion = 9.3, ullDbSysId = 6395542721432104958 +P00 DEBUG: Archive::Info->dbHistoryList=>: hDbHash = [hash] +P00 DEBUG: Archive::Info->archiveIdList=>: stryArchiveId = (9.3-1) +P00 DEBUG: Archive::Common::walSegmentFind(): iWaitSeconds = [undef], oStorageRepo = [object], strArchiveId = 9.3-1, strWalSegment = 000000010000000100000002 +P00 DEBUG: Storage::Local->list(): bIgnoreMissing = true, strExpression = ^000000010000000100000002-[0-f]{40}(\.gz){0,1}$, strPathExp = <REPO:ARCHIVE>/9.3-1/0000000100000001, strSortOrder = <forward> +P00 DEBUG: Storage::Local->list=>: stryFileList = (000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz) +P00 DEBUG: Archive::Common::walSegmentFind=>: strWalFileName = 000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz +P00 DEBUG: Archive::Base->getCheck=>: strArchiveFile = 000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz, strArchiveId = 9.3-1, strCipherPass = [undef] +P00 DEBUG: Storage::Local->openRead(): bIgnoreMissing = <false>, rhyFilter = [undef], strCipherPass = [undef], xFileExp = <REPO:ARCHIVE>/9.3-1/000000010000000100000002-f5035e2c3b83a9c32660f959b23451e78f7438f7.gz +P00 DEBUG: Storage::Posix::Driver->new(): bFileSync = <true>, bPathSync = <true> +P00 DEBUG: Storage::Local->new(): bAllowTemp = <true>, hRule = [undef], lBufferMax = 4194304, oDriver = [object], strCipherPassUser = [undef], strCipherType = [undef], strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strPathBase = [TEST_PATH]/db-master/db/base, strTempExtension = pgbackrest.tmp +P00 DEBUG: Storage::Local->openWrite(): bAtomic = <false>, bPathCreate = <false>, lTimestamp = [undef], rhyFilter = ({rxyParam => ({strCompressType => decompress}), strClass => pgBackRest::Storage::Filter::Gzip}), strCipherPass = [undef], strGroup = [undef], strMode = <0640>, strUser = [undef], xFileExp = [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG +P00 DEBUG: Storage::Base->copy(): xDestinationFile = [object], xSourceFile = [object] +P00 DEBUG: Archive::Get::Get->get=>: iResult = 0 +P00 DEBUG: Common::Exit::exitSafe(): iExitCode = 0, oException = [undef], strSignal = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy(): bComplete = true, iRemoteIdx = [undef], strRemoteType = [undef] +P00 DEBUG: Protocol::Helper::protocolDestroy=>: iExitStatus = 0 +P00 DEBUG: Common::Lock::lockRelease(): bFailOnNoLock = false +P00 INFO: archive-get command end: completed successfully +P00 DEBUG: Common::Exit::exitSafe=>: iExitCode = 0 + > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --log-level-console=warn --archive-queue-max=33554432 --stanza=db archive-push [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 ------------------------------------------------------------------------------------------------------------------------------------ @@ -522,6 +606,7 @@ db-system-id=6353949018581704918 db-version="9.4" [db:history] +1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} stanza-create db - use force to recreate the stanza producing mismatched db-id (db-master host) @@ -560,19 +645,23 @@ db-system-id=6353949018581704918 db-version="9.4" [db:history] +1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} full backup - create first full backup (db-master host) > [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --retention-full=2 --no-online --log-level-console=detail --type=full --stanza=db backup ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: backup command begin [BACKREST-VERSION]: --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --no-online --protocol-timeout=60 --repo-path=/ --repo-s3-bucket=pgbackrest-dev --repo-s3-endpoint=s3.amazonaws.com --repo-s3-key=<redacted> --repo-s3-key-secret=<redacted> --repo-s3-region=us-east-1 --no-repo-s3-verify-ssl --repo-type=s3 --retention-full=2 --stanza=db --start-fast --type=full +P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG (16MB, 33%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 +P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 (16MB, 66%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 (16MB, 99%) checksum 1e34fa1c833090d94b9bb14f2a8d3153dca6ea27 P01 INFO: backup file [TEST_PATH]/db-master/db/base/global/pg_control (8KB, 100%) checksum 89373d9f2973502940de06bc5212489df3f8a912 P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/archive_status/000000010000000100000001.ready (0B, 100%) -P00 INFO: full backup size = 16MB +P00 INFO: full backup size = 48MB P00 INFO: new backup label = [BACKUP-FULL-1] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin [BACKREST-VERSION]: --config=[TEST_PATH]/db-master/pgbackrest.conf --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --repo-path=/ --repo-s3-bucket=pgbackrest-dev --repo-s3-endpoint=s3.amazonaws.com --repo-s3-key=<redacted> --repo-s3-key-secret=<redacted> --repo-s3-region=us-east-1 --no-repo-s3-verify-ssl --repo-type=s3 --retention-archive=2 --retention-full=2 --stanza=db +P00 INFO: remove archive path: /archive/db/9.3-1 P00 INFO: full backup total < 2 - using oldest full backup for 9.4-2 archive retention P00 INFO: expire command end: completed successfully @@ -625,6 +714,7 @@ db-system-id=6353949018581704918 db-version="9.4" [db:history] +1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} stanza-create db - use force to recreate the stanza from backups (db-master host) @@ -666,6 +756,7 @@ db-system-id=6353949018581704918 db-version="9.4" [db:history] +1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} stanza-upgrade db - successfully upgrade with XX.Y-Z (db-master host) @@ -708,6 +799,7 @@ db-system-id=6392579261579036436 db-version="9.5" [db:history] +1={"db-id":6395542721432104958,"db-version":"9.3"} 2={"db-id":6353949018581704918,"db-version":"9.4"} 3={"db-id":35184388866048,"db-version":"10.0"} 4={"db-id":6392579261579036436,"db-version":"9.5"} @@ -720,10 +812,12 @@ diff backup - diff changed to full backup (db-master host) ------------------------------------------------------------------------------------------------------------------------------------ P00 INFO: backup command begin [BACKREST-VERSION]: --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db1-path=[TEST_PATH]/db-master/db/base --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --no-online --protocol-timeout=60 --repo-path=/ --repo-s3-bucket=pgbackrest-dev --repo-s3-endpoint=s3.amazonaws.com --repo-s3-key=<redacted> --repo-s3-key-secret=<redacted> --repo-s3-region=us-east-1 --no-repo-s3-verify-ssl --repo-type=s3 --retention-full=2 --stanza=db --start-fast --type=diff P00 WARN: no prior backup exists, diff backup has been changed to full +P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG (16MB, 33%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 +P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000002 (16MB, 66%) checksum f5035e2c3b83a9c32660f959b23451e78f7438f7 P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/000000010000000100000001 (16MB, 99%) checksum 15b1a1a35c26b17570aca7920980f0ad11c6d858 P01 INFO: backup file [TEST_PATH]/db-master/db/base/global/pg_control (8KB, 100%) checksum e28bf39d0a56bf9fabd4049b329fcae8878bfec6 P01 INFO: backup file [TEST_PATH]/db-master/db/base/pg_xlog/archive_status/000000010000000100000001.ready (0B, 100%) -P00 INFO: full backup size = 16MB +P00 INFO: full backup size = 48MB P00 INFO: new backup label = [BACKUP-FULL-2] P00 INFO: backup command end: completed successfully P00 INFO: expire command begin [BACKREST-VERSION]: --config=[TEST_PATH]/db-master/pgbackrest.conf --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --repo-path=/ --repo-s3-bucket=pgbackrest-dev --repo-s3-endpoint=s3.amazonaws.com --repo-s3-key=<redacted> --repo-s3-key-secret=<redacted> --repo-s3-region=us-east-1 --no-repo-s3-verify-ssl --repo-type=s3 --retention-archive=2 --retention-full=2 --stanza=db diff --git a/test/lib/pgBackRestTest/Common/DefineTest.pm b/test/lib/pgBackRestTest/Common/DefineTest.pm index 266ea3d26..4f10aaba7 100644 --- a/test/lib/pgBackRestTest/Common/DefineTest.pm +++ b/test/lib/pgBackRestTest/Common/DefineTest.pm @@ -493,7 +493,7 @@ my $oTestDef = }, { &TESTDEF_NAME => 'info-unit', - &TESTDEF_TOTAL => 2, + &TESTDEF_TOTAL => 4, &TESTDEF_CLIB => true, &TESTDEF_COVERAGE => @@ -501,6 +501,17 @@ my $oTestDef = 'Archive/Info' => TESTDEF_COVERAGE_PARTIAL, }, }, + { + &TESTDEF_NAME => 'get', + &TESTDEF_TOTAL => 2, + &TESTDEF_CLIB => true, + + &TESTDEF_COVERAGE => + { + 'Archive/Base' => TESTDEF_COVERAGE_PARTIAL, + 'Archive/Get/Get' => TESTDEF_COVERAGE_PARTIAL, + }, + }, ] }, # Backup tests diff --git a/test/lib/pgBackRestTest/Module/Archive/ArchiveGetTest.pm b/test/lib/pgBackRestTest/Module/Archive/ArchiveGetTest.pm new file mode 100644 index 000000000..2af75508e --- /dev/null +++ b/test/lib/pgBackRestTest/Module/Archive/ArchiveGetTest.pm @@ -0,0 +1,284 @@ +#################################################################################################################################### +# Archive Get and Base Tests +#################################################################################################################################### +package pgBackRestTest::Module::Archive::ArchiveGetTest; +use parent 'pgBackRestTest::Env::ConfigEnvTest'; + +#################################################################################################################################### +# Perl includes +#################################################################################################################################### +use strict; +use warnings FATAL => qw(all); +use Carp qw(confess); + +use Storable qw(dclone); +use Digest::SHA qw(sha1_hex); + +use pgBackRest::Archive::Common; +use pgBackRest::Archive::Get::Get; +use pgBackRest::Archive::Info; +use pgBackRest::Common::Exception; +use pgBackRest::Common::Log; +use pgBackRest::Config::Config; +use pgBackRest::DbVersion; +use pgBackRest::Manifest; +use pgBackRest::Protocol::Storage::Helper; + +use pgBackRestTest::Env::HostEnvTest; +use pgBackRestTest::Common::ExecuteTest; +use pgBackRestTest::Common::RunTest; + +#################################################################################################################################### +# initModule +#################################################################################################################################### +sub initModule +{ + my $self = shift; + + $self->{strDbPath} = $self->testPath() . '/db'; + $self->{strRepoPath} = $self->testPath() . '/repo'; + $self->{strArchivePath} = "$self->{strRepoPath}/archive/" . $self->stanza(); + $self->{strBackupPath} = "$self->{strRepoPath}/backup/" . $self->stanza(); +} + +#################################################################################################################################### +# initTest +#################################################################################################################################### +sub initTest +{ + my $self = shift; + + # Clear cache from the previous test + storageRepoCacheClear($self->stanza()); + + # Load options + $self->configTestClear(); + $self->optionTestSet(CFGOPT_STANZA, $self->stanza()); + $self->optionTestSet(CFGOPT_REPO_PATH, $self->testPath() . '/repo'); + $self->optionTestSet(CFGOPT_DB_PATH, $self->{strDbPath}); + $self->configTestLoad(CFGCMD_ARCHIVE_GET); + + # Create archive info path + storageTest()->pathCreate($self->{strArchivePath}, {bIgnoreExists => true, bCreateParent => true}); + + # Create backup info path + storageTest()->pathCreate($self->{strBackupPath}, {bIgnoreExists => true, bCreateParent => true}); + + # Create pg_control path + storageTest()->pathCreate($self->{strDbPath} . '/' . DB_PATH_GLOBAL, {bCreateParent => true}); + + # Copy a pg_control file into the pg_control path + executeTest( + 'cp ' . $self->dataPath() . '/backup.pg_control_' . WAL_VERSION_94 . '.bin ' . $self->{strDbPath} . '/' . + DB_FILE_PGCONTROL); +} + +#################################################################################################################################### +# run +#################################################################################################################################### +sub run +{ + my $self = shift; + my $oArchiveBase = new pgBackRest::Archive::Base(); + + # Define test file + my $strFileContent = 'TESTDATA'; + my $strFileHash = sha1_hex($strFileContent); + my $iFileSize = length($strFileContent); + + my $strDestinationPath = $self->{strDbPath} . "/pg_xlog"; + my $strDestinationFile = $strDestinationPath . "/RECOVERYXLOG"; + my $strWalSegment = '000000010000000100000001'; + my $strArchivePath; + + ################################################################################################################################ + if ($self->begin("Archive::Base::getCheck()")) + { + # Create and save archive.info file + my $oArchiveInfo = new pgBackRest::Archive::Info(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE), false, + {bLoad => false, bIgnoreMissing => true}); + $oArchiveInfo->create(PG_VERSION_92, WAL_VERSION_92_SYS_ID, false); + $oArchiveInfo->dbSectionSet(PG_VERSION_93, WAL_VERSION_93_SYS_ID, $oArchiveInfo->dbHistoryIdGet(false) + 1); + $oArchiveInfo->dbSectionSet(PG_VERSION_92, WAL_VERSION_92_SYS_ID, $oArchiveInfo->dbHistoryIdGet(false) + 1); + $oArchiveInfo->dbSectionSet(PG_VERSION_94, WAL_VERSION_94_SYS_ID, $oArchiveInfo->dbHistoryIdGet(false) + 10); + $oArchiveInfo->save(); + + # db-version, db-sys-id passed but combination doesn't exist in archive.info history + #--------------------------------------------------------------------------------------------------------------------------- + $self->testException(sub {$oArchiveBase->getCheck(PG_VERSION_95, WAL_VERSION_94_SYS_ID, undef, false)}, ERROR_UNKNOWN, + "unable to retrieve the archive id for database version '" . PG_VERSION_95 . "' and system-id '" . + WAL_VERSION_94_SYS_ID . "'"); + + # db-version, db-sys-id and wal passed all undefined + #--------------------------------------------------------------------------------------------------------------------------- + my ($strArchiveId, $strArchiveFile, $strCipherPass) = $oArchiveBase->getCheck(undef, undef, undef, false); + $self->testResult(sub {($strArchiveId eq PG_VERSION_94 . '-13') && !defined($strArchiveFile) && !defined($strCipherPass)}, + true, 'undef db-version, db-sys-id and wal returns only current db archive-id'); + + # db-version defined, db-sys-id and wal undefined + #--------------------------------------------------------------------------------------------------------------------------- + ($strArchiveId, $strArchiveFile, $strCipherPass) = $oArchiveBase->getCheck(PG_VERSION_92, undef, undef, false); + $self->testResult(sub {($strArchiveId eq PG_VERSION_94 . '-13') && !defined($strArchiveFile) && !defined($strCipherPass)}, + true, 'old db-version, db-sys-id and wal undefined returns only current db archive-id'); + + # db-version undefined, db-sys-id defined and wal undefined + #--------------------------------------------------------------------------------------------------------------------------- + ($strArchiveId, $strArchiveFile, $strCipherPass) = $oArchiveBase->getCheck(undef, WAL_VERSION_93_SYS_ID, undef, false); + $self->testResult(sub {($strArchiveId eq PG_VERSION_94 . '-13') && !defined($strArchiveFile) && !defined($strCipherPass)}, + true, 'undef db-version, old db-sys-id and wal undef returns only current db archive-id'); + + # old db-version, db-sys-id and wal undefined, check = true (default) + #--------------------------------------------------------------------------------------------------------------------------- + ($strArchiveId, $strArchiveFile, $strCipherPass) = $oArchiveBase->getCheck(PG_VERSION_92, undef, undef); + $self->testResult(sub {($strArchiveId eq PG_VERSION_94 . '-13') && !defined($strArchiveFile) && !defined($strCipherPass)}, + true, 'old db-version, db-sys-id and wal undefined, check = true returns only current db archive-id'); + + # old db-version, old db-sys-id and wal undefined, check = true (default) + #--------------------------------------------------------------------------------------------------------------------------- + $self->testException(sub {$oArchiveBase->getCheck(PG_VERSION_93, WAL_VERSION_93_SYS_ID, undef)}, ERROR_ARCHIVE_MISMATCH, + "WAL segment version " . PG_VERSION_93 . " does not match archive version " . PG_VERSION_94 . "\n" . + "WAL segment system-id " . WAL_VERSION_93_SYS_ID . " does not match archive system-id " . WAL_VERSION_94_SYS_ID . + "\nHINT: are you archiving to the correct stanza?"); + + # db-version, db-sys-id undefined, wal requested is stored in old archive + #--------------------------------------------------------------------------------------------------------------------------- + $strArchivePath = $self->{strArchivePath} . "/" . PG_VERSION_92 . "-1/"; + my $strWalMajorPath = "${strArchivePath}/" . substr($strWalSegment, 0, 16); + my $strWalSegmentName = "${strWalSegment}-${strFileHash}"; + + storageRepo()->pathCreate($strWalMajorPath, {bCreateParent => true}); + storageRepo()->put("${strWalMajorPath}/${strWalSegmentName}"); + + ($strArchiveId, $strArchiveFile, $strCipherPass) = $oArchiveBase->getCheck(undef, undef, $strWalSegment, false); + + $self->testResult(sub {($strArchiveId eq PG_VERSION_94 . '-13') && !defined($strArchiveFile) && !defined($strCipherPass)}, + true, 'undef db-version, db-sys-id with a requested wal not in current db archive returns only current db archive-id'); + + # Pass db-version and db-sys-id where WAL is actually located + #--------------------------------------------------------------------------------------------------------------------------- + ($strArchiveId, $strArchiveFile, $strCipherPass) = + $oArchiveBase->getCheck(PG_VERSION_92, WAL_VERSION_92_SYS_ID, $strWalSegment, false); + + $self->testResult(sub {($strArchiveId eq PG_VERSION_92 . '-1') && ($strArchiveFile eq $strWalSegmentName) && !defined($strCipherPass)}, + true, 'db-version, db-sys-id with a requested wal in requested db archive'); + + # Put same WAL segment in more recent archive for same DB + #--------------------------------------------------------------------------------------------------------------------------- + $strArchivePath = $self->{strArchivePath} . "/" . PG_VERSION_92 . "-3/"; + $strWalMajorPath = "${strArchivePath}/" . substr($strWalSegment, 0, 16); + $strWalSegmentName = "${strWalSegment}-${strFileHash}"; + + # Store with actual data that will match the hash check + storageRepo()->pathCreate($strWalMajorPath, {bCreateParent => true}); + storageRepo()->put("${strWalMajorPath}/${strWalSegmentName}", $strFileContent); + + ($strArchiveId, $strArchiveFile, $strCipherPass) = + $oArchiveBase->getCheck(PG_VERSION_92, WAL_VERSION_92_SYS_ID, $strWalSegment, false); + + # Using the returned values, confirm the correct file is read + $self->testResult(sub {sha1_hex(${storageRepo()->get($self->{strArchivePath} . "/" . $strArchiveId . "/" . + substr($strWalSegment, 0, 16) . "/" . $strArchiveFile)})}, $strFileHash, + 'check correct WAL archiveID when in multiple locations'); + } + + ################################################################################################################################ + if ($self->begin("Archive::Get::Get::get()")) + { + # archive.info missing + #--------------------------------------------------------------------------------------------------------------------------- + $self->testException(sub {new pgBackRest::Archive::Get::Get()->get($strWalSegment, $strDestinationFile)}, + ERROR_FILE_MISSING, + ARCHIVE_INFO_FILE . " does not exist but is required to push/get WAL segments\n" . + "HINT: is archive_command configured in postgresql.conf?\n" . + "HINT: has a stanza-create been performed?\n" . + "HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving scheme."); + + # Create and save archive.info file + my $oArchiveInfo = new pgBackRest::Archive::Info(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE), false, + {bLoad => false, bIgnoreMissing => true}); + $oArchiveInfo->create(PG_VERSION_94, WAL_VERSION_94_SYS_ID, false); + $oArchiveInfo->dbSectionSet(PG_VERSION_93, WAL_VERSION_93_SYS_ID, $oArchiveInfo->dbHistoryIdGet(false) + 1); + $oArchiveInfo->dbSectionSet(PG_VERSION_94, WAL_VERSION_94_SYS_ID, $oArchiveInfo->dbHistoryIdGet(false) + 10); + $oArchiveInfo->save(); + + # file not found + #--------------------------------------------------------------------------------------------------------------------------- + $self->testResult(sub {new pgBackRest::Archive::Get::Get()->get($strWalSegment, $strDestinationFile)}, 1, + "unable to find ${strWalSegment} in the archive"); + + # file found but is not a WAL segment + #--------------------------------------------------------------------------------------------------------------------------- + $strArchivePath = $self->{strArchivePath} . "/" . PG_VERSION_94 . "-1/"; + + storageRepo()->pathCreate($strArchivePath); + storageRepo()->put($strArchivePath . BOGUS, BOGUS); + my $strBogusHash = sha1_hex(BOGUS); + + # Create path to copy file + storageRepo()->pathCreate($strDestinationPath); + + $self->testResult(sub {new pgBackRest::Archive::Get::Get()->get(BOGUS, $strDestinationFile)}, 0, + "non-WAL segment copied"); + + # Confirm the correct file is copied + $self->testResult(sub {sha1_hex(${storageRepo()->get($strDestinationFile)})}, $strBogusHash, + ' check correct non-WAL copied from older archiveId'); + + # create same WAL segment in same DB but different archives and different has values. Confirm latest one copied. + #--------------------------------------------------------------------------------------------------------------------------- + my $strWalMajorPath = "${strArchivePath}/" . substr($strWalSegment, 0, 16); + my $strWalSegmentName = "${strWalSegment}-${strFileHash}"; + + # Put zero byte file in old archive + storageRepo()->pathCreate($strWalMajorPath); + storageRepo()->put("${strWalMajorPath}/${strWalSegmentName}"); + + # Create newest archive path + $strArchivePath = $self->{strArchivePath} . "/" . PG_VERSION_94 . "-12/"; + $strWalMajorPath = "${strArchivePath}/" . substr($strWalSegment, 0, 16); + $strWalSegmentName = "${strWalSegment}-${strFileHash}"; + + # Store with actual data that will match the hash check + storageRepo()->pathCreate($strWalMajorPath, {bCreateParent => true}); + storageRepo()->put("${strWalMajorPath}/${strWalSegmentName}", $strFileContent); + + $self->testResult(sub {new pgBackRest::Archive::Get::Get()->get($strWalSegmentName, $strDestinationFile)}, 0, + "WAL segment copied"); + + # Confirm the correct file is copied + $self->testResult(sub {sha1_hex(${storageRepo()->get($strDestinationFile)})}, $strFileHash, + ' check correct WAL copied when in multiple locations'); + + # get files from an older DB version to simulate restoring from an old backup set to a database that is of that same version + #--------------------------------------------------------------------------------------------------------------------------- + # Create same WAL name in older DB archive but with different data to ensure it is copied + $strArchivePath = $self->{strArchivePath} . "/" . PG_VERSION_93 . "-2/"; + $strWalMajorPath = "${strArchivePath}/" . substr($strWalSegment, 0, 16); + $strWalSegmentName = "${strWalSegment}-${strFileHash}"; + + my $strWalContent = 'WALTESTDATA'; + my $strWalHash = sha1_hex($strWalContent); + + # Store with actual data that will match the hash check + storageRepo()->pathCreate($strWalMajorPath, {bCreateParent => true}); + storageRepo()->put("${strWalMajorPath}/${strWalSegmentName}", $strWalContent); + + # Remove the destination file to ensure it is copied + storageTest()->remove($strDestinationFile); + + # Remove the current pg_control file and copy the older db pg_control file into the pg_control path + storageTest()->remove($self->{strDbPath} . '/' . DB_FILE_PGCONTROL); + executeTest( + 'cp ' . $self->dataPath() . '/backup.pg_control_' . WAL_VERSION_93 . '.bin ' . $self->{strDbPath} . '/' . + DB_FILE_PGCONTROL); + + $self->testResult(sub {new pgBackRest::Archive::Get::Get()->get($strWalSegmentName, $strDestinationFile)}, 0, + "WAL segment copied from older db backupset to same version older db"); + + # Confirm the correct file is copied + $self->testResult(sub {sha1_hex(${storageRepo()->get($strDestinationFile)})}, $strWalHash, + ' check correct WAL copied from older db'); + } +} + +1; diff --git a/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitTest.pm b/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitTest.pm index 53b55de0d..cd5ce8655 100644 --- a/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitTest.pm +++ b/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitTest.pm @@ -74,6 +74,16 @@ sub run my $strArchiveTestFile = $self->dataPath() . '/backup.wal1_'; + ################################################################################################################################ + if ($self->begin("Archive::Info::new()")) + { + $self->testException(sub {new pgBackRest::Archive::Info(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE))}, ERROR_FILE_MISSING, + ARCHIVE_INFO_FILE . " does not exist but is required to push/get WAL segments\n" . + "HINT: is archive_command configured in postgresql.conf?\n" . + "HINT: has a stanza-create been performed?\n" . + "HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving scheme."); + } + ################################################################################################################################ if ($self->begin("Archive::Info::reconstruct()")) { @@ -130,6 +140,48 @@ sub run ' new archive info encrypted'); } + ################################################################################################################################ + if ($self->begin("Archive::Info::archiveIdList(), check(), archiveId()")) + { + my @stryArchiveId; + my $oArchiveInfo = new pgBackRest::Archive::Info(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE), false, + {bLoad => false, bIgnoreMissing => true}); + + $oArchiveInfo->create(PG_VERSION_92, WAL_VERSION_92_SYS_ID, false); + $oArchiveInfo->dbSectionSet(PG_VERSION_93, WAL_VERSION_93_SYS_ID, $oArchiveInfo->dbHistoryIdGet(false) + 1); + $oArchiveInfo->dbSectionSet(PG_VERSION_94, WAL_VERSION_94_SYS_ID, $oArchiveInfo->dbHistoryIdGet(false) + 10); + $oArchiveInfo->dbSectionSet(PG_VERSION_93, WAL_VERSION_93_SYS_ID, $oArchiveInfo->dbHistoryIdGet(false) + 1); + $oArchiveInfo->save(); + + # Check gets only the latest DB and returns only that archiveId + push(@stryArchiveId, $oArchiveInfo->check(PG_VERSION_93, WAL_VERSION_93_SYS_ID)); + $self->testResult(sub {(@stryArchiveId == 1) && ($stryArchiveId[0] eq PG_VERSION_93 . "-13")}, true, + 'check - return only newest archiveId'); + + $self->testResult(sub {$oArchiveInfo->archiveId({strDbVersion => PG_VERSION_93, ullDbSysId => WAL_VERSION_93_SYS_ID})}, + PG_VERSION_93 . "-13", 'archiveId - return only newest archiveId for multiple histories'); + + $self->testException(sub {$oArchiveInfo->archiveId({strDbVersion => PG_VERSION_94, ullDbSysId => BOGUS})}, ERROR_UNKNOWN, + "unable to retrieve the archive id for database version '" . PG_VERSION_94 . "' and system-id '" . BOGUS . "'"); + + $self->testException(sub {$oArchiveInfo->check(PG_VERSION_94, WAL_VERSION_94_SYS_ID)}, ERROR_ARCHIVE_MISMATCH, + "WAL segment version " . PG_VERSION_94 . " does not match archive version " . PG_VERSION_93 . + "\nWAL segment system-id " . WAL_VERSION_94_SYS_ID . " does not match archive system-id " . WAL_VERSION_93_SYS_ID . + "\nHINT: are you archiving to the correct stanza?"); + + @stryArchiveId = $oArchiveInfo->archiveIdList(PG_VERSION_93, WAL_VERSION_93_SYS_ID); + $self->testResult(sub {(@stryArchiveId == 2) && ($stryArchiveId[0] eq PG_VERSION_93 . "-13") && + ($stryArchiveId[1] eq PG_VERSION_93 . "-2")}, true, 'archiveIdList - returns multiple archiveId - newest first'); + + @stryArchiveId = $oArchiveInfo->archiveIdList(PG_VERSION_94, WAL_VERSION_94_SYS_ID); + $self->testResult(sub {(@stryArchiveId == 1) && ($stryArchiveId[0] eq PG_VERSION_94 . "-12")}, true, + 'archiveIdList - returns older archiveId'); + + $self->testException(sub {$oArchiveInfo->archiveIdList(PG_VERSION_95, WAL_VERSION_94_SYS_ID)}, ERROR_UNKNOWN, + "unable to retrieve the archive id for database version '" . PG_VERSION_95 . "' and system-id '" . + WAL_VERSION_94_SYS_ID . "'"); + } + ################################################################################################################################ if ($self->begin("encryption")) { diff --git a/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm b/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm index c04e4c33b..4de6f87cb 100644 --- a/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm +++ b/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm @@ -248,7 +248,7 @@ sub run storageTest()->remove($oHostDbMaster->spoolPath() . '/archive/' . $self->stanza() . "/out/${strSourceFile}.ok"); #--------------------------------------------------------------------------------------------------------------------------- - &log(INFO, ' db version mismatch error'); + &log(INFO, ' db version mismatch in db section only - archive-push errors but archive-get succeeds'); $oHostBackup->infoMunge( storageRepo()->pathGet(STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE), @@ -258,16 +258,50 @@ sub run $strCommandPush . " ${strWalPath}/${strSourceFile}", {iExpectedExitStatus => ERROR_ARCHIVE_MISMATCH, oLogTest => $self->expect()}); + # Remove RECOVERYXLOG so it can be recovered + storageTest()->remove("${strWalPath}/RECOVERYXLOG", {bIgnoreMissing => false}); + $oHostDbMaster->executeSimple( $strCommandGet . " ${strSourceFile1} ${strWalPath}/RECOVERYXLOG", - {iExpectedExitStatus => ERROR_ARCHIVE_MISMATCH, oLogTest => $self->expect()}); + {oLogTest => $self->expect()}); + + # Check that the destination file exists + if (storageDb()->exists("${strWalPath}/RECOVERYXLOG")) + { + my ($strActualChecksum) = storageDb()->hashSize("${strWalPath}/RECOVERYXLOG"); + + if ($strActualChecksum ne $strArchiveChecksum) + { + confess "recovered file hash '${strActualChecksum}' does not match expected '${strArchiveChecksum}'"; + } + } + else + { + confess "archive file '${strWalPath}/RECOVERYXLOG' is not in destination"; + } + + #--------------------------------------------------------------------------------------------------------------------------- + &log(INFO, ' db version mismatch error - archive-get unable to retrieve archiveId'); + + # db section and corresponding history munged + $oHostBackup->infoMunge( + storageRepo()->pathGet(STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE), + {&INFO_ARCHIVE_SECTION_DB_HISTORY => {'1' => {&INFO_ARCHIVE_KEY_DB_VERSION => '8.0'}}}); + + $oHostDbMaster->executeSimple( + $strCommandGet . " ${strSourceFile1} ${strWalPath}/RECOVERYXLOG", + {iExpectedExitStatus => ERROR_UNKNOWN, oLogTest => $self->expect()}); + + # Restore the file to its original condition + $oHostBackup->infoRestore(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE)); #--------------------------------------------------------------------------------------------------------------------------- &log(INFO, ' db system-id mismatch error'); $oHostBackup->infoMunge( storageRepo()->pathGet(STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE), - {&INFO_ARCHIVE_SECTION_DB => {&INFO_BACKUP_KEY_SYSTEM_ID => 5000900090001855000}}); + {&INFO_ARCHIVE_SECTION_DB => {&INFO_BACKUP_KEY_SYSTEM_ID => 5000900090001855000}, + &INFO_ARCHIVE_SECTION_DB_HISTORY => {'1' => {&INFO_ARCHIVE_KEY_DB_ID => 5000900090001855000}}}); $oHostDbMaster->executeSimple( $strCommandPush . " ${strWalPath}/${strSourceFile}", @@ -275,7 +309,7 @@ sub run $oHostDbMaster->executeSimple( $strCommandGet . " ${strSourceFile1} ${strWalPath}/RECOVERYXLOG", - {iExpectedExitStatus => ERROR_ARCHIVE_MISMATCH, oLogTest => $self->expect()}); + {iExpectedExitStatus => ERROR_UNKNOWN, oLogTest => $self->expect()}); # Restore the file to its original condition $oHostBackup->infoRestore(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE)); diff --git a/test/lib/pgBackRestTest/Module/Mock/MockStanzaTest.pm b/test/lib/pgBackRestTest/Module/Mock/MockStanzaTest.pm index ca8541667..957b9f1af 100644 --- a/test/lib/pgBackRestTest/Module/Mock/MockStanzaTest.pm +++ b/test/lib/pgBackRestTest/Module/Mock/MockStanzaTest.pm @@ -227,8 +227,6 @@ sub run {strOptionalParam => '--no-' . cfgOptionName(CFGOPT_ONLINE) . ' --' . cfgOptionName(CFGOPT_FORCE)}); } - # Fail on archive push due to mismatch of DB since stanza not upgraded - #-------------------------------------------------------------------------------------------------------------------------- # Encrypted info files could not be reconstructed above so just copy them back if ($bRepoEncrypt) { @@ -236,6 +234,13 @@ sub run forceStorageMove(storageRepo(), $strArchiveInfoCopyOldFile, $strArchiveInfoCopyFile, {bRecurse => false}); } + # Just before upgrading push one last WAL on the old version to ensure it can be retrieved later + #-------------------------------------------------------------------------------------------------------------------------- + ($strArchiveFile, $strSourceFile) = $self->archiveGenerate($strWalPath, 1, 2, WAL_VERSION_93); + $oHostDbMaster->executeSimple($strCommand . " ${strSourceFile}", {oLogTest => $self->expect()}); + + # Fail on archive push due to mismatch of DB since stanza not upgraded + #-------------------------------------------------------------------------------------------------------------------------- my $strArchiveTestFile = $self->dataPath() . '/backup.wal1_'; # Upgrade the DB by copying new pg_control @@ -252,6 +257,25 @@ sub run $oHostBackup->stanzaUpgrade('successful upgrade creates additional history', {strOptionalParam => '--no-' . cfgOptionName(CFGOPT_ONLINE)}); + # Make sure that WAL from the old version can still be retrieved + #-------------------------------------------------------------------------------------------------------------------------- + # Copy the old pg_control back so it looks like the original db has been restored + storageDb()->copy( + $self->dataPath() . '/backup.pg_control_' . WAL_VERSION_93 . '.bin', + $oHostDbMaster->dbBasePath() . '/' . DB_FILE_PGCONTROL); + + # Attempt to get the last archive log that was pushed to this repo + $oHostDbMaster->executeSimple( + $oHostDbMaster->backrestExe() . ' --config=' . $oHostDbMaster->backrestConfig() . + " --stanza=db archive-get ${strArchiveFile} " . $oHostDbMaster->dbBasePath() . '/pg_xlog/RECOVERYXLOG', + {oLogTest => $self->expect()}); + + # Copy the new pg_control back so the tests can continue with the upgraded stanza + storageDb()->copy( + $self->dataPath() . '/backup.pg_control_' . WAL_VERSION_94 . '.bin', + $oHostDbMaster->dbBasePath() . '/' . DB_FILE_PGCONTROL); + forceStorageMode(storageDb(), $oHostDbMaster->dbBasePath() . '/' . DB_FILE_PGCONTROL, '600'); + # After stanza upgrade, make sure archives are pushed to the new db verion-id directory (9.4-2) #-------------------------------------------------------------------------------------------------------------------------- # Push a WAL segment so have a valid file in the latest DB archive dir only [parent: 550d4fb9c591]