Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fef88b3

Browse files
committed
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: Peter Geoghegan <[email protected]>
1 parent 7ab3214 commit fef88b3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/backend/access/transam/xlogarchive.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ RestoreArchivedFile(char *path, const char *xlogfname,
300300
signaled = WIFSIGNALED(rc) || WEXITSTATUS(rc) > 125;
301301

302302
ereport(signaled ? FATAL : DEBUG2,
303-
(errmsg("could not restore file \"%s\" from archive: return code %d",
304-
xlogfname, rc)));
303+
(errmsg("could not restore file \"%s\" from archive: %s",
304+
xlogfname, wait_result_to_str(rc))));
305305

306306
not_available:
307307

@@ -410,9 +410,10 @@ ExecuteRecoveryCommand(char *command, char *commandName, bool failOnSignal)
410410
ereport((signaled && failOnSignal) ? FATAL : WARNING,
411411
/*------
412412
translator: First %s represents a recovery.conf parameter name like
413-
"recovery_end_command", and the 2nd is the value of that parameter. */
414-
(errmsg("%s \"%s\": return code %d", commandName,
415-
command, rc)));
413+
"recovery_end_command", the 2nd is the value of that parameter, the
414+
third an already translated error message. */
415+
(errmsg("%s \"%s\": %s", commandName,
416+
command, wait_result_to_str(rc))));
416417
}
417418
}
418419

0 commit comments

Comments
 (0)