From f5a8fe721e2cf099e0e8818c0512abbc0b5a657e Mon Sep 17 00:00:00 2001 From: Zhao Junwang Date: Thu, 9 Nov 2023 15:03:38 +0800 Subject: [PATCH] PITR shutdown should not report error by pg_ctl After a PITR recovery, the dbstate in pg_control is DB_SHUTDOWNED_IN_RECOVERY, check this and do not report error in pg_ctl. Signed-off-by: Zhao Junwang --- src/bin/pg_ctl/pg_ctl.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 3b145bd838..bc257dc060 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -46,6 +46,7 @@ typedef enum POSTMASTER_READY, POSTMASTER_STILL_STARTING, POSTMASTER_FAILED, + POSTMASTER_RECOVERY_SHUTDOWN, } WaitPMResult; typedef enum @@ -662,11 +663,19 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) int exitstatus; if (waitpid(pm_pid, &exitstatus, WNOHANG) == pm_pid) - return POSTMASTER_FAILED; + { + if (get_control_dbstate() == DB_SHUTDOWNED_IN_RECOVERY) + return POSTMASTER_RECOVERY_SHUTDOWN; + else return POSTMASTER_FAILED; + } } #else if (WaitForSingleObject(postmasterProcess, 0) == WAIT_OBJECT_0) - return POSTMASTER_FAILED; + { + if (get_control_dbstate() == DB_SHUTDOWNED_IN_RECOVERY) + return POSTMASTER_RECOVERY_SHUTDOWN; + else return POSTMASTER_FAILED; + } #endif /* Startup still in process; wait, printing a dot once per second */ @@ -991,10 +1000,14 @@ do_start(void) progname); exit(1); break; + case POSTMASTER_RECOVERY_SHUTDOWN: + print_msg(_("PITR shutdown\n")); + print_msg(_("update configuration for startup again if needed\n")); + break; case POSTMASTER_FAILED: print_msg(_(" stopped waiting\n")); write_stderr(_("%s: could not start server\n" - "Examine the log output.\n"), + "Examine the log output\n"), progname); exit(1); break; -- 2.41.0