Commit fef88b3f authored by Peter Eisentraut's avatar Peter Eisentraut

Report exit code from external recovery commands properly

When an external recovery command such as restore_command or
archive_cleanup_command fails, report the exit code properly,
distinguishing signals and normal exists, using the existing
wait_result_to_str() facility, instead of just reporting the return
value from system().
Reviewed-by: default avatarPeter Geoghegan <pg@heroku.com>
parent 7ab32140
...@@ -300,8 +300,8 @@ RestoreArchivedFile(char *path, const char *xlogfname, ...@@ -300,8 +300,8 @@ RestoreArchivedFile(char *path, const char *xlogfname,
signaled = WIFSIGNALED(rc) || WEXITSTATUS(rc) > 125; signaled = WIFSIGNALED(rc) || WEXITSTATUS(rc) > 125;
ereport(signaled ? FATAL : DEBUG2, ereport(signaled ? FATAL : DEBUG2,
(errmsg("could not restore file \"%s\" from archive: return code %d", (errmsg("could not restore file \"%s\" from archive: %s",
xlogfname, rc))); xlogfname, wait_result_to_str(rc))));
not_available: not_available:
...@@ -410,9 +410,10 @@ ExecuteRecoveryCommand(char *command, char *commandName, bool failOnSignal) ...@@ -410,9 +410,10 @@ ExecuteRecoveryCommand(char *command, char *commandName, bool failOnSignal)
ereport((signaled && failOnSignal) ? FATAL : WARNING, ereport((signaled && failOnSignal) ? FATAL : WARNING,
/*------ /*------
translator: First %s represents a recovery.conf parameter name like translator: First %s represents a recovery.conf parameter name like
"recovery_end_command", and the 2nd is the value of that parameter. */ "recovery_end_command", the 2nd is the value of that parameter, the
(errmsg("%s \"%s\": return code %d", commandName, third an already translated error message. */
command, rc))); (errmsg("%s \"%s\": %s", commandName,
command, wait_result_to_str(rc))));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment