1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-09-16 09:06:18 +02:00

Improved errors returned from child processes by removing redundant error level and code.

This commit is contained in:
David Steele
2016-12-04 17:51:00 -05:00
parent 817592837c
commit 896984848b
10 changed files with 43 additions and 23 deletions

View File

@@ -62,7 +62,8 @@ local $EVAL_ERROR = undef; eval
if (commandTest(CMD_REMOTE))
{
# Set log levels
logLevelSet(OFF, OFF, OFF);
optionSet(OPTION_LOG_LEVEL_STDERR, PROTOCOL, true);
logLevelSet(OFF, OFF, optionGet(OPTION_LOG_LEVEL_STDERR));
# Check that the repo path exists if this is a backup remote
if (optionTest(OPTION_TYPE, BACKUP) && !-e optionGet(OPTION_REPO_PATH))
@@ -97,7 +98,8 @@ local $EVAL_ERROR = undef; eval
if (commandTest(CMD_LOCAL))
{
# Set log levels
logLevelSet(OFF, OFF, OFF);
optionSet(OPTION_LOG_LEVEL_STDERR, PROTOCOL, true);
logLevelSet(OFF, OFF, optionGet(OPTION_LOG_LEVEL_STDERR));
# Load module dynamically
require pgBackRest::Protocol::LocalMinion;

View File

@@ -186,6 +186,10 @@
<p>Simplified the result hash of <code>File->manifest()</code>, <code>Db->tablespaceMapGet()</code>, and <code>Db->databaseMapGet()</code>.</p>
</release-item>
<release-item>
<p>Improved errors returned from child processes by removing redundant error level and code.</p>
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-contributor id="shang.cynthia"/>

View File

@@ -90,7 +90,7 @@ sub exitSafe
}
elsif ($iExitCode == ERROR_TERM)
{
&log(ERROR, "process terminated on a ${strSignal} signal", ERROR_TERM);
&log(ERROR, "terminated on signal [SIG${strSignal}]", ERROR_TERM);
}
# Log command end

View File

@@ -38,6 +38,8 @@ use constant INFO => 'INFO';
push @EXPORT, qw(INFO);
use constant WARN => 'WARN';
push @EXPORT, qw(WARN);
use constant PROTOCOL => 'PROTOCOL';
push @EXPORT, qw(PROTOCOL);
use constant ERROR => 'ERROR';
push @EXPORT, qw(ERROR);
use constant ASSERT => 'ASSERT';
@@ -50,11 +52,12 @@ use constant OFF => 'OFF';
####################################################################################################################################
my %oLogLevelRank;
$oLogLevelRank{TRACE}{rank} = 7;
$oLogLevelRank{DEBUG}{rank} = 6;
$oLogLevelRank{DETAIL}{rank} = 5;
$oLogLevelRank{INFO}{rank} = 4;
$oLogLevelRank{WARN}{rank} = 3;
$oLogLevelRank{TRACE}{rank} = 8;
$oLogLevelRank{DEBUG}{rank} = 7;
$oLogLevelRank{DETAIL}{rank} = 6;
$oLogLevelRank{INFO}{rank} = 5;
$oLogLevelRank{WARN}{rank} = 4;
$oLogLevelRank{PROTOCOL}{rank} = 3;
$oLogLevelRank{ERROR}{rank} = 2;
$oLogLevelRank{ASSERT}{rank} = 1;
$oLogLevelRank{OFF}{rank} = 0;
@@ -587,7 +590,12 @@ sub log
# Output to stderr depending on log level
if (!$rExtra->{bLogConsole} && $iLogLevelRank <= $oLogLevelRank{$strLogLevelStdErr}{rank})
{
syswrite(*STDERR, $strLevel . (defined($iCode) ? " [${iCode}]" : '') . ": $strMessage\n");
if ($strLogLevelStdErr ne PROTOCOL)
{
syswrite(*STDERR, $strLevel . (defined($iCode) ? " [${iCode}]" : '') . ': ');
}
syswrite(*STDERR, "${strMessage}\n");
$rExtra->{bLogConsole} = true;
}
# Else output to stdout depending on log level and test flag

View File

@@ -1879,7 +1879,7 @@ sub configLogging
{
my $bLogInitForce = shift;
if (($bInitLog || (defined($bLogInitForce) && $bLogInitForce)) && !commandTest(CMD_REMOTE) && !commandTest(CMD_LOCAL))
if ($bInitLog || (defined($bLogInitForce) && $bLogInitForce))
{
logLevelSet(
optionValid(OPTION_LOG_LEVEL_FILE) ? optionGet(OPTION_LOG_LEVEL_FILE) : OFF,
@@ -2867,11 +2867,14 @@ sub optionSet
{
my $strOption = shift;
my $oValue = shift;
my $bForce = shift;
optionValid($strOption, true);
if (!optionValid($strOption, !defined($bForce) || !$bForce))
{
$oOption{$strOption}{valid} = true;
}
$oOption{$strOption}{source} = SOURCE_PARAM;
$oOption{$strOption}{value} = $oValue;
}

View File

@@ -154,6 +154,9 @@ sub process
{
my $self = shift;
# Reset stderr log level so random errors do not get output
logLevelSet(undef, undef, OFF);
# Loop until the exit command is received
eval
{
@@ -202,7 +205,7 @@ sub process
my $oException = $EVAL_ERROR;
# Change log level so error will go to stderr
logLevelSet(undef, undef, ERROR);
logLevelSet(undef, undef, PROTOCOL);
# If standard exception
if (isException($oException))

View File

@@ -162,7 +162,7 @@ P00 DEBUG: Common::Exit::exitSafe(): iExitCode = 138, oException = [undef],
P00 DEBUG: Protocol::Protocol::protocolDestroy(): bComplete = false, iRemoteIdx = [undef], strRemoteType = [undef]
P00 DEBUG: Protocol::Protocol::protocolDestroy=>: iExitStatus = 0
P00 DEBUG: Common::Lock::lockRelease(): bFailOnNoLock = false
P00 ERROR: [138]: process terminated on a TERM signal
P00 ERROR: [138]: terminated on signal [SIGTERM]
P00 INFO: archive-push command end: terminated on signal [SIGTERM]
P00 DEBUG: Common::Exit::exitSafe=>: iExitCode = 138

View File

@@ -168,7 +168,7 @@ P00 DEBUG: Common::Exit::exitSafe(): iExitCode = 138, oException = [undef],
P00 DEBUG: Protocol::Protocol::protocolDestroy(): bComplete = false, iRemoteIdx = [undef], strRemoteType = [undef]
P00 DEBUG: Protocol::Protocol::protocolDestroy=>: iExitStatus = 0
P00 DEBUG: Common::Lock::lockRelease(): bFailOnNoLock = false
P00 ERROR: [138]: process terminated on a TERM signal
P00 ERROR: [138]: terminated on signal [SIGTERM]
P00 INFO: archive-push command end: terminated on signal [SIGTERM]
P00 DEBUG: Common::Exit::exitSafe=>: iExitCode = 138

View File

@@ -416,7 +416,7 @@ P00 DEBUG: Common::Exit::exitSafe(): iExitCode = 138, oException = [undef],
P00 DEBUG: Protocol::Protocol::protocolDestroy(): bComplete = false, iRemoteIdx = [undef], strRemoteType = [undef]
P00 DEBUG: Protocol::Protocol::protocolDestroy=>: iExitStatus = 0
P00 DEBUG: Common::Lock::lockRelease(): bFailOnNoLock = false
P00 ERROR: [138]: process terminated on a TERM signal
P00 ERROR: [138]: terminated on signal [SIGTERM]
P00 INFO: backup command end: terminated on signal [SIGTERM]
P00 DEBUG: Common::Exit::exitSafe=>: iExitCode = 138

View File

@@ -371,7 +371,7 @@ P00 DEBUG: Backup->processManifest(): bCompress = false, bHardLink = false,
P00 TEST: PgBaCkReStTeSt-BACKUP-START-PgBaCkReStTeSt
P00 DEBUG: Protocol::Protocol::protocolGet(): iRemoteIdx = 1, oParam = [undef], strRemoteType = db
P00 DEBUG: Protocol::Protocol::protocolGet: found cached protocol
P00 ERROR: [141]: remote process terminated on db-master host: ERROR [141]: unable to read line after 1 second(s)
P00 ERROR: [141]: remote process terminated on db-master host: unable to read line after 1 second(s)
P00 DEBUG: Common::Exit::exitSafe(): iExitCode = [undef], oException = [object], strSignal = [undef]
P00 DEBUG: Protocol::Protocol::protocolDestroy(): bComplete = false, iRemoteIdx = [undef], strRemoteType = [undef]
P00 DEBUG: Protocol::Protocol::protocolDestroy: found cached protocol: iRemoteIdx = 1, strRemoteType = db
@@ -440,7 +440,7 @@ P00 DEBUG: Backup->processManifest(): bCompress = false, bHardLink = false,
P00 TEST: PgBaCkReStTeSt-BACKUP-START-PgBaCkReStTeSt
P00 DEBUG: Protocol::Protocol::protocolGet(): iRemoteIdx = 1, oParam = [undef], strRemoteType = db
P00 DEBUG: Protocol::Protocol::protocolGet: found cached protocol
P00 ERROR: [138]: remote process terminated on db-master host: no error on stderr
P00 ERROR: [138]: remote process terminated on db-master host: terminated on signal [SIGTERM]
P00 DEBUG: Common::Exit::exitSafe(): iExitCode = [undef], oException = [object], strSignal = [undef]
P00 DEBUG: Protocol::Protocol::protocolDestroy(): bComplete = false, iRemoteIdx = [undef], strRemoteType = [undef]
P00 DEBUG: Protocol::Protocol::protocolDestroy: found cached protocol: iRemoteIdx = 1, strRemoteType = db
@@ -479,7 +479,7 @@ P00 DEBUG: Protocol::Protocol::protocolGet: found cached protocol
P00 DEBUG: File->new(): oProtocol = [object], strBackupPath = [TEST_PATH]/backup/repo, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strStanza = db
P00 DEBUG: Db->info(): strDbPath = <[TEST_PATH]/db-master/db/base>
P00 DEBUG: File->new(): oProtocol = [object], strBackupPath = [TEST_PATH]/backup/repo, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strStanza = db
P00 ERROR: [137]: remote process terminated on db-master host: no error on stderr
P00 ERROR: [137]: remote process terminated on db-master host: stop file exists for all stanzas
P00 DEBUG: Common::Exit::exitSafe(): iExitCode = [undef], oException = [object], strSignal = [undef]
P00 DEBUG: Protocol::Protocol::protocolDestroy(): bComplete = false, iRemoteIdx = [undef], strRemoteType = [undef]
P00 DEBUG: Protocol::Protocol::protocolDestroy: found cached protocol: iRemoteIdx = 1, strRemoteType = db
@@ -541,7 +541,7 @@ P00 DEBUG: Protocol::Protocol::protocolGet: found cached protocol
P00 DEBUG: File->new(): oProtocol = [object], strBackupPath = [TEST_PATH]/backup/repo, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strStanza = db
P00 DEBUG: Db->info(): strDbPath = <[TEST_PATH]/db-master/db/base>
P00 DEBUG: File->new(): oProtocol = [object], strBackupPath = [TEST_PATH]/backup/repo, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strStanza = db
P00 ERROR: [137]: remote process terminated on db-master host: no error on stderr
P00 ERROR: [137]: remote process terminated on db-master host: stop file exists for stanza db
P00 DEBUG: Common::Exit::exitSafe(): iExitCode = [undef], oException = [object], strSignal = [undef]
P00 DEBUG: Protocol::Protocol::protocolDestroy(): bComplete = false, iRemoteIdx = [undef], strRemoteType = [undef]
P00 DEBUG: Protocol::Protocol::protocolDestroy: found cached protocol: iRemoteIdx = 1, strRemoteType = db
@@ -651,7 +651,7 @@ P00 DEBUG: Protocol::Protocol::protocolDestroy: found cached protocol: iRem
P00 DEBUG: Protocol::CommonMaster->close=>: iExitStatus = 0
P00 DEBUG: Protocol::Protocol::protocolDestroy=>: iExitStatus = 0
P00 DEBUG: Common::Lock::lockRelease(): bFailOnNoLock = false
P00 ERROR: [138]: process terminated on a TERM signal
P00 ERROR: [138]: terminated on signal [SIGTERM]
P00 INFO: backup command end: terminated on signal [SIGTERM]
P00 DEBUG: Common::Exit::exitSafe=>: iExitCode = 138
@@ -4146,6 +4146,6 @@ diff backup - protocol shutdown timeout (backup host)
P00 WARN: option retention-full is not set, the repository may run out of space
HINT: to retain full backups indefinitely (without warning), set option 'retention-full' to the maximum.
P00 TEST: PgBaCkReStTeSt-BACKUP-STOP-PgBaCkReStTeSt
P00 ERROR: [141]: remote process terminated on db-master host: ERROR [141]: unable to read line after 2 second(s)
P00 WARN: unable to shutdown protocol [141]: remote process terminated on db-master host: ERROR [141]: unable to read line after 2 second(s)
P00 ERROR: [141]: remote process terminated on db-master host: unable to read line after 2 second(s)
P00 WARN: unable to shutdown protocol [141]: remote process terminated on db-master host: unable to read line after 2 second(s)
HINT: the process completed all operations successfully but protocol-timeout may need to be increased.