You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	The archive-push command is implemented entirely in C.
This new implementation should behave exactly like the old Perl code with the exception of updated log messages. Remove as much of the Perl code as possible without breaking other commands.
This commit is contained in:
		| @@ -90,6 +90,7 @@ sub run | ||||
|         $oHostBackup->stanzaCreate('create required data for stanza', {strOptionalParam => '--no-' . cfgOptionName(CFGOPT_ONLINE)}); | ||||
|  | ||||
|         # Push a WAL segment | ||||
|         &log(INFO, '    push first WAL'); | ||||
|         $oHostDbMaster->archivePush($strWalPath, $strWalTestFile, 1); | ||||
|  | ||||
|         # Break the database version of the archive info file | ||||
| @@ -97,17 +98,24 @@ sub run | ||||
|         { | ||||
|             $oHostBackup->infoMunge( | ||||
|                 $oStorage->pathGet(STORAGE_REPO_ARCHIVE . qw{/} . ARCHIVE_INFO_FILE), | ||||
|                 {&INFO_ARCHIVE_SECTION_DB => {&INFO_ARCHIVE_KEY_DB_VERSION => '8.0'}}); | ||||
|                 {&INFO_ARCHIVE_SECTION_DB => {&INFO_ARCHIVE_KEY_DB_VERSION => '8.0'}, | ||||
|                  &INFO_ARCHIVE_SECTION_DB_HISTORY => {1 => {&INFO_ARCHIVE_KEY_DB_VERSION => '8.0'}}}); | ||||
|         } | ||||
|  | ||||
|         # Push two more segments with errors to exceed archive-push-queue-max | ||||
|         $oHostDbMaster->archivePush( | ||||
|             $strWalPath, $strWalTestFile, 2, $iError ? ERROR_FILE_READ : ERROR_ARCHIVE_MISMATCH); | ||||
|         &log(INFO, '    push second WAL'); | ||||
|  | ||||
|         $oHostDbMaster->archivePush( | ||||
|             $strWalPath, $strWalTestFile, 3, $iError ? ERROR_FILE_READ : ERROR_ARCHIVE_MISMATCH); | ||||
|             $strWalPath, $strWalTestFile, 2, $iError ? ERROR_UNKNOWN : ERROR_ARCHIVE_MISMATCH); | ||||
|  | ||||
|         &log(INFO, '    push third WAL'); | ||||
|  | ||||
|         $oHostDbMaster->archivePush( | ||||
|             $strWalPath, $strWalTestFile, 3, $iError ? ERROR_UNKNOWN : ERROR_ARCHIVE_MISMATCH); | ||||
|  | ||||
|         # Now this segment will get dropped | ||||
|         &log(INFO, '    push fourth WAL'); | ||||
|  | ||||
|         $oHostDbMaster->archivePush($strWalPath, $strWalTestFile, 4, undef, undef, '--repo1-host=bogus'); | ||||
|  | ||||
|         # Fix the database version | ||||
|   | ||||
| @@ -273,39 +273,6 @@ sub run | ||||
|  | ||||
|         storageTest()->remove("${strWalPath}/archive_status/00000002.history.ready"); | ||||
|  | ||||
|         #--------------------------------------------------------------------------------------------------------------------------- | ||||
|         &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), | ||||
|             {&INFO_ARCHIVE_SECTION_DB => {&INFO_ARCHIVE_KEY_DB_VERSION => '8.0'}}); | ||||
|  | ||||
|         $oHostDbMaster->executeSimple( | ||||
|             $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", | ||||
|             {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'); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user