Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcd85ae1

Browse files
committed
Improve pg_ctl's message for shutdown after recovery.
If pg_ctl tries to start the postmaster, but the postmaster shuts downbecause it completed a point-in-time recovery, pg_ctl used to reporta message that indicated a failure. It's not really a failure, soinstead say "server shut down because of recovery target settings".Zhao Junwang, Crisp Lee, Laurenz AlbeDiscussion:https://postgr.es/m/CAGHPtV7GttPZ-HvxZuYRy70jLGQMEm5=LQc4fKGa=J74m2VZbg@mail.gmail.com
1 parent56c6be5 commitcd85ae1

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ typedef enum
4545
{
4646
POSTMASTER_READY,
4747
POSTMASTER_STILL_STARTING,
48+
POSTMASTER_SHUTDOWN_IN_RECOVERY,
4849
POSTMASTER_FAILED,
4950
}WaitPMResult;
5051

@@ -657,17 +658,24 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
657658
* On Windows, we may be checking the postmaster's parent shell, but
658659
* that's fine for this purpose.
659660
*/
660-
#ifndefWIN32
661661
{
662+
boolpm_died;
663+
#ifndefWIN32
662664
intexitstatus;
663665

664-
if (waitpid(pm_pid,&exitstatus,WNOHANG)==pm_pid)
665-
returnPOSTMASTER_FAILED;
666-
}
666+
pm_died= (waitpid(pm_pid,&exitstatus,WNOHANG)==pm_pid);
667667
#else
668-
if (WaitForSingleObject(postmasterProcess,0)==WAIT_OBJECT_0)
669-
returnPOSTMASTER_FAILED;
668+
pm_died= (WaitForSingleObject(postmasterProcess,0)==WAIT_OBJECT_0);
670669
#endif
670+
if (pm_died)
671+
{
672+
/* See if postmaster terminated intentionally */
673+
if (get_control_dbstate()==DB_SHUTDOWNED_IN_RECOVERY)
674+
returnPOSTMASTER_SHUTDOWN_IN_RECOVERY;
675+
else
676+
returnPOSTMASTER_FAILED;
677+
}
678+
}
671679

672680
/* Startup still in process; wait, printing a dot once per second */
673681
if (i %WAITS_PER_SEC==0)
@@ -991,6 +999,10 @@ do_start(void)
991999
progname);
9921000
exit(1);
9931001
break;
1002+
casePOSTMASTER_SHUTDOWN_IN_RECOVERY:
1003+
print_msg(_(" done\n"));
1004+
print_msg(_("server shut down because of recovery target settings\n"));
1005+
break;
9941006
casePOSTMASTER_FAILED:
9951007
print_msg(_(" stopped waiting\n"));
9961008
write_stderr(_("%s: could not start server\n"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp