pgbackrest.git / summary / log / commit / refs

commit    bacc08792dae400de652ce2f769aeeda73f0ef8e
Author:   Cynthia Shang <cynthia.shang@crunchydata.com>
Commit:   David Steele <david@pgmasters.net>
Date:     Tue Jan 30 21:49:47 2018 +0000

    Ensure latest db-id is selected on when matching archive.info to backup.info.
    
    This provides correct matching in the event there are system-id and db-version duplicates (e.g. after reverting a pg_upgrade).
    
    Fixed by Cynthia Shang.
    Reported by Adam K. Sumner.


doc/xml/release.xml | 14 ++++++++++++++ lib/pgBackRest/Backup/Info.pm | 3 ++- .../lib/pgBackRestTest/Module/Backup/BackupInfoUnitTest.pm | 12 ++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 67327dccd..f98b7a9b6 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -20,6 +20,15 @@ <p>Fixed inability to restore a single database contained in a tablespace using --db-include.</p> </release-item> + + <release-item> + <release-item-contributor-list> + <release-item-ideator id="sumner.adam.k"/> + <release-item-contributor id="shang.cynthia"/> + </release-item-contributor-list> + + <p>Ensure latest <id>db-id</id> is selected on when matching <file>archive.info</file> to <file>backup.info</file>. This provides correct matching in the event there are <id>system-id</id> and <id>db-version</id> duplicates (e.g. after reverting a <id>pg_upgrade</id>).</p> + </release-item> </release-bug-list> <release-feature-list> @@ -4037,6 +4046,11 @@ <contributor-id type="github">Underhunden</contributor-id> </contributor> + <contributor id="sumner.adam.k"> + <contributor-name-display>Adam K. Sumner</contributor-name-display> + <contributor-id type="github">Flamacue</contributor-id> + </contributor> + <contributor id="uspen"> <contributor-name-display>Uspen</contributor-name-display> <contributor-id type="github">uspen</contributor-id> diff --git a/lib/pgBackRest/Backup/Info.pm b/lib/pgBackRest/Backup/Info.pm index 8abdb8c08..2098a505d 100644 --- a/lib/pgBackRest/Backup/Info.pm +++ b/lib/pgBackRest/Backup/Info.pm @@ -667,7 +667,8 @@ sub backupArchiveDbHistoryId my $ullDbSysIdArchive = $$hDbListArchive{$iDbIdArchive}{&INFO_SYSTEM_ID}; # Get the db-id from backup info history that corresponds to the archive db-version and db-system-id - foreach my $iDbIdBackup (keys %{$hDbListBackup}) + # Sort from newest (highest db-id) to oldest + foreach my $iDbIdBackup (sort {$b <=> $a} keys %{$hDbListBackup}) { if ($$hDbListBackup{$iDbIdBackup}{&INFO_SYSTEM_ID} == $ullDbSysIdArchive && $$hDbListBackup{$iDbIdBackup}{&INFO_DB_VERSION} eq $strDbVersionArchive) diff --git a/test/lib/pgBackRestTest/Module/Backup/BackupInfoUnitTest.pm b/test/lib/pgBackRestTest/Module/Backup/BackupInfoUnitTest.pm index 820df652d..4dfb8d743 100644 --- a/test/lib/pgBackRestTest/Module/Backup/BackupInfoUnitTest.pm +++ b/test/lib/pgBackRestTest/Module/Backup/BackupInfoUnitTest.pm @@ -186,6 +186,18 @@ sub run $strArchiveId = &PG_VERSION_93 . "-" . $iHistoryId; $self->testResult(sub {$oBackupInfo->backupArchiveDbHistoryId($strArchiveId, storageRepo()->pathGet(STORAGE_REPO_ARCHIVE))}, "[undef]", 'same db system-id but different version'); + + # First and last version and ullsystemid same in backup.info but only 1st in archive info - return last + #--------------------------------------------------------------------------------------------------------------------------- + $iHistoryId = $oBackupInfo->dbHistoryIdGet(true)+1; + $oBackupInfo->dbSectionSet( + PG_VERSION_93, $i93ControlVersion, $i93CatalogVersion, $self->dbSysId(PG_VERSION_93), $iHistoryId); + + $oBackupInfo->save(); + + $strArchiveId = &PG_VERSION_93 . "-1"; + $self->testResult(sub {$oBackupInfo->backupArchiveDbHistoryId($strArchiveId, + storageRepo()->pathGet(STORAGE_REPO_ARCHIVE))}, $iHistoryId, 'duplicate 1st and last version/sysid - last chosen'); } ################################################################################################################################ [parent: 00f58ec8c034]