PostgreSQL Source Code git master
Loading...
Searching...
No Matches
auxprocess.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 * auxprocess.c
3 * functions related to auxiliary processes.
4 *
5 *
6 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * IDENTIFICATION
10 * src/backend/postmaster/auxprocess.c
11 *-------------------------------------------------------------------------
12 */
13#include "postgres.h"
14
15#include <unistd.h>
16#include <signal.h>
17
18#include "miscadmin.h"
19#include "pgstat.h"
22#include "storage/ipc.h"
23#include "storage/proc.h"
24#include "storage/procsignal.h"
25#include "utils/memutils.h"
26#include "utils/ps_status.h"
27#include "utils/wait_event.h"
28
29
30static void ShutdownAuxiliaryProcess(int code, Datum arg);
31
32
33/*
34 * AuxiliaryProcessMainCommon
35 *
36 * Common initialization code for auxiliary processes, such as the bgwriter,
37 * walwriter, walreceiver, and the startup process.
38 */
39void
41{
43
44 /* Release postmaster's working memory context */
46 {
49 }
50
52
54
56
57 /*
58 * As an auxiliary process, we aren't going to do the full InitPostgres
59 * pushups, but there are a couple of things that need to get lit up even
60 * in an auxiliary process.
61 */
62
63 /*
64 * Create a PGPROC so we can use LWLocks and access shared memory.
65 */
67
68 BaseInit();
69
71
72 /*
73 * Auxiliary processes don't run transactions, but they may need a
74 * resource owner anyway to manage buffer pins acquired outside
75 * transactions (and, perhaps, other things in future).
76 */
78
79
80 /* Initialize backend status information */
84
85 /* register a before-shutdown callback for LWLock cleanup */
87
89}
90
91/*
92 * Begin shutdown of an auxiliary process. This is approximately the equivalent
93 * of ShutdownPostgres() in postinit.c. We can't run transactions in an
94 * auxiliary process, so most of the work of AbortTransaction() is not needed,
95 * but we do need to make sure we've released any LWLocks we are holding.
96 * (This is only critical during an error exit.)
97 */
98static void
void AuxiliaryProcessMainCommon(void)
Definition auxprocess.c:40
static void ShutdownAuxiliaryProcess(int code, Datum arg)
Definition auxprocess.c:99
void pgstat_bestart_initial(void)
void pgstat_beinit(void)
void pgstat_bestart_final(void)
#define Assert(condition)
Definition c.h:945
bool ConditionVariableCancelSleep(void)
Datum arg
Definition elog.c:1322
bool IsUnderPostmaster
Definition globals.c:120
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition ipc.c:344
void LWLockReleaseAll(void)
Definition lwlock.c:1893
MemoryContext PostmasterContext
Definition mcxt.c:168
void MemoryContextDelete(MemoryContext context)
Definition mcxt.c:472
@ NormalProcessing
Definition miscadmin.h:472
@ InitProcessing
Definition miscadmin.h:471
#define GetProcessingMode()
Definition miscadmin.h:481
#define SetProcessingMode(mode)
Definition miscadmin.h:483
bool IgnoreSystemIndexes
Definition miscinit.c:82
uint64_t Datum
Definition postgres.h:70
void BaseInit(void)
Definition postinit.c:616
static int fb(int x)
void ProcSignalInit(const uint8 *cancel_key, int cancel_key_len)
Definition procsignal.c:169
void init_ps_display(const char *fixed_part)
Definition ps_status.c:285
void CreateAuxProcessResourceOwner(void)
Definition resowner.c:996
void InitAuxiliaryProcess(void)
Definition proc.c:606
static void pgstat_report_wait_end(void)
Definition wait_event.h:85