PostgreSQL Source Code git master
Loading...
Searching...
No Matches
procsignal.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * procsignal.h
4 * Routines for interprocess signaling
5 *
6 *
7 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/storage/procsignal.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#ifndef PROCSIGNAL_H
15#define PROCSIGNAL_H
16
17#include "storage/procnumber.h"
18
19
20/*
21 * Reasons for signaling a Postgres child process (a backend or an auxiliary
22 * process, like checkpointer). We can cope with concurrent signals for different
23 * reasons. However, if the same reason is signaled multiple times in quick
24 * succession, the process is likely to observe only one notification of it.
25 * This is okay for the present uses.
26 *
27 * Also, because of race conditions, it's important that all the signals be
28 * defined so that no harm is done if a process mistakenly receives one.
29 */
30typedef enum
31{
32 PROCSIG_CATCHUP_INTERRUPT, /* sinval catchup interrupt */
33 PROCSIG_NOTIFY_INTERRUPT, /* listen/notify interrupt */
34 PROCSIG_PARALLEL_MESSAGE, /* message from cooperating parallel backend */
35 PROCSIG_WALSND_INIT_STOPPING, /* ask walsenders to prepare for shutdown */
36 PROCSIG_BARRIER, /* global barrier interrupt */
37 PROCSIG_LOG_MEMORY_CONTEXT, /* ask backend to log the memory contexts */
38 PROCSIG_PARALLEL_APPLY_MESSAGE, /* Message from parallel apply workers */
39 PROCSIG_SLOTSYNC_MESSAGE, /* ask slot synchronization to stop */
40 PROCSIG_REPACK_MESSAGE, /* Message from repack worker */
41 PROCSIG_RECOVERY_CONFLICT, /* backend is blocking recovery, check
42 * PGPROC->pendingRecoveryConflicts for the
43 * reason */
45
46#define NUM_PROCSIGNALS (PROCSIG_RECOVERY_CONFLICT + 1)
47
58
59/*
60 * Length of query cancel keys generated.
61 *
62 * Note that the protocol allows for longer keys, or shorter, but this is the
63 * length we actually generate. Client code, and the server code that handles
64 * incoming cancellation packets from clients, mustn't use this hardcoded
65 * length.
66 */
67#define MAX_CANCEL_KEY_LENGTH 32
68
69/*
70 * prototypes for functions in procsignal.c
71 */
72extern void ProcSignalInit(const uint8 *cancel_key, int cancel_key_len);
73extern int SendProcSignal(pid_t pid, ProcSignalReason reason,
74 ProcNumber procNumber);
75extern void SendCancelRequest(int backendPID, const uint8 *cancel_key, int cancel_key_len);
76
78extern void WaitForProcSignalBarrier(uint64 generation);
79extern void ProcessProcSignalBarrier(void);
80
82
83/* ProcSignalHeader is an opaque struct, details known only within procsignal.c */
85
86#ifdef EXEC_BACKEND
88#endif
89
90#endif /* PROCSIGNAL_H */
#define PGDLLIMPORT
Definition c.h:1421
uint8_t uint8
Definition c.h:622
#define SIGNAL_ARGS
Definition c.h:1450
uint64_t uint64
Definition c.h:625
static int fb(int x)
int ProcNumber
Definition procnumber.h:24
NON_EXEC_STATIC ProcSignalHeader * ProcSignal
Definition procsignal.c:120
int SendProcSignal(pid_t pid, ProcSignalReason reason, ProcNumber procNumber)
Definition procsignal.c:288
ProcSignalReason
Definition procsignal.h:31
@ PROCSIG_RECOVERY_CONFLICT
Definition procsignal.h:41
@ PROCSIG_PARALLEL_MESSAGE
Definition procsignal.h:34
@ PROCSIG_CATCHUP_INTERRUPT
Definition procsignal.h:32
@ PROCSIG_SLOTSYNC_MESSAGE
Definition procsignal.h:39
@ PROCSIG_LOG_MEMORY_CONTEXT
Definition procsignal.h:37
@ PROCSIG_BARRIER
Definition procsignal.h:36
@ PROCSIG_REPACK_MESSAGE
Definition procsignal.h:40
@ PROCSIG_WALSND_INIT_STOPPING
Definition procsignal.h:35
@ PROCSIG_PARALLEL_APPLY_MESSAGE
Definition procsignal.h:38
@ PROCSIG_NOTIFY_INTERRUPT
Definition procsignal.h:33
void ProcSignalInit(const uint8 *cancel_key, int cancel_key_len)
Definition procsignal.c:170
void ProcessProcSignalBarrier(void)
Definition procsignal.c:503
ProcSignalBarrierType
Definition procsignal.h:49
@ PROCSIGNAL_BARRIER_CHECKSUM_INPROGRESS_OFF
Definition procsignal.h:55
@ PROCSIGNAL_BARRIER_SMGRRELEASE
Definition procsignal.h:50
@ PROCSIGNAL_BARRIER_CHECKSUM_INPROGRESS_ON
Definition procsignal.h:54
@ PROCSIGNAL_BARRIER_UPDATE_XLOG_LOGICAL_INFO
Definition procsignal.h:51
@ PROCSIGNAL_BARRIER_CHECKSUM_ON
Definition procsignal.h:56
@ PROCSIGNAL_BARRIER_CHECKSUM_OFF
Definition procsignal.h:53
void WaitForProcSignalBarrier(uint64 generation)
Definition procsignal.c:428
void SendCancelRequest(int backendPID, const uint8 *cancel_key, int cancel_key_len)
Definition procsignal.c:731
uint64 EmitProcSignalBarrier(ProcSignalBarrierType type)
Definition procsignal.c:360
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition procsignal.c:688
const char * type