*** a/src/backend/postmaster/postmaster.c --- b/src/backend/postmaster/postmaster.c *************** *** 287,292 **** typedef enum --- 287,294 ---- static PMState pmState = PM_INIT; + static bool ReachedEndOfRecovery = false; /* T if we've reached PM_RUN */ + bool ClientAuthInProgress = false; /* T during new-client * authentication */ *************** *** 2168,2174 **** pmdie(SIGNAL_ARGS) (errmsg("received smart shutdown request"))); if (pmState == PM_RUN || pmState == PM_RECOVERY || ! pmState == PM_HOT_STANDBY) { /* autovacuum workers are told to shut down immediately */ SignalAutovacWorkers(SIGTERM); --- 2170,2176 ---- (errmsg("received smart shutdown request"))); if (pmState == PM_RUN || pmState == PM_RECOVERY || ! pmState == PM_HOT_STANDBY || pmState == PM_STARTUP) { /* autovacuum workers are told to shut down immediately */ SignalAutovacWorkers(SIGTERM); *************** *** 2370,2375 **** reaper(SIGNAL_ARGS) --- 2372,2378 ---- * Startup succeeded, commence normal operations */ FatalError = false; + ReachedEndOfRecovery = true; pmState = PM_RUN; /* *************** *** 3028,3036 **** PostmasterStateMachine(void) { /* * Terminate backup mode to avoid recovery after a clean fast ! * shutdown. */ ! CancelBackup(); /* Normal exit from the postmaster is here */ ExitPostmaster(0); --- 3031,3042 ---- { /* * Terminate backup mode to avoid recovery after a clean fast ! * shutdown. We skip this cancellation if we've not reached ! * end of recovery yet since the backup label file is still ! * required for subsequent recovery. */ ! if (ReachedEndOfRecovery) ! CancelBackup(); /* Normal exit from the postmaster is here */ ExitPostmaster(0); *************** *** 3058,3063 **** PostmasterStateMachine(void) --- 3064,3072 ---- shmem_exit(1); reset_shared(PostPortNumber); + /* Reset to false before restarting recovery */ + ReachedEndOfRecovery = false; + StartupPID = StartupDataBase(); Assert(StartupPID != 0); pmState = PM_STARTUP; *************** *** 4208,4214 **** sigusr1_handler(SIGNAL_ARGS) } if (CheckPostmasterSignal(PMSIGNAL_START_WALRECEIVER) && ! WalReceiverPID == 0) { /* Startup Process wants us to start the walreceiver process. */ WalReceiverPID = StartWalReceiver(); --- 4217,4225 ---- } if (CheckPostmasterSignal(PMSIGNAL_START_WALRECEIVER) && ! WalReceiverPID == 0 && ! (pmState == PM_STARTUP || pmState == PM_RECOVERY || ! pmState == PM_HOT_STANDBY || pmState == PM_WAIT_READONLY)) { /* Startup Process wants us to start the walreceiver process. */ WalReceiverPID = StartWalReceiver();