You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	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.
This commit is contained in:
		| @@ -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)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user