Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3546cf8

Browse files
committed
Improve comments for postmaster.c's BackendList.
This had gotten a little disjointed over time, and some of the grammar was sloppy. Rewrite for more clarity. In passing, re-pgindent some recently added comments. No code changes.
1 parent 3bd7f99 commit 3546cf8

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

src/backend/postmaster/postmaster.c

+20-17
Original file line numberDiff line numberDiff line change
@@ -156,28 +156,32 @@
156156
* authorization phase). This is used mainly to keep track of how many
157157
* children we have and send them appropriate signals when necessary.
158158
*
159-
* "Special" children such as the startup, bgwriter and autovacuum launcher
160-
* tasks are not in this list. Autovacuum worker and walsender are in it.
159+
* As shown in the above set of backend types, this list includes not only
160+
* "normal" client sessions, but also autovacuum workers, walsenders, and
161+
* background workers. (Note that at the time of launch, walsenders are
162+
* labeled BACKEND_TYPE_NORMAL; we relabel them to BACKEND_TYPE_WALSND
163+
* upon noticing they've changed their PMChildFlags entry. Hence that check
164+
* must be done before any operation that needs to distinguish walsenders
165+
* from normal backends.)
166+
*
161167
* Also, "dead_end" children are in it: these are children launched just for
162168
* the purpose of sending a friendly rejection message to a would-be client.
163169
* We must track them because they are attached to shared memory, but we know
164170
* they will never become live backends. dead_end children are not assigned a
165-
* PMChildSlot.
171+
* PMChildSlot. dead_end children have bkend_type NORMAL.
166172
*
167-
* Background workers are in this list, too.
173+
* "Special" children such as the startup, bgwriter and autovacuum launcher
174+
* tasks are not in this list. They are tracked via StartupPID and other
175+
* pid_t variables below. (Thus, there can't be more than one of any given
176+
* "special" child process type. We use BackendList entries for any child
177+
* process there can be more than one of.)
168178
*/
169179
typedef struct bkend
170180
{
171181
pid_t pid; /* process id of backend */
172182
int32 cancel_key; /* cancel key for cancels for this backend */
173183
int child_slot; /* PMChildSlot for this backend, if any */
174-
175-
/*
176-
* Flavor of backend or auxiliary process. Note that BACKEND_TYPE_WALSND
177-
* backends initially announce themselves as BACKEND_TYPE_NORMAL, so if
178-
* bkend_type is normal, you should check for a recent transition.
179-
*/
180-
int bkend_type;
184+
int bkend_type; /* child process flavor, see above */
181185
bool dead_end; /* is it going to send an error and quit? */
182186
bool bgworker_notify; /* gets bgworker start/stop notifications */
183187
dlist_node elem; /* list link in BackendList */
@@ -1059,10 +1063,9 @@ PostmasterMain(int argc, char *argv[])
10591063
* only during a few moments during a standby promotion. However there is
10601064
* a race condition: if pg_ctl promote is executed and creates the files
10611065
* during a promotion, the files can stay around even after the server is
1062-
* brought up to be the primary. Then, if a new standby starts by using the
1063-
* backup taken from the new primary, the files can exist at the server
1064-
* startup and should be removed in order to avoid an unexpected
1065-
* promotion.
1066+
* brought up to be the primary. Then, if a new standby starts by using
1067+
* the backup taken from the new primary, the files can exist at server
1068+
* startup and must be removed in order to avoid an unexpected promotion.
10661069
*
10671070
* Note that promotion signal files need to be removed before the startup
10681071
* process is invoked. Because, after that, they can be used by
@@ -5336,8 +5339,8 @@ sigusr1_handler(SIGNAL_ARGS)
53365339
/*
53375340
* Tell startup process to finish recovery.
53385341
*
5339-
* Leave the promote signal file in place and let the Startup
5340-
* process do the unlink.
5342+
* Leave the promote signal file in place and let the Startup process
5343+
* do the unlink.
53415344
*/
53425345
signal_child(StartupPID, SIGUSR2);
53435346
}

0 commit comments

Comments
 (0)