@@ -316,9 +316,10 @@ static bool FatalError = false; /* T if recovering from backend crash */
316316 * Notice that this state variable does not distinguish *why* we entered
317317 * states later than PM_RUN --- Shutdown and FatalError must be consulted
318318 * to find that out. FatalError is never true in PM_RECOVERY, PM_HOT_STANDBY,
319- * or PM_RUN states, nor in PM_SHUTDOWN states (because we don't enter those
320- * states when trying to recover from a crash). It can be true in PM_STARTUP
321- * state, because we don't clear it until we've successfully started WAL redo.
319+ * or PM_RUN states, nor in PM_WAIT_XLOG_SHUTDOWN states (because we don't
320+ * enter those states when trying to recover from a crash). It can be true in
321+ * PM_STARTUP state, because we don't clear it until we've successfully
322+ * started WAL redo.
322323 */
323324typedef enum
324325{
@@ -329,9 +330,9 @@ typedef enum
329330 PM_RUN , /* normal "database is alive" state */
330331 PM_STOP_BACKENDS , /* need to stop remaining backends */
331332 PM_WAIT_BACKENDS , /* waiting for live backends to exit */
332- PM_SHUTDOWN , /* waiting for checkpointer to do shutdown
333+ PM_WAIT_XLOG_SHUTDOWN , /* waiting for checkpointer to do shutdown
333334 * ckpt */
334- PM_SHUTDOWN_2 , /* waiting for archiver and walsenders to
335+ PM_WAIT_XLOG_ARCHIVAL , /* waiting for archiver and walsenders to
335336 * finish */
336337 PM_WAIT_DEAD_END , /* waiting for dead-end children to exit */
337338 PM_NO_CHILDREN , /* all important children have exited */
@@ -2354,7 +2355,7 @@ process_pm_child_exit(void)
23542355 {
23552356 ReleasePostmasterChildSlot (CheckpointerPMChild );
23562357 CheckpointerPMChild = NULL ;
2357- if (EXIT_STATUS_0 (exitstatus ) && pmState == PM_SHUTDOWN )
2358+ if (EXIT_STATUS_0 (exitstatus ) && pmState == PM_WAIT_XLOG_SHUTDOWN )
23582359 {
23592360 /*
23602361 * OK, we saw normal exit of the checkpointer after it's been
@@ -2363,8 +2364,8 @@ process_pm_child_exit(void)
23632364 * occur on next postmaster start.)
23642365 *
23652366 * At this point we should have no normal backend children
2366- * left (else we'd not be in PM_SHUTDOWN state) but we might
2367- * have dead-end children to wait for.
2367+ * left (else we'd not be in PM_WAIT_XLOG_SHUTDOWN state) but
2368+ * we might have dead-end children to wait for.
23682369 *
23692370 * If we have an archiver subprocess, tell it to do a last
23702371 * archive cycle and quit. Likewise, if we have walsender
@@ -2382,7 +2383,7 @@ process_pm_child_exit(void)
23822383 */
23832384 SignalChildren (SIGUSR2 , btmask (B_WAL_SENDER ));
23842385
2385- UpdatePMState (PM_SHUTDOWN_2 );
2386+ UpdatePMState (PM_WAIT_XLOG_ARCHIVAL );
23862387 }
23872388 else
23882389 {
@@ -2733,7 +2734,7 @@ HandleChildCrash(int pid, int exitstatus, const char *procname)
27332734 pmState == PM_HOT_STANDBY ||
27342735 pmState == PM_RUN ||
27352736 pmState == PM_STOP_BACKENDS ||
2736- pmState == PM_SHUTDOWN )
2737+ pmState == PM_WAIT_XLOG_SHUTDOWN )
27372738 UpdatePMState (PM_WAIT_BACKENDS );
27382739
27392740 /*
@@ -2957,7 +2958,7 @@ PostmasterStateMachine(void)
29572958 if (CheckpointerPMChild != NULL )
29582959 {
29592960 signal_child (CheckpointerPMChild , SIGUSR2 );
2960- UpdatePMState (PM_SHUTDOWN );
2961+ UpdatePMState (PM_WAIT_XLOG_SHUTDOWN );
29612962 }
29622963 else
29632964 {
@@ -2982,13 +2983,13 @@ PostmasterStateMachine(void)
29822983 }
29832984 }
29842985
2985- if (pmState == PM_SHUTDOWN_2 )
2986+ if (pmState == PM_WAIT_XLOG_ARCHIVAL )
29862987 {
29872988 /*
2988- * PM_SHUTDOWN_2 state ends when there's no other children than
2989- * dead-end children left. There shouldn't be any regular backends
2990- * left by now anyway; what we're really waiting for is walsenders and
2991- * archiver.
2989+ * PM_WAIT_XLOG_ARCHIVAL state ends when there's no other children
2990+ * than dead-end children left. There shouldn't be any regular
2991+ * backends left by now anyway; what we're really waiting for is
2992+ * walsenders and archiver.
29922993 */
29932994 if (CountChildren (btmask_all_except (B_LOGGER , B_DEAD_END_BACKEND )) == 0 )
29942995 {
@@ -3131,8 +3132,8 @@ pmstate_name(PMState state)
31313132 PM_TOSTR_CASE (PM_RUN );
31323133 PM_TOSTR_CASE (PM_STOP_BACKENDS );
31333134 PM_TOSTR_CASE (PM_WAIT_BACKENDS );
3134- PM_TOSTR_CASE (PM_SHUTDOWN );
3135- PM_TOSTR_CASE (PM_SHUTDOWN_2 );
3135+ PM_TOSTR_CASE (PM_WAIT_XLOG_SHUTDOWN );
3136+ PM_TOSTR_CASE (PM_WAIT_XLOG_ARCHIVAL );
31363137 PM_TOSTR_CASE (PM_WAIT_DEAD_END );
31373138 PM_TOSTR_CASE (PM_NO_CHILDREN );
31383139 }
@@ -3173,9 +3174,10 @@ LaunchMissingBackgroundProcesses(void)
31733174 * The checkpointer and the background writer are active from the start,
31743175 * until shutdown is initiated.
31753176 *
3176- * (If the checkpointer is not running when we enter the PM_SHUTDOWN
3177- * state, it is launched one more time to perform the shutdown checkpoint.
3178- * That's done in PostmasterStateMachine(), not here.)
3177+ * (If the checkpointer is not running when we enter the
3178+ * PM_WAIT_XLOG_SHUTDOWN state, it is launched one more time to perform
3179+ * the shutdown checkpoint. That's done in PostmasterStateMachine(), not
3180+ * here.)
31793181 */
31803182 if (pmState == PM_RUN || pmState == PM_RECOVERY ||
31813183 pmState == PM_HOT_STANDBY || pmState == PM_STARTUP )
@@ -3996,8 +3998,8 @@ bgworker_should_start_now(BgWorkerStartTime start_time)
39963998 {
39973999 case PM_NO_CHILDREN :
39984000 case PM_WAIT_DEAD_END :
3999- case PM_SHUTDOWN_2 :
4000- case PM_SHUTDOWN :
4001+ case PM_WAIT_XLOG_ARCHIVAL :
4002+ case PM_WAIT_XLOG_SHUTDOWN :
40014003 case PM_WAIT_BACKENDS :
40024004 case PM_STOP_BACKENDS :
40034005 break ;
0 commit comments