PostgreSQL Source Code  git master
auxprocess.h File Reference
#include "miscadmin.h"
Include dependency graph for auxprocess.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void AuxiliaryProcessMain (AuxProcType auxtype) pg_attribute_noreturn()
 

Function Documentation

◆ AuxiliaryProcessMain()

void AuxiliaryProcessMain ( AuxProcType  auxtype)

Definition at line 58 of file auxprocess.c.

59 {
61 
62  MyAuxProcType = auxtype;
63 
64  switch (MyAuxProcType)
65  {
66  case StartupProcess:
68  break;
69  case ArchiverProcess:
71  break;
72  case BgWriterProcess:
74  break;
77  break;
78  case WalWriterProcess:
80  break;
81  case WalReceiverProcess:
83  break;
86  break;
87  default:
88  elog(PANIC, "unrecognized process type: %d", (int) MyAuxProcType);
90  }
91 
92  init_ps_display(NULL);
93 
95  IgnoreSystemIndexes = true;
96 
97  /*
98  * As an auxiliary process, we aren't going to do the full InitPostgres
99  * pushups, but there are a couple of things that need to get lit up even
100  * in an auxiliary process.
101  */
102 
103  /*
104  * Create a PGPROC so we can use LWLocks and access shared memory.
105  */
107 
108  BaseInit();
109 
110  /*
111  * Assign the ProcSignalSlot for an auxiliary process. Since it doesn't
112  * have a BackendId, the slot is statically allocated based on the
113  * auxiliary process type (MyAuxProcType). Backends use slots indexed in
114  * the range from 1 to MaxBackends (inclusive), so we use MaxBackends +
115  * AuxProcType + 1 as the index of the slot for an auxiliary process.
116  *
117  * This will need rethinking if we ever want more than one of a particular
118  * auxiliary process type.
119  */
121 
122  /*
123  * Auxiliary processes don't run transactions, but they may need a
124  * resource owner anyway to manage buffer pins acquired outside
125  * transactions (and, perhaps, other things in future).
126  */
128 
129 
130  /* Initialize backend status information */
131  pgstat_beinit();
132  pgstat_bestart();
133 
134  /* register a before-shutdown callback for LWLock cleanup */
136 
138 
139  switch (MyAuxProcType)
140  {
141  case StartupProcess:
143  proc_exit(1);
144 
145  case ArchiverProcess:
146  PgArchiverMain();
147  proc_exit(1);
148 
149  case BgWriterProcess:
151  proc_exit(1);
152 
153  case CheckpointerProcess:
155  proc_exit(1);
156 
157  case WalWriterProcess:
158  WalWriterMain();
159  proc_exit(1);
160 
161  case WalReceiverProcess:
162  WalReceiverMain();
163  proc_exit(1);
164 
167  proc_exit(1);
168 
169  default:
170  elog(PANIC, "unrecognized process type: %d", (int) MyAuxProcType);
171  proc_exit(1);
172  }
173 }
AuxProcType MyAuxProcType
Definition: auxprocess.c:46
static void ShutdownAuxiliaryProcess(int code, Datum arg)
Definition: auxprocess.c:183
void StartupProcessMain(void)
Definition: startup.c:217
void pgstat_beinit(void)
void pgstat_bestart(void)
void BackgroundWriterMain(void)
Definition: bgwriter.c:91
void CheckpointerMain(void)
Definition: checkpointer.c:172
#define PANIC
Definition: elog.h:42
bool IsUnderPostmaster
Definition: globals.c:116
int MaxBackends
Definition: globals.c:143
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:337
void proc_exit(int code)
Definition: ipc.c:104
Assert(fmt[strlen(fmt) - 1] !='\n')
@ NormalProcessing
Definition: miscadmin.h:410
@ BootstrapProcessing
Definition: miscadmin.h:408
#define SetProcessingMode(mode)
Definition: miscadmin.h:421
@ B_WAL_SUMMARIZER
Definition: miscadmin.h:340
@ B_WAL_WRITER
Definition: miscadmin.h:341
@ B_WAL_RECEIVER
Definition: miscadmin.h:338
@ B_CHECKPOINTER
Definition: miscadmin.h:334
@ B_STARTUP
Definition: miscadmin.h:337
@ B_INVALID
Definition: miscadmin.h:327
@ B_BG_WRITER
Definition: miscadmin.h:333
@ B_ARCHIVER
Definition: miscadmin.h:328
@ BgWriterProcess
Definition: miscadmin.h:442
@ StartupProcess
Definition: miscadmin.h:441
@ ArchiverProcess
Definition: miscadmin.h:443
@ WalWriterProcess
Definition: miscadmin.h:445
@ WalReceiverProcess
Definition: miscadmin.h:446
@ WalSummarizerProcess
Definition: miscadmin.h:447
@ CheckpointerProcess
Definition: miscadmin.h:444
bool IgnoreSystemIndexes
Definition: miscinit.c:80
BackendType MyBackendType
Definition: miscinit.c:63
void PgArchiverMain(void)
Definition: pgarch.c:212
void BaseInit(void)
Definition: postinit.c:630
void ProcSignalInit(int pss_idx)
Definition: procsignal.c:162
void init_ps_display(const char *fixed_part)
Definition: ps_status.c:242
void CreateAuxProcessResourceOwner(void)
Definition: resowner.c:982
void InitAuxiliaryProcess(void)
Definition: proc.c:520
void WalReceiverMain(void)
Definition: walreceiver.c:186
void WalSummarizerMain(void)
void WalWriterMain(void)
Definition: walwriter.c:88

References ArchiverProcess, Assert(), B_ARCHIVER, B_BG_WRITER, B_CHECKPOINTER, B_INVALID, B_STARTUP, B_WAL_RECEIVER, B_WAL_SUMMARIZER, B_WAL_WRITER, BackgroundWriterMain(), BaseInit(), before_shmem_exit(), BgWriterProcess, BootstrapProcessing, CheckpointerMain(), CheckpointerProcess, CreateAuxProcessResourceOwner(), elog(), IgnoreSystemIndexes, init_ps_display(), InitAuxiliaryProcess(), IsUnderPostmaster, MaxBackends, MyAuxProcType, MyBackendType, NormalProcessing, PANIC, PgArchiverMain(), pgstat_beinit(), pgstat_bestart(), proc_exit(), ProcSignalInit(), SetProcessingMode, ShutdownAuxiliaryProcess(), StartupProcess, StartupProcessMain(), WalReceiverMain(), WalReceiverProcess, WalSummarizerMain(), WalSummarizerProcess, WalWriterMain(), and WalWriterProcess.

Referenced by StartChildProcess().