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

Commit28e7a99

Browse files
committed
postmaster: Rename some shutdown related PMState phase names
The previous names weren't particularly clear. Future patches will add moreshutdown phases, making it even more important to have understandable shutdownphases.Suggested-by: Heikki Linnakangas <hlinnaka@iki.fi>Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>Discussion:https://postgr.es/m/d2cd8fd3-396a-4390-8f0b-74be65e72899@iki.fi
1 parente84712c commit28e7a99

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
323324
typedefenum
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 inPM_SHUTDOWN state) but we might
2367-
* have dead-end children to wait for.
2367+
* left (else we'd not be inPM_WAIT_XLOG_SHUTDOWN state) but
2368+
*we mighthave 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+
*thandead-end children left. There shouldn't be any regular
2991+
*backendsleft by now anyway; what we're really waiting for is
2992+
*walsenders andarchiver.
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
casePM_NO_CHILDREN:
39984000
casePM_WAIT_DEAD_END:
3999-
casePM_SHUTDOWN_2:
4000-
casePM_SHUTDOWN:
4001+
casePM_WAIT_XLOG_ARCHIVAL:
4002+
casePM_WAIT_XLOG_SHUTDOWN:
40014003
casePM_WAIT_BACKENDS:
40024004
casePM_STOP_BACKENDS:
40034005
break;

‎src/backend/replication/README

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ shutdown checkpoint and terminating pgarch and other auxiliary processes, but
4545
that's not desirable for walsenders, because we want the standby servers to
4646
receive all the WAL, including the shutdown checkpoint, before the primary
4747
is shut down. Therefore postmaster treats walsenders like the pgarch process,
48-
and instructs them to terminate atPM_SHUTDOWN_2phase, after all regular
49-
backends have died and checkpointer has issued the shutdown checkpoint.
48+
and instructs them to terminate atthe PM_WAIT_XLOG_ARCHIVALphase, after all
49+
regularbackends have died and checkpointer has issued the shutdown checkpoint.
5050

5151
When postmaster accepts a connection, it immediately forks a new process
5252
to handle the handshake and authentication, and the process initializes to

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp