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 where an archive-push error would not be retried.
It would instead return errors to PostgreSQL indefinitely (unless the .error file was manually deleted). Reported by Jens Wilke.
This commit is contained in:
		| @@ -149,6 +149,18 @@ | ||||
|  | ||||
|     <release-list> | ||||
|         <release date="XXXX-XX-XX" version="1.14dev" title="UNDER DEVELOPMENT"> | ||||
|             <release-core-list> | ||||
|                 <release-bug-list> | ||||
|                     <release-item> | ||||
|                         <release-item-contributor-list> | ||||
|                             <release-item-ideator id="wilke.jens"/> | ||||
|                         </release-item-contributor-list> | ||||
|  | ||||
|                         <p>Fixed an issue where an archive-push error would not be retried and would instead return errors to <postgres/> indefinitely (unless the <file>.error</file> file was manually deleted).</p> | ||||
|                     </release-item> | ||||
|                 </release-bug-list> | ||||
|             </release-core-list> | ||||
|  | ||||
|             <release-doc-list> | ||||
|                 <release-feature-list> | ||||
|                     <release-item> | ||||
|   | ||||
| @@ -85,11 +85,12 @@ sub process | ||||
|         # Loop to check for status files and launch async process | ||||
|         my $bPushed = false; | ||||
|         my $oWait = waitInit(optionGet(OPTION_ARCHIVE_TIMEOUT)); | ||||
|         $self->{bConfessOnError} = false; | ||||
|  | ||||
|         do | ||||
|         { | ||||
|             # Check WAL status | ||||
|             $bPushed = $self->walStatus($self->{strSpoolPath}, $strWalFile); | ||||
|             $bPushed = $self->walStatus($self->{strSpoolPath}, $strWalFile, $self->{bConfessOnError}); | ||||
|  | ||||
|             # If not found then launch async process | ||||
|             if (!$bPushed) | ||||
| @@ -99,6 +100,8 @@ sub process | ||||
|                 $bClient = (new pgBackRest::Archive::ArchivePushAsync( | ||||
|                     $strWalPath, $self->{strSpoolPath}, $self->{strBackRestBin}))->process(); | ||||
|             } | ||||
|  | ||||
|             $self->{bConfessOnError} = true; | ||||
|         } | ||||
|         while ($bClient && !$bPushed && waitMore($oWait)); | ||||
|  | ||||
| @@ -168,12 +171,14 @@ sub walStatus | ||||
|         $strOperation, | ||||
|         $strSpoolPath, | ||||
|         $strWalFile, | ||||
|         $bConfessOnError, | ||||
|     ) = | ||||
|         logDebugParam | ||||
|         ( | ||||
|             __PACKAGE__ . '->walStatus', \@_, | ||||
|             {name => 'strSpoolPath'}, | ||||
|             {name => 'strWalFile'}, | ||||
|             {name => 'bConfessOnError', default => true}, | ||||
|         ); | ||||
|  | ||||
|     # Default result is false | ||||
| @@ -225,9 +230,11 @@ sub walStatus | ||||
|  | ||||
|                 &log(WARN, $strMessage); | ||||
|             } | ||||
|  | ||||
|             $bResult = true; | ||||
|         } | ||||
|         # Process error files | ||||
|         else | ||||
|         elsif ($bConfessOnError) | ||||
|         { | ||||
|             # Error files must have content | ||||
|             if (@stryWalStatus == 0) | ||||
| @@ -235,11 +242,8 @@ sub walStatus | ||||
|                 confess &log(ASSERT, "$stryStatusFile[0] has no content"); | ||||
|             } | ||||
|  | ||||
|             # Confess the error | ||||
|             confess &log(ERROR, $strMessage, $iCode); | ||||
|         } | ||||
|  | ||||
|         $bResult = true; | ||||
|     } | ||||
|  | ||||
|     # Return from function and log return values if any | ||||
|   | ||||
| @@ -35,7 +35,7 @@ use constant BACKREST_BIN                                           => abs_path( | ||||
| # Defines the current version of the BackRest executable.  The version number is used to track features but does not affect what | ||||
| # repositories or manifests can be read - that's the job of the format number. | ||||
| #----------------------------------------------------------------------------------------------------------------------------------- | ||||
| use constant BACKREST_VERSION                                       => '1.13'; | ||||
| use constant BACKREST_VERSION                                       => '1.14dev'; | ||||
|     push @EXPORT, qw(BACKREST_VERSION); | ||||
|  | ||||
| # Format Format Number | ||||
|   | ||||
| @@ -11,7 +11,7 @@ use AutoLoader; | ||||
| our @ISA = qw(Exporter); | ||||
|  | ||||
| # Library version (add .999 during development) | ||||
| our $VERSION = '1.13'; | ||||
| our $VERSION = '1.14.999'; | ||||
|  | ||||
| sub libCVersion {return $VERSION}; | ||||
|  | ||||
|   | ||||
| @@ -700,9 +700,24 @@ sub run | ||||
|         $self->optionSetTest($oOption, OPTION_SPOOL_PATH, $self->{strRepoPath}); | ||||
|         logDisable(); $self->configLoadExpect(dclone($oOption), CMD_ARCHIVE_PUSH); logEnable(); | ||||
|  | ||||
|         # Write an OK file so the async process is not actually started | ||||
|         # Write an error file and verify that it doesn't error the first time around | ||||
|         $strSegment = $self->walSegment($iWalTimeline, $iWalMajor, $iWalMinor++); | ||||
|         filePathCreate($self->{strSpoolPath}, undef, undef, true); | ||||
|         fileStringWrite("$self->{strSpoolPath}/${strSegment}.error", ERROR_ARCHIVE_TIMEOUT . "\ntest error"); | ||||
|  | ||||
|         $self->testException( | ||||
|             sub {$oPush->process("$self->{strWalPath}/${strSegment}")}, ERROR_ARCHIVE_TIMEOUT, | ||||
|             "test error"); | ||||
|  | ||||
|         $self->testResult($oPush->{bConfessOnError}, true, "went through error loop"); | ||||
|  | ||||
|         $self->testResult( | ||||
|             sub {walSegmentFind($self->{oFile}, $self->{strArchiveId}, $strSegment)}, '[undef]', | ||||
|             "${strSegment} WAL not in archive"); | ||||
|  | ||||
|         #--------------------------------------------------------------------------------------------------------------------------- | ||||
|         # Write an OK file so the async process is not actually started | ||||
|         $strSegment = $self->walSegment($iWalTimeline, $iWalMajor, $iWalMinor++); | ||||
|         fileStringWrite("$self->{strSpoolPath}/${strSegment}.ok"); | ||||
|  | ||||
|         $self->testResult( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user