You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-05-22 10:15:16 +02:00
Move async forking and more error handling to C.
The Perl process was exiting directly when called but that interfered with proper locking for the forked async process. Now Perl returns results to the C process which handles all errors, including signals.
This commit is contained in:
@@ -590,7 +590,7 @@ sub run
|
||||
my $strSegment = $self->walSegment($iWalTimeline, $iWalMajor, $iWalMinor++);
|
||||
$self->walGenerate($self->{strWalPath}, PG_VERSION_94, 1, $strSegment);
|
||||
|
||||
$self->testResult(sub {$oPush->process("pg_xlog/${strSegment}")}, 0, "${strSegment} WAL pushed (with relative path)");
|
||||
$self->testResult(sub {$oPush->process("pg_xlog/${strSegment}")}, undef, "${strSegment} WAL pushed (with relative path)");
|
||||
|
||||
$self->testResult(
|
||||
sub {walSegmentFind(storageRepo(), $self->{strArchiveId}, $strSegment)}, "${strSegment}-$self->{strWalHash}",
|
||||
@@ -606,7 +606,7 @@ sub run
|
||||
$strSegment = $self->walSegment($iWalTimeline, $iWalMajor, $iWalMinor++);
|
||||
$self->walGenerate($self->{strWalPath}, PG_VERSION_94, 1, $strSegment);
|
||||
|
||||
$self->testResult(sub {$oPush->process("$self->{strWalPath}/${strSegment}")}, 0, "${strSegment} WAL dropped");
|
||||
$self->testResult(sub {$oPush->process("$self->{strWalPath}/${strSegment}")}, undef, "${strSegment} WAL dropped");
|
||||
$self->testResult(
|
||||
sub {walSegmentFind(storageRepo(), $self->{strArchiveId}, $strSegment)}, '[undef]',
|
||||
"${strSegment} WAL in archive");
|
||||
@@ -615,7 +615,7 @@ sub run
|
||||
$self->optionTestSet(CFGOPT_ARCHIVE_QUEUE_MAX, PG_WAL_SIZE * 4);
|
||||
$self->configTestLoad(CFGCMD_ARCHIVE_PUSH);
|
||||
|
||||
$self->testResult(sub {$oPush->process("$self->{strWalPath}/${strSegment}")}, 0, "${strSegment} WAL pushed");
|
||||
$self->testResult(sub {$oPush->process("$self->{strWalPath}/${strSegment}")}, undef, "${strSegment} WAL pushed");
|
||||
$self->testResult(
|
||||
sub {walSegmentFind(storageRepo(), $self->{strArchiveId}, $strSegment)}, "${strSegment}-$self->{strWalHash}",
|
||||
"${strSegment} WAL in archive");
|
||||
@@ -634,18 +634,7 @@ sub run
|
||||
|
||||
$strSegment = $self->walSegment($iWalTimeline, $iWalMajor, $iWalMinor++);
|
||||
$self->walGenerate($self->{strWalPath}, PG_VERSION_94, 1, $strSegment);
|
||||
$self->testResult(sub {$oPush->process("$self->{strWalPath}/${strSegment}")}, 0, "${strSegment} WAL pushed async");
|
||||
$self->testResult(sub {$oPush->process("$self->{strWalPath}/${strSegment}")}, 0, "hit lock - already running");
|
||||
|
||||
# Wait for child process to exit
|
||||
if ($iProcessId == $PID)
|
||||
{
|
||||
waitpid(-1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
exit 0;
|
||||
}
|
||||
$self->testResult(sub {$oPush->process("$self->{strWalPath}/${strSegment}")}, undef, "${strSegment} WAL pushed async");
|
||||
|
||||
$self->testResult(
|
||||
sub {walSegmentFind(storageRepo(), $self->{strArchiveId}, $strSegment, 5)}, "${strSegment}-$self->{strWalHash}",
|
||||
@@ -662,28 +651,10 @@ sub run
|
||||
$self->optionTestSet(CFGOPT_ARCHIVE_TIMEOUT, 5);
|
||||
$self->configTestLoad(CFGCMD_ARCHIVE_PUSH);
|
||||
|
||||
|
||||
# Wait for error file to appear
|
||||
my $oWait = waitInit(10);
|
||||
my $strErrorFile = STORAGE_SPOOL_ARCHIVE_OUT . "/${strSegment}.error";
|
||||
|
||||
do
|
||||
{
|
||||
$self->testResult(sub {$oPush->process("$self->{strWalPath}/${strSegment}")}, 0, 'process connect error');
|
||||
|
||||
# Wait for child process to exit
|
||||
if ($iProcessId == $PID)
|
||||
{
|
||||
waitpid(-1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
while (!storageSpool()->exists($strErrorFile) && waitMore($oWait));
|
||||
$self->testResult(sub {$oPush->process("$self->{strWalPath}/${strSegment}")}, undef, 'process connect error');
|
||||
|
||||
# Check contents of error file
|
||||
my $strErrorFile = STORAGE_SPOOL_ARCHIVE_OUT . "/${strSegment}.error";
|
||||
my $strErrorFileContents = ${storageSpool()->get($strErrorFile)};
|
||||
|
||||
$self->testResult(
|
||||
|
||||
@@ -175,7 +175,7 @@ sub run
|
||||
|
||||
# Output No stanzas exist in default text option
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
$self->testResult(sub {$oInfo->process()}, 0, 'No stanzas exist and default text option');
|
||||
$self->testResult(sub {$oInfo->process()}, undef, 'No stanzas exist and default text option');
|
||||
|
||||
# Invalid option
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -188,7 +188,7 @@ sub run
|
||||
$self->optionTestSet(CFGOPT_OUTPUT, CFGOPTVAL_INFO_OUTPUT_JSON);
|
||||
$self->configTestLoad(CFGCMD_INFO);
|
||||
|
||||
$self->testResult(sub {$oInfo->process()}, 0, 'json option');
|
||||
$self->testResult(sub {$oInfo->process()}, undef, 'json option');
|
||||
|
||||
# Add linefeed to JSON
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -285,7 +285,7 @@ sub run
|
||||
$self->optionTestClear(CFGOPT_OUTPUT);
|
||||
$self->configTestLoad(CFGCMD_INFO);
|
||||
|
||||
$self->testResult(sub {$oInfo->process()}, 0, 'stanza set');
|
||||
$self->testResult(sub {$oInfo->process()}, undef, 'stanza set');
|
||||
|
||||
# Create the stanza - no WAL or backups
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -514,10 +514,10 @@ sub run
|
||||
my $oStanza = new pgBackRest::Stanza();
|
||||
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
$self->testResult(sub {$oStanza->stanzaUpgrade()}, 0, 'successfully upgraded');
|
||||
$self->testResult(sub {$oStanza->stanzaUpgrade()}, undef, 'successfully upgraded');
|
||||
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
$self->testResult(sub {$oStanza->stanzaUpgrade()}, 0, 'upgrade not required');
|
||||
$self->testResult(sub {$oStanza->stanzaUpgrade()}, undef, 'upgrade not required');
|
||||
|
||||
# Attempt to change the encryption settings
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -570,7 +570,7 @@ sub run
|
||||
$self->testResult(sub {storageRepo()->encrypted($strArchivedFile)}, true, 'created encrypted archive WAL');
|
||||
|
||||
# Upgrade
|
||||
$self->testResult(sub {$oStanza->stanzaUpgrade()}, 0, ' successfully upgraded');
|
||||
$self->testResult(sub {$oStanza->stanzaUpgrade()}, undef, ' successfully upgraded');
|
||||
$self->testResult(sub {storageRepo()->encrypted(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE) . '/'
|
||||
. ARCHIVE_INFO_FILE)}, true, ' upgraded archive info encrypted');
|
||||
$self->testResult(sub {storageRepo()->encrypted(storageRepo()->pathGet(STORAGE_REPO_BACKUP) . '/'
|
||||
@@ -720,7 +720,7 @@ sub run
|
||||
$self->optionTestSetBool(CFGOPT_FORCE, true);
|
||||
$self->configTestLoad(CFGCMD_STANZA_DELETE);
|
||||
|
||||
$self->testResult(sub {$oStanza->stanzaDelete()}, 0, 'successfully delete stanza with force');
|
||||
$self->testResult(sub {$oStanza->stanzaDelete()}, undef, 'successfully delete stanza with force');
|
||||
$self->testResult(sub {storageRepo()->pathExists($self->{strArchivePath}) ||
|
||||
storageRepo()->pathExists($self->{strBackupPath})},
|
||||
false, ' neither archive nor backup repo paths for the stanza exist');
|
||||
@@ -731,7 +731,7 @@ sub run
|
||||
|
||||
# Rerun stanza-delete without force and with missing stanza directories
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
$self->testResult(sub {$oStanza->stanzaDelete()}, 0, 'successful - stanza already deleted');
|
||||
$self->testResult(sub {$oStanza->stanzaDelete()}, undef, 'successful - stanza already deleted');
|
||||
|
||||
# Recursive dir delete with archive directory and stanza directory but missing info files
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -750,7 +750,7 @@ sub run
|
||||
executeTest("sudo chown 777 " . $self->{strBackupPath} . "/${strFullLabel}/" . BOGUS);
|
||||
|
||||
lockStop();
|
||||
$self->testResult(sub {$oStanza->stanzaDelete()}, 0,
|
||||
$self->testResult(sub {$oStanza->stanzaDelete()}, undef,
|
||||
'successful - recursive delete with missing info files and inaccessible file');
|
||||
$self->testResult(sub {storageRepo()->pathExists($self->{strArchivePath}) ||
|
||||
storageRepo()->pathExists($self->{strBackupPath})},
|
||||
@@ -801,7 +801,7 @@ sub run
|
||||
"[undef]", ' manifest saved');
|
||||
|
||||
lockStop();
|
||||
$self->testResult(sub {$oStanza->stanzaDelete()}, 0,
|
||||
$self->testResult(sub {$oStanza->stanzaDelete()}, undef,
|
||||
' successful - recursive delete on encrypted repo');
|
||||
$self->testResult(sub {storageRepo()->pathExists($self->{strArchivePath}) ||
|
||||
storageRepo()->pathExists($self->{strBackupPath})},
|
||||
|
||||
Reference in New Issue
Block a user