|
156 | 156 | * authorization phase). This is used mainly to keep track of how many
|
157 | 157 | * children we have and send them appropriate signals when necessary.
|
158 | 158 | *
|
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 | + * |
161 | 167 | * Also, "dead_end" children are in it: these are children launched just for
|
162 | 168 | * the purpose of sending a friendly rejection message to a would-be client.
|
163 | 169 | * We must track them because they are attached to shared memory, but we know
|
164 | 170 | * they will never become live backends. dead_end children are not assigned a
|
165 |
| - * PMChildSlot. |
| 171 | + * PMChildSlot. dead_end children have bkend_type NORMAL. |
166 | 172 | *
|
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.) |
168 | 178 | */
|
169 | 179 | typedef struct bkend
|
170 | 180 | {
|
171 | 181 | pid_t pid; /* process id of backend */
|
172 | 182 | int32 cancel_key; /* cancel key for cancels for this backend */
|
173 | 183 | 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 */ |
181 | 185 | bool dead_end; /* is it going to send an error and quit? */
|
182 | 186 | bool bgworker_notify; /* gets bgworker start/stop notifications */
|
183 | 187 | dlist_node elem; /* list link in BackendList */
|
@@ -1059,10 +1063,9 @@ PostmasterMain(int argc, char *argv[])
|
1059 | 1063 | * only during a few moments during a standby promotion. However there is
|
1060 | 1064 | * a race condition: if pg_ctl promote is executed and creates the files
|
1061 | 1065 | * 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. |
1066 | 1069 | *
|
1067 | 1070 | * Note that promotion signal files need to be removed before the startup
|
1068 | 1071 | * process is invoked. Because, after that, they can be used by
|
@@ -5336,8 +5339,8 @@ sigusr1_handler(SIGNAL_ARGS)
|
5336 | 5339 | /*
|
5337 | 5340 | * Tell startup process to finish recovery.
|
5338 | 5341 | *
|
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. |
5341 | 5344 | */
|
5342 | 5345 | signal_child(StartupPID, SIGUSR2);
|
5343 | 5346 | }
|
|
0 commit comments