PostgreSQL Source Code git master
Loading...
Searching...
No Matches
bgworker_internals.h File Reference
#include "datatype/timestamp.h"
#include "lib/ilist.h"
#include "postmaster/bgworker.h"
Include dependency graph for bgworker_internals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  RegisteredBgWorker
 

Macros

#define MAX_PARALLEL_WORKER_LIMIT   1024
 

Typedefs

typedef struct RegisteredBgWorker RegisteredBgWorker
 

Functions

Size BackgroundWorkerShmemSize (void)
 
void BackgroundWorkerShmemInit (void)
 
void BackgroundWorkerStateChange (bool allow_new_workers)
 
void ForgetBackgroundWorker (RegisteredBgWorker *rw)
 
void ReportBackgroundWorkerPID (RegisteredBgWorker *rw)
 
void ReportBackgroundWorkerExit (RegisteredBgWorker *rw)
 
void BackgroundWorkerStopNotifications (pid_t pid)
 
void ForgetUnstartedBackgroundWorkers (void)
 
void ResetBackgroundWorkerCrashTimes (void)
 
pg_noreturn void BackgroundWorkerMain (const void *startup_data, size_t startup_data_len)
 

Variables

PGDLLIMPORT dlist_head BackgroundWorkerList
 

Macro Definition Documentation

◆ MAX_PARALLEL_WORKER_LIMIT

#define MAX_PARALLEL_WORKER_LIMIT   1024

Definition at line 24 of file bgworker_internals.h.

Typedef Documentation

◆ RegisteredBgWorker

Function Documentation

◆ BackgroundWorkerMain()

pg_noreturn void BackgroundWorkerMain ( const void startup_data,
size_t  startup_data_len 
)
extern

Definition at line 739 of file bgworker.c.

740{
742 BackgroundWorker *worker;
744
745 if (startup_data == NULL)
746 elog(FATAL, "unable to find bgworker entry");
749 memcpy(worker, startup_data, sizeof(BackgroundWorker));
750
751 /*
752 * Now that we're done reading the startup data, release postmaster's
753 * working memory context.
754 */
756 {
759 }
760
761 MyBgworkerEntry = worker;
762 init_ps_display(worker->bgw_name);
763
765
766 /* Apply PostAuthDelay */
767 if (PostAuthDelay > 0)
768 pg_usleep(PostAuthDelay * 1000000L);
769
770 /*
771 * Set up signal handlers.
772 */
774 {
775 /*
776 * SIGINT is used to signal canceling the current action
777 */
781
782 /* XXX Any other handlers needed here? */
783 }
784 else
785 {
789 }
791 /* SIGQUIT handler was already set up by InitPostmasterChild */
793
794 InitializeTimeouts(); /* establishes SIGALRM handler */
795
799
800 /*
801 * If an exception is encountered, processing resumes here.
802 *
803 * We just need to clean up, report the error, and go away.
804 */
805 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
806 {
807 /* Since not using PG_TRY, must reset error stack by hand */
809
810 /* Prevent interrupts while cleaning up */
812
813 /*
814 * sigsetjmp will have blocked all signals, but we may need to accept
815 * signals while communicating with our parallel leader. Once we've
816 * done HOLD_INTERRUPTS() it should be safe to unblock signals.
817 */
819
820 /* Report the error to the parallel leader and the server log */
822
823 /*
824 * Do we need more cleanup here? For shmem-connected bgworkers, we
825 * will call InitProcess below, which will install ProcKill as exit
826 * callback. That will take care of releasing locks, etc.
827 */
828
829 /* and go away */
830 proc_exit(1);
831 }
832
833 /* We can now handle ereport(ERROR) */
835
836 /*
837 * Create a per-backend PGPROC struct in shared memory. We must do this
838 * before we can use LWLocks or access any shared memory.
839 */
840 InitProcess();
841
842 /*
843 * Early initialization.
844 */
845 BaseInit();
846
847 /*
848 * Look up the entry point function, loading its library if necessary.
849 */
851 worker->bgw_function_name);
852
853 /*
854 * Note that in normal processes, we would call InitPostgres here. For a
855 * worker, however, we don't know what database to connect to, yet; so we
856 * need to wait until the user code does it via
857 * BackgroundWorkerInitializeConnection().
858 */
859
860 /*
861 * Now invoke the user-defined worker code
862 */
863 entrypt(worker->bgw_main_arg);
864
865 /* ... and if it returns, we're done */
866 proc_exit(0);
867}
void BackgroundWorkerUnblockSignals(void)
Definition bgworker.c:947
static bgworker_main_type LookupBackgroundWorkerFunction(const char *libraryname, const char *funcname)
Definition bgworker.c:1358
static void bgworker_die(SIGNAL_ARGS)
Definition bgworker.c:725
#define BGWORKER_BACKEND_DATABASE_CONNECTION
Definition bgworker.h:60
void(* bgworker_main_type)(Datum main_arg)
Definition bgworker.h:79
#define Assert(condition)
Definition c.h:873
void EmitErrorReport(void)
Definition elog.c:1704
ErrorContextCallback * error_context_stack
Definition elog.c:95
sigjmp_buf * PG_exception_stack
Definition elog.c:97
#define FATAL
Definition elog.h:41
#define elog(elevel,...)
Definition elog.h:226
void proc_exit(int code)
Definition ipc.c:105
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition mcxt.c:1232
MemoryContext TopMemoryContext
Definition mcxt.c:166
MemoryContext PostmasterContext
Definition mcxt.c:168
void MemoryContextDelete(MemoryContext context)
Definition mcxt.c:472
@ InitProcessing
Definition miscadmin.h:471
#define GetProcessingMode()
Definition miscadmin.h:481
#define HOLD_INTERRUPTS()
Definition miscadmin.h:134
#define pqsignal
Definition port.h:547
int PostAuthDelay
Definition postgres.c:100
void FloatExceptionHandler(SIGNAL_ARGS)
Definition postgres.c:3058
void StatementCancelHandler(SIGNAL_ARGS)
Definition postgres.c:3041
void BaseInit(void)
Definition postinit.c:607
BackgroundWorker * MyBgworkerEntry
Definition postmaster.c:200
static int fb(int x)
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition procsignal.c:677
void init_ps_display(const char *fixed_part)
Definition ps_status.c:285
void pg_usleep(long microsec)
Definition signal.c:53
void InitProcess(void)
Definition proc.c:395
char bgw_function_name[BGW_MAXLEN]
Definition bgworker.h:104
char bgw_name[BGW_MAXLEN]
Definition bgworker.h:98
char bgw_library_name[MAXPGPATH]
Definition bgworker.h:103
void InitializeTimeouts(void)
Definition timeout.c:470
#define SIGCHLD
Definition win32_port.h:168
#define SIGHUP
Definition win32_port.h:158
#define SIGPIPE
Definition win32_port.h:163
#define SIGUSR1
Definition win32_port.h:170
#define SIGUSR2
Definition win32_port.h:171

References Assert, BackgroundWorkerUnblockSignals(), BaseInit(), BackgroundWorker::bgw_flags, BackgroundWorker::bgw_function_name, BackgroundWorker::bgw_library_name, BackgroundWorker::bgw_main_arg, BackgroundWorker::bgw_name, BGWORKER_BACKEND_DATABASE_CONNECTION, bgworker_die(), elog, EmitErrorReport(), error_context_stack, FATAL, fb(), FloatExceptionHandler(), GetProcessingMode, HOLD_INTERRUPTS, init_ps_display(), InitializeTimeouts(), InitProcess(), InitProcessing, LookupBackgroundWorkerFunction(), MemoryContextAlloc(), MemoryContextDelete(), MyBgworkerEntry, PG_exception_stack, pg_usleep(), PostAuthDelay, PostmasterContext, pqsignal, proc_exit(), procsignal_sigusr1_handler(), SIGCHLD, SIGHUP, SIGPIPE, SIGUSR1, SIGUSR2, StatementCancelHandler(), and TopMemoryContext.

◆ BackgroundWorkerShmemInit()

void BackgroundWorkerShmemInit ( void  )
extern

Definition at line 172 of file bgworker.c.

173{
174 bool found;
175
176 BackgroundWorkerData = ShmemInitStruct("Background Worker Data",
178 &found);
180 {
181 dlist_iter iter;
182 int slotno = 0;
183
187
188 /*
189 * Copy contents of worker list into shared memory. Record the shared
190 * memory slot assigned to each worker. This ensures a 1-to-1
191 * correspondence between the postmaster's private list and the array
192 * in shared memory.
193 */
195 {
198
199 rw = dlist_container(RegisteredBgWorker, rw_lnode, iter.cur);
201 slot->in_use = true;
202 slot->terminate = false;
203 slot->pid = InvalidPid;
204 slot->generation = 0;
205 rw->rw_shmem_slot = slotno;
206 rw->rw_worker.bgw_notify_pid = 0; /* might be reinit after crash */
207 memcpy(&slot->worker, &rw->rw_worker, sizeof(BackgroundWorker));
208 ++slotno;
209 }
210
211 /*
212 * Mark any remaining slots as not in use.
213 */
215 {
217
218 slot->in_use = false;
219 ++slotno;
220 }
221 }
222 else
223 Assert(found);
224}
dlist_head BackgroundWorkerList
Definition bgworker.c:41
static BackgroundWorkerArray * BackgroundWorkerData
Definition bgworker.c:109
Size BackgroundWorkerShmemSize(void)
Definition bgworker.c:156
bool IsUnderPostmaster
Definition globals.c:120
int max_worker_processes
Definition globals.c:144
#define dlist_foreach(iter, lhead)
Definition ilist.h:623
#define dlist_container(type, membername, ptr)
Definition ilist.h:593
#define InvalidPid
Definition miscadmin.h:32
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition shmem.c:378
uint32 parallel_terminate_count
Definition bgworker.c:99
uint32 parallel_register_count
Definition bgworker.c:98
BackgroundWorkerSlot slot[FLEXIBLE_ARRAY_MEMBER]
Definition bgworker.c:100
BackgroundWorker worker
Definition bgworker.c:81
pid_t bgw_notify_pid
Definition bgworker.h:107
BackgroundWorker rw_worker
dlist_node * cur
Definition ilist.h:179

References Assert, BackgroundWorkerData, BackgroundWorkerList, BackgroundWorkerShmemSize(), BackgroundWorker::bgw_notify_pid, dlist_iter::cur, dlist_container, dlist_foreach, fb(), BackgroundWorkerSlot::generation, BackgroundWorkerSlot::in_use, InvalidPid, IsUnderPostmaster, max_worker_processes, BackgroundWorkerArray::parallel_register_count, BackgroundWorkerArray::parallel_terminate_count, BackgroundWorkerSlot::pid, RegisteredBgWorker::rw_shmem_slot, RegisteredBgWorker::rw_worker, ShmemInitStruct(), BackgroundWorkerArray::slot, BackgroundWorkerSlot::terminate, BackgroundWorkerArray::total_slots, and BackgroundWorkerSlot::worker.

Referenced by CreateOrAttachShmemStructs().

◆ BackgroundWorkerShmemSize()

Size BackgroundWorkerShmemSize ( void  )
extern

Definition at line 156 of file bgworker.c.

157{
158 Size size;
159
160 /* Array of workers is variably sized. */
161 size = offsetof(BackgroundWorkerArray, slot);
163 sizeof(BackgroundWorkerSlot)));
164
165 return size;
166}
size_t Size
Definition c.h:619
Size add_size(Size s1, Size s2)
Definition shmem.c:482
Size mul_size(Size s1, Size s2)
Definition shmem.c:497

References add_size(), fb(), max_worker_processes, and mul_size().

Referenced by BackgroundWorkerShmemInit(), and CalculateShmemSize().

◆ BackgroundWorkerStateChange()

void BackgroundWorkerStateChange ( bool  allow_new_workers)
extern

Definition at line 256 of file bgworker.c.

257{
258 int slotno;
259
260 /*
261 * The total number of slots stored in shared memory should match our
262 * notion of max_worker_processes. If it does not, something is very
263 * wrong. Further down, we always refer to this value as
264 * max_worker_processes, in case shared memory gets corrupted while we're
265 * looping.
266 */
268 {
269 ereport(LOG,
270 (errmsg("inconsistent background worker state (\"max_worker_processes\"=%d, total slots=%d)",
273 return;
274 }
275
276 /*
277 * Iterate through slots, looking for newly-registered workers or workers
278 * who must die.
279 */
281 {
284
285 if (!slot->in_use)
286 continue;
287
288 /*
289 * Make sure we don't see the in_use flag before the updated slot
290 * contents.
291 */
293
294 /* See whether we already know about this worker. */
296 if (rw != NULL)
297 {
298 /*
299 * In general, the worker data can't change after it's initially
300 * registered. However, someone can set the terminate flag.
301 */
302 if (slot->terminate && !rw->rw_terminate)
303 {
304 rw->rw_terminate = true;
305 if (rw->rw_pid != 0)
306 kill(rw->rw_pid, SIGTERM);
307 else
308 {
309 /* Report never-started, now-terminated worker as dead. */
311 }
312 }
313 continue;
314 }
315
316 /*
317 * If we aren't allowing new workers, then immediately mark it for
318 * termination; the next stanza will take care of cleaning it up.
319 * Doing this ensures that any process waiting for the worker will get
320 * awoken, even though the worker will never be allowed to run.
321 */
323 slot->terminate = true;
324
325 /*
326 * If the worker is marked for termination, we don't need to add it to
327 * the registered workers list; we can just free the slot. However, if
328 * bgw_notify_pid is set, the process that registered the worker may
329 * need to know that we've processed the terminate request, so be sure
330 * to signal it.
331 */
332 if (slot->terminate)
333 {
334 int notify_pid;
335
336 /*
337 * We need a memory barrier here to make sure that the load of
338 * bgw_notify_pid and the update of parallel_terminate_count
339 * complete before the store to in_use.
340 */
342 if ((slot->worker.bgw_flags & BGWORKER_CLASS_PARALLEL) != 0)
344 slot->pid = 0;
345
347 slot->in_use = false;
348
349 if (notify_pid != 0)
351
352 continue;
353 }
354
355 /*
356 * Copy the registration data into the registered workers list.
357 */
359 sizeof(RegisteredBgWorker),
361 if (rw == NULL)
362 {
363 ereport(LOG,
365 errmsg("out of memory")));
366 return;
367 }
368
369 /*
370 * Copy strings in a paranoid way. If shared memory is corrupted, the
371 * source data might not even be NUL-terminated.
372 */
374 slot->worker.bgw_name, BGW_MAXLEN);
376 slot->worker.bgw_type, BGW_MAXLEN);
381
382 /*
383 * Copy various fixed-size fields.
384 *
385 * flags, start_time, and restart_time are examined by the postmaster,
386 * but nothing too bad will happen if they are corrupted. The
387 * remaining fields will only be examined by the child process. It
388 * might crash, but we won't.
389 */
395
396 /*
397 * Copy the PID to be notified about state changes, but only if the
398 * postmaster knows about a backend with that PID. It isn't an error
399 * if the postmaster doesn't know about the PID, because the backend
400 * that requested the worker could have died (or been killed) just
401 * after doing so. Nonetheless, at least until we get some experience
402 * with how this plays out in the wild, log a message at a relative
403 * high debug level.
404 */
407 {
408 elog(DEBUG1, "worker notification PID %d is not valid",
409 (int) rw->rw_worker.bgw_notify_pid);
411 }
412
413 /* Initialize postmaster bookkeeping. */
414 rw->rw_pid = 0;
415 rw->rw_crashed_at = 0;
416 rw->rw_shmem_slot = slotno;
417 rw->rw_terminate = false;
418
419 /* Log it! */
421 (errmsg_internal("registering background worker \"%s\"",
422 rw->rw_worker.bgw_name)));
423
425 }
426}
void ascii_safe_strlcpy(char *dest, const char *src, size_t destsiz)
Definition ascii.c:174
#define pg_memory_barrier()
Definition atomics.h:141
#define pg_read_barrier()
Definition atomics.h:154
void ReportBackgroundWorkerPID(RegisteredBgWorker *rw)
Definition bgworker.c:471
static RegisteredBgWorker * FindRegisteredWorkerBySlotNumber(int slotno)
Definition bgworker.c:231
#define BGW_EXTRALEN
Definition bgworker.h:94
#define BGWORKER_CLASS_PARALLEL
Definition bgworker.h:75
#define BGW_MAXLEN
Definition bgworker.h:93
int errmsg_internal(const char *fmt,...)
Definition elog.c:1170
int errcode(int sqlerrcode)
Definition elog.c:863
int errmsg(const char *fmt,...)
Definition elog.c:1080
#define LOG
Definition elog.h:31
#define DEBUG1
Definition elog.h:30
#define ereport(elevel,...)
Definition elog.h:150
#define MCXT_ALLOC_ZERO
Definition fe_memutils.h:30
#define MCXT_ALLOC_NO_OOM
Definition fe_memutils.h:29
static void dlist_push_head(dlist_head *head, dlist_node *node)
Definition ilist.h:347
void * MemoryContextAllocExtended(MemoryContext context, Size size, int flags)
Definition mcxt.c:1289
#define MAXPGPATH
bool PostmasterMarkPIDForWorkerNotify(int pid)
char bgw_type[BGW_MAXLEN]
Definition bgworker.h:99
BgWorkerStartTime bgw_start_time
Definition bgworker.h:101
char bgw_extra[BGW_EXTRALEN]
Definition bgworker.h:106
#define kill(pid, sig)
Definition win32_port.h:490

References ascii_safe_strlcpy(), BackgroundWorkerData, BackgroundWorkerList, BackgroundWorker::bgw_extra, BGW_EXTRALEN, BackgroundWorker::bgw_flags, BackgroundWorker::bgw_function_name, BackgroundWorker::bgw_library_name, BackgroundWorker::bgw_main_arg, BGW_MAXLEN, BackgroundWorker::bgw_name, BackgroundWorker::bgw_notify_pid, BackgroundWorker::bgw_restart_time, BackgroundWorker::bgw_start_time, BackgroundWorker::bgw_type, BGWORKER_CLASS_PARALLEL, DEBUG1, dlist_push_head(), elog, ereport, errcode(), errmsg(), errmsg_internal(), fb(), FindRegisteredWorkerBySlotNumber(), BackgroundWorkerSlot::in_use, kill, LOG, max_worker_processes, MAXPGPATH, MCXT_ALLOC_NO_OOM, MCXT_ALLOC_ZERO, MemoryContextAllocExtended(), BackgroundWorkerArray::parallel_terminate_count, pg_memory_barrier, pg_read_barrier, BackgroundWorkerSlot::pid, PostmasterContext, PostmasterMarkPIDForWorkerNotify(), ReportBackgroundWorkerPID(), RegisteredBgWorker::rw_crashed_at, RegisteredBgWorker::rw_lnode, RegisteredBgWorker::rw_pid, RegisteredBgWorker::rw_shmem_slot, RegisteredBgWorker::rw_terminate, RegisteredBgWorker::rw_worker, SIGUSR1, BackgroundWorkerArray::slot, BackgroundWorkerSlot::terminate, BackgroundWorkerArray::total_slots, and BackgroundWorkerSlot::worker.

Referenced by process_pm_pmsignal().

◆ BackgroundWorkerStopNotifications()

void BackgroundWorkerStopNotifications ( pid_t  pid)
extern

Definition at line 524 of file bgworker.c.

525{
526 dlist_iter iter;
527
529 {
531
532 rw = dlist_container(RegisteredBgWorker, rw_lnode, iter.cur);
533 if (rw->rw_worker.bgw_notify_pid == pid)
535 }
536}

References BackgroundWorkerList, BackgroundWorker::bgw_notify_pid, dlist_iter::cur, dlist_container, dlist_foreach, and RegisteredBgWorker::rw_worker.

Referenced by CleanupBackend().

◆ ForgetBackgroundWorker()

void ForgetBackgroundWorker ( RegisteredBgWorker rw)
extern

Definition at line 439 of file bgworker.c.

440{
442
445 Assert(slot->in_use);
446
447 /*
448 * We need a memory barrier here to make sure that the update of
449 * parallel_terminate_count completes before the store to in_use.
450 */
453
455 slot->in_use = false;
456
458 (errmsg_internal("unregistering background worker \"%s\"",
459 rw->rw_worker.bgw_name)));
460
462 pfree(rw);
463}
static void dlist_delete(dlist_node *node)
Definition ilist.h:405
void pfree(void *pointer)
Definition mcxt.c:1616

References Assert, BackgroundWorkerData, BackgroundWorker::bgw_flags, BackgroundWorker::bgw_name, BGWORKER_CLASS_PARALLEL, DEBUG1, dlist_delete(), ereport, errmsg_internal(), BackgroundWorkerSlot::in_use, max_worker_processes, BackgroundWorkerArray::parallel_terminate_count, pfree(), pg_memory_barrier, RegisteredBgWorker::rw_lnode, RegisteredBgWorker::rw_shmem_slot, RegisteredBgWorker::rw_worker, and BackgroundWorkerArray::slot.

Referenced by DetermineSleepTime(), ForgetUnstartedBackgroundWorkers(), maybe_start_bgworkers(), ReportBackgroundWorkerExit(), and ResetBackgroundWorkerCrashTimes().

◆ ForgetUnstartedBackgroundWorkers()

void ForgetUnstartedBackgroundWorkers ( void  )
extern

Definition at line 551 of file bgworker.c.

552{
554
556 {
559
560 rw = dlist_container(RegisteredBgWorker, rw_lnode, iter.cur);
563
564 /* If it's not yet started, and there's someone waiting ... */
565 if (slot->pid == InvalidPid &&
566 rw->rw_worker.bgw_notify_pid != 0)
567 {
568 /* ... then zap it, and notify the waiter */
570
572 if (notify_pid != 0)
574 }
575 }
576}
void ForgetBackgroundWorker(RegisteredBgWorker *rw)
Definition bgworker.c:439
#define dlist_foreach_modify(iter, lhead)
Definition ilist.h:640
dlist_node * cur
Definition ilist.h:200

References Assert, BackgroundWorkerData, BackgroundWorkerList, BackgroundWorker::bgw_notify_pid, dlist_mutable_iter::cur, dlist_container, dlist_foreach_modify, fb(), ForgetBackgroundWorker(), InvalidPid, kill, max_worker_processes, BackgroundWorkerSlot::pid, RegisteredBgWorker::rw_shmem_slot, RegisteredBgWorker::rw_worker, SIGUSR1, and BackgroundWorkerArray::slot.

Referenced by PostmasterStateMachine().

◆ ReportBackgroundWorkerExit()

void ReportBackgroundWorkerExit ( RegisteredBgWorker rw)
extern

Definition at line 493 of file bgworker.c.

494{
496 int notify_pid;
497
500 slot->pid = rw->rw_pid;
502
503 /*
504 * If this worker is slated for deregistration, do that before notifying
505 * the process which started it. Otherwise, if that process tries to
506 * reuse the slot immediately, it might not be available yet. In theory
507 * that could happen anyway if the process checks slot->pid at just the
508 * wrong moment, but this makes the window narrower.
509 */
510 if (rw->rw_terminate ||
513
514 if (notify_pid != 0)
516}
#define BGW_NEVER_RESTART
Definition bgworker.h:92

References Assert, BackgroundWorkerData, BGW_NEVER_RESTART, BackgroundWorker::bgw_notify_pid, BackgroundWorker::bgw_restart_time, fb(), ForgetBackgroundWorker(), kill, max_worker_processes, BackgroundWorkerSlot::pid, RegisteredBgWorker::rw_pid, RegisteredBgWorker::rw_shmem_slot, RegisteredBgWorker::rw_terminate, RegisteredBgWorker::rw_worker, SIGUSR1, and BackgroundWorkerArray::slot.

Referenced by CleanupBackend().

◆ ReportBackgroundWorkerPID()

◆ ResetBackgroundWorkerCrashTimes()

void ResetBackgroundWorkerCrashTimes ( void  )
extern

Definition at line 589 of file bgworker.c.

590{
592
594 {
596
597 rw = dlist_container(RegisteredBgWorker, rw_lnode, iter.cur);
598
600 {
601 /*
602 * Workers marked BGW_NEVER_RESTART shouldn't get relaunched after
603 * the crash, so forget about them. (If we wait until after the
604 * crash to forget about them, and they are parallel workers,
605 * parallel_terminate_count will get incremented after we've
606 * already zeroed parallel_register_count, which would be bad.)
607 */
609 }
610 else
611 {
612 /*
613 * The accounting which we do via parallel_register_count and
614 * parallel_terminate_count would get messed up if a worker marked
615 * parallel could survive a crash and restart cycle. All such
616 * workers should be marked BGW_NEVER_RESTART, and thus control
617 * should never reach this branch.
618 */
620
621 /*
622 * Allow this worker to be restarted immediately after we finish
623 * resetting.
624 */
625 rw->rw_crashed_at = 0;
626 rw->rw_pid = 0;
627
628 /*
629 * If there was anyone waiting for it, they're history.
630 */
632 }
633 }
634}

References Assert, BackgroundWorkerList, BackgroundWorker::bgw_flags, BGW_NEVER_RESTART, BackgroundWorker::bgw_notify_pid, BackgroundWorker::bgw_restart_time, BGWORKER_CLASS_PARALLEL, dlist_mutable_iter::cur, dlist_container, dlist_foreach_modify, ForgetBackgroundWorker(), RegisteredBgWorker::rw_crashed_at, RegisteredBgWorker::rw_pid, and RegisteredBgWorker::rw_worker.

Referenced by PostmasterStateMachine().

Variable Documentation

◆ BackgroundWorkerList