Skip to content

Commit f593c55

Browse files
committed
Tweak pg_promote() to report failures on kill() or postmaster failures
Since its introduction in 1007465, pg_promote() has been returning a false status in three cases: - SIGUSR1 not sent to the postmaster process. - Postmaster death during standby promotion. - Standby not promoted within the specified wait time. An application calling this function will have a hard time understanding what a false state returned actually means. Per discussion, this switches the two first states to fail rather than return a "false" status, making the second case more consistent with the existing CHECK_FOR_INTERRUPTS in the wait loop. False is only returned when the promotion is not completed within the specified time (60s by default). Author: Ashutosh Sharma Reviewed-by: Fujii Masao, Laurenz Albe, Michael Paquier Discussion: https://postgr.es/m/CAE9k0P=QTrwptL0t4J0fuBRDDjgsT-0PVKd-ikd96i1hyL7Bcg@mail.gmail.com
1 parent 36e4419 commit f593c55

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/backend/access/transam/xlogfuncs.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,10 @@ pg_promote(PG_FUNCTION_ARGS)
711711
/* signal the postmaster */
712712
if (kill(PostmasterPid, SIGUSR1) != 0)
713713
{
714-
ereport(WARNING,
715-
(errmsg("failed to send signal to postmaster: %m")));
716714
(void) unlink(PROMOTE_SIGNAL_FILE);
717-
PG_RETURN_BOOL(false);
715+
ereport(ERROR,
716+
(errcode(ERRCODE_SYSTEM_ERROR),
717+
errmsg("failed to send signal to postmaster: %m")));
718718
}
719719

720720
/* return immediately if waiting was not requested */
@@ -744,7 +744,10 @@ pg_promote(PG_FUNCTION_ARGS)
744744
* necessity for manual cleanup of all postmaster children.
745745
*/
746746
if (rc & WL_POSTMASTER_DEATH)
747-
PG_RETURN_BOOL(false);
747+
ereport(FATAL,
748+
(errcode(ERRCODE_ADMIN_SHUTDOWN),
749+
errmsg("terminating connection due to unexpected postmaster exit"),
750+
errcontext("while waiting on promotion")));
748751
}
749752

750753
ereport(WARNING,

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