summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2007-12-12 09:39:54 +0000
committerPeter Eisentraut2007-12-12 09:39:54 +0000
commit3dcfb4e337d2169192e1a6a2880272b835f9ddce (patch)
treeedae0e54c2784966298bf6764173cd2b9e8b62f3
parentc4ab66b0b0190b2785736b4a99346c011b509ad0 (diff)
Provide a more accurate, detailed log message when the archive command fails.
-rw-r--r--src/backend/postmaster/pgarch.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index 08660c0ac6..6901549dcf 100644
--- a/src/backend/postmaster/pgarch.c
+++ b/src/backend/postmaster/pgarch.c
@@ -484,11 +484,35 @@ pgarch_archiveXlog(char *xlog)
* Per the Single Unix Spec, shells report exit status > 128 when a
* called command died on a signal.
*/
- bool signaled = WIFSIGNALED(rc) || WEXITSTATUS(rc) > 128;
+ int lev = (WIFSIGNALED(rc) || WEXITSTATUS(rc) > 128) ? FATAL : LOG;
- ereport(signaled ? FATAL : LOG,
- (errmsg("archive command \"%s\" failed: return code %d",
- xlogarchcmd, rc)));
+ if (WIFEXITED(rc))
+ {
+ ereport(lev,
+ (errmsg("archive command failed with exit code %d", WEXITSTATUS(rc)),
+ errdetail("The failed archive command was: %s", xlogarchcmd)));
+ }
+ else if (WIFSIGNALED(rc))
+ {
+ ereport(lev, (
+#if defined(WIN32)
+ errmsg("archive command was terminated by exception 0x%X", WTERMSIG(rc)),
+ errhint("See C include file \"ntstatus.h\" for a description of the hexadecimal value."),
+#elif defined(HAVE_DECL_SYS_SIGLIST) && HAVE_DECL_SYS_SIGLIST
+ errmsg("archive command was terminated by signal %d: %s",
+ WTERMSIG(rc),
+ WTERMSIG(rc) < NSIG ? sys_siglist[WTERMSIG(rc)] : "(unknown)"),
+#else
+ errmsg("archive command was terminated by signal %d", WTERMSIG(exitstatus)),
+#endif
+ errdetail("The failed archive command was: %s", xlogarchcmd)));
+ }
+ else
+ {
+ ereport(lev,
+ (errmsg("archive command exited with unrecognized status %d", rc),
+ errdetail("The failed archive command was: %s", xlogarchcmd)));
+ }
return false;
}