Improve pg_ctl's message for shutdown after recovery.
If pg_ctl tries to start the postmaster, but the postmaster shuts down because it completed a point-in-time recovery, pg_ctl used to report a message that indicated a failure. It's not really a failure, so instead say "server shut down because of recovery target settings". Zhao Junwang, Crisp Lee, Laurenz Albe Discussion: https://postgr.es/m/CAGHPtV7GttPZ-HvxZuYRy70jLGQMEm5=LQc4fKGa=J74m2VZbg@mail.gmail.com
This commit is contained in:
parent
56c6be57af
commit
cd85ae1114
@ -45,6 +45,7 @@ typedef enum
|
|||||||
{
|
{
|
||||||
POSTMASTER_READY,
|
POSTMASTER_READY,
|
||||||
POSTMASTER_STILL_STARTING,
|
POSTMASTER_STILL_STARTING,
|
||||||
|
POSTMASTER_SHUTDOWN_IN_RECOVERY,
|
||||||
POSTMASTER_FAILED,
|
POSTMASTER_FAILED,
|
||||||
} WaitPMResult;
|
} WaitPMResult;
|
||||||
|
|
||||||
@ -657,17 +658,24 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
|
|||||||
* On Windows, we may be checking the postmaster's parent shell, but
|
* On Windows, we may be checking the postmaster's parent shell, but
|
||||||
* that's fine for this purpose.
|
* that's fine for this purpose.
|
||||||
*/
|
*/
|
||||||
#ifndef WIN32
|
|
||||||
{
|
{
|
||||||
|
bool pm_died;
|
||||||
|
#ifndef WIN32
|
||||||
int exitstatus;
|
int exitstatus;
|
||||||
|
|
||||||
if (waitpid(pm_pid, &exitstatus, WNOHANG) == pm_pid)
|
pm_died = (waitpid(pm_pid, &exitstatus, WNOHANG) == pm_pid);
|
||||||
|
#else
|
||||||
|
pm_died = (WaitForSingleObject(postmasterProcess, 0) == WAIT_OBJECT_0);
|
||||||
|
#endif
|
||||||
|
if (pm_died)
|
||||||
|
{
|
||||||
|
/* See if postmaster terminated intentionally */
|
||||||
|
if (get_control_dbstate() == DB_SHUTDOWNED_IN_RECOVERY)
|
||||||
|
return POSTMASTER_SHUTDOWN_IN_RECOVERY;
|
||||||
|
else
|
||||||
return POSTMASTER_FAILED;
|
return POSTMASTER_FAILED;
|
||||||
}
|
}
|
||||||
#else
|
}
|
||||||
if (WaitForSingleObject(postmasterProcess, 0) == WAIT_OBJECT_0)
|
|
||||||
return POSTMASTER_FAILED;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Startup still in process; wait, printing a dot once per second */
|
/* Startup still in process; wait, printing a dot once per second */
|
||||||
if (i % WAITS_PER_SEC == 0)
|
if (i % WAITS_PER_SEC == 0)
|
||||||
@ -991,6 +999,10 @@ do_start(void)
|
|||||||
progname);
|
progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
|
case POSTMASTER_SHUTDOWN_IN_RECOVERY:
|
||||||
|
print_msg(_(" done\n"));
|
||||||
|
print_msg(_("server shut down because of recovery target settings\n"));
|
||||||
|
break;
|
||||||
case POSTMASTER_FAILED:
|
case POSTMASTER_FAILED:
|
||||||
print_msg(_(" stopped waiting\n"));
|
print_msg(_(" stopped waiting\n"));
|
||||||
write_stderr(_("%s: could not start server\n"
|
write_stderr(_("%s: could not start server\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user