Skip to content

Commit a3382de

Browse files
committed
Provide a more accurate, detailed log message when the archive command fails.
1 parent 8db9ba1 commit a3382de

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

src/backend/postmaster/pgarch.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* IDENTIFICATION
22-
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.33 2007/11/24 21:37:04 tgl Exp $
22+
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.34 2007/12/12 09:39:54 petere Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -484,11 +484,35 @@ pgarch_archiveXlog(char *xlog)
484484
* Per the Single Unix Spec, shells report exit status > 128 when a
485485
* called command died on a signal.
486486
*/
487-
bool signaled = WIFSIGNALED(rc) || WEXITSTATUS(rc) > 128;
487+
int lev = (WIFSIGNALED(rc) || WEXITSTATUS(rc) > 128) ? FATAL : LOG;
488488

489-
ereport(signaled ? FATAL : LOG,
490-
(errmsg("archive command \"%s\" failed: return code %d",
491-
xlogarchcmd, rc)));
489+
if (WIFEXITED(rc))
490+
{
491+
ereport(lev,
492+
(errmsg("archive command failed with exit code %d", WEXITSTATUS(rc)),
493+
errdetail("The failed archive command was: %s", xlogarchcmd)));
494+
}
495+
else if (WIFSIGNALED(rc))
496+
{
497+
ereport(lev, (
498+
#if defined(WIN32)
499+
errmsg("archive command was terminated by exception 0x%X", WTERMSIG(rc)),
500+
errhint("See C include file \"ntstatus.h\" for a description of the hexadecimal value."),
501+
#elif defined(HAVE_DECL_SYS_SIGLIST) && HAVE_DECL_SYS_SIGLIST
502+
errmsg("archive command was terminated by signal %d: %s",
503+
WTERMSIG(rc),
504+
WTERMSIG(rc) < NSIG ? sys_siglist[WTERMSIG(rc)] : "(unknown)"),
505+
#else
506+
errmsg("archive command was terminated by signal %d", WTERMSIG(exitstatus)),
507+
#endif
508+
errdetail("The failed archive command was: %s", xlogarchcmd)));
509+
}
510+
else
511+
{
512+
ereport(lev,
513+
(errmsg("archive command exited with unrecognized status %d", rc),
514+
errdetail("The failed archive command was: %s", xlogarchcmd)));
515+
}
492516

493517
return false;
494518
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy