33
33
#include "miscadmin.h"
34
34
#include "nodes/makefuncs.h"
35
35
#include "pg_getopt.h"
36
- #include "pgstat.h"
37
- #include "postmaster/bgwriter.h"
38
- #include "postmaster/startup.h"
39
- #include "postmaster/walwriter.h"
40
- #include "replication/walreceiver.h"
41
36
#include "storage/bufmgr.h"
42
37
#include "storage/bufpage.h"
43
38
#include "storage/condition_variable.h"
47
42
#include "utils/builtins.h"
48
43
#include "utils/fmgroids.h"
49
44
#include "utils/memutils.h"
50
- #include "utils/ps_status.h"
51
45
#include "utils/rel.h"
52
46
#include "utils/relmapper.h"
53
47
@@ -56,7 +50,6 @@ uint32 bootstrap_data_checksum_version = 0; /* No checksum */
56
50
57
51
static void CheckerModeMain (void );
58
52
static void bootstrap_signals (void );
59
- static void ShutdownAuxiliaryProcess (int code , Datum arg );
60
53
static Form_pg_attribute AllocateAttribute (void );
61
54
static void populate_typ_list (void );
62
55
static Oid gettype (char * type );
@@ -67,8 +60,6 @@ static void cleanup(void);
67
60
* ----------------
68
61
*/
69
62
70
- AuxProcType MyAuxProcType = NotAnAuxProcess ; /* declared in miscadmin.h */
71
-
72
63
Relation boot_reldesc ; /* current relation descriptor */
73
64
74
65
Form_pg_attribute attrtypes [MAXATTR ]; /* points to attribute info */
@@ -184,139 +175,6 @@ typedef struct _IndexList
184
175
static IndexList * ILHead = NULL ;
185
176
186
177
187
- /*
188
- * AuxiliaryProcessMain
189
- *
190
- * The main entry point for auxiliary processes, such as the bgwriter,
191
- * walwriter, walreceiver, bootstrapper and the shared memory checker code.
192
- *
193
- * This code is here just because of historical reasons.
194
- */
195
- void
196
- AuxiliaryProcessMain (AuxProcType auxtype )
197
- {
198
- Assert (IsUnderPostmaster );
199
-
200
- MyAuxProcType = auxtype ;
201
-
202
- switch (MyAuxProcType )
203
- {
204
- case StartupProcess :
205
- MyBackendType = B_STARTUP ;
206
- break ;
207
- case ArchiverProcess :
208
- MyBackendType = B_ARCHIVER ;
209
- break ;
210
- case BgWriterProcess :
211
- MyBackendType = B_BG_WRITER ;
212
- break ;
213
- case CheckpointerProcess :
214
- MyBackendType = B_CHECKPOINTER ;
215
- break ;
216
- case WalWriterProcess :
217
- MyBackendType = B_WAL_WRITER ;
218
- break ;
219
- case WalReceiverProcess :
220
- MyBackendType = B_WAL_RECEIVER ;
221
- break ;
222
- default :
223
- elog (ERROR , "something has gone wrong" );
224
- MyBackendType = B_INVALID ;
225
- }
226
-
227
- init_ps_display (NULL );
228
-
229
- SetProcessingMode (BootstrapProcessing );
230
- IgnoreSystemIndexes = true;
231
-
232
- BaseInit ();
233
-
234
- /*
235
- * As an auxiliary process, we aren't going to do the full InitPostgres
236
- * pushups, but there are a couple of things that need to get lit up even
237
- * in an auxiliary process.
238
- */
239
-
240
- /*
241
- * Create a PGPROC so we can use LWLocks. In the EXEC_BACKEND case, this
242
- * was already done by SubPostmasterMain().
243
- */
244
- #ifndef EXEC_BACKEND
245
- InitAuxiliaryProcess ();
246
- #endif
247
-
248
- /*
249
- * Assign the ProcSignalSlot for an auxiliary process. Since it doesn't
250
- * have a BackendId, the slot is statically allocated based on the
251
- * auxiliary process type (MyAuxProcType). Backends use slots indexed in
252
- * the range from 1 to MaxBackends (inclusive), so we use MaxBackends +
253
- * AuxProcType + 1 as the index of the slot for an auxiliary process.
254
- *
255
- * This will need rethinking if we ever want more than one of a particular
256
- * auxiliary process type.
257
- */
258
- ProcSignalInit (MaxBackends + MyAuxProcType + 1 );
259
-
260
- /* finish setting up bufmgr.c */
261
- InitBufferPoolBackend ();
262
-
263
- /*
264
- * Auxiliary processes don't run transactions, but they may need a
265
- * resource owner anyway to manage buffer pins acquired outside
266
- * transactions (and, perhaps, other things in future).
267
- */
268
- CreateAuxProcessResourceOwner ();
269
-
270
- /* Initialize statistics reporting */
271
- pgstat_initialize ();
272
-
273
- /* Initialize backend status information */
274
- pgstat_beinit ();
275
- pgstat_bestart ();
276
-
277
- /* register a before-shutdown callback for LWLock cleanup */
278
- before_shmem_exit (ShutdownAuxiliaryProcess , 0 );
279
-
280
- SetProcessingMode (NormalProcessing );
281
-
282
- switch (MyAuxProcType )
283
- {
284
- case CheckerProcess :
285
- case BootstrapProcess :
286
- pg_unreachable ();
287
- break ;
288
-
289
- case StartupProcess :
290
- StartupProcessMain ();
291
- proc_exit (1 );
292
-
293
- case ArchiverProcess :
294
- PgArchiverMain ();
295
- proc_exit (1 );
296
-
297
- case BgWriterProcess :
298
- BackgroundWriterMain ();
299
- proc_exit (1 );
300
-
301
- case CheckpointerProcess :
302
- CheckpointerMain ();
303
- proc_exit (1 );
304
-
305
- case WalWriterProcess :
306
- InitXLOGAccess ();
307
- WalWriterMain ();
308
- proc_exit (1 );
309
-
310
- case WalReceiverProcess :
311
- WalReceiverMain ();
312
- proc_exit (1 );
313
-
314
- default :
315
- elog (PANIC , "unrecognized process type: %d" , (int ) MyAuxProcType );
316
- proc_exit (1 );
317
- }
318
- }
319
-
320
178
/*
321
179
* In shared memory checker mode, all we really want to do is create shared
322
180
* memory and semaphores (just to prove we can do it with the current GUC
@@ -554,21 +412,6 @@ bootstrap_signals(void)
554
412
pqsignal (SIGQUIT , SIG_DFL );
555
413
}
556
414
557
- /*
558
- * Begin shutdown of an auxiliary process. This is approximately the equivalent
559
- * of ShutdownPostgres() in postinit.c. We can't run transactions in an
560
- * auxiliary process, so most of the work of AbortTransaction() is not needed,
561
- * but we do need to make sure we've released any LWLocks we are holding.
562
- * (This is only critical during an error exit.)
563
- */
564
- static void
565
- ShutdownAuxiliaryProcess (int code , Datum arg )
566
- {
567
- LWLockReleaseAll ();
568
- ConditionVariableCancelSleep ();
569
- pgstat_report_wait_end ();
570
- }
571
-
572
415
/* ----------------------------------------------------------------
573
416
* MANUAL BACKEND INTERACTIVE INTERFACE COMMANDS
574
417
* ----------------------------------------------------------------
0 commit comments