PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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-2025, 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
40 /* Recovery conflict reasons */
51
52#define NUM_PROCSIGNALS (PROCSIG_RECOVERY_CONFLICT_LAST + 1)
53
54typedef enum
55{
56 PROCSIGNAL_BARRIER_SMGRRELEASE, /* ask smgr to close files */
58
59/*
60 * prototypes for functions in procsignal.c
61 */
62extern Size ProcSignalShmemSize(void);
63extern void ProcSignalShmemInit(void);
64
65extern void ProcSignalInit(bool cancel_key_valid, int32 cancel_key);
66extern int SendProcSignal(pid_t pid, ProcSignalReason reason,
67 ProcNumber procNumber);
68extern void SendCancelRequest(int backendPID, int32 cancelAuthCode);
69
71extern void WaitForProcSignalBarrier(uint64 generation);
72extern void ProcessProcSignalBarrier(void);
73
75
76/* ProcSignalHeader is an opaque struct, details known only within procsignal.c */
78
79#ifdef EXEC_BACKEND
81#endif
82
83#endif /* PROCSIGNAL_H */
#define PGDLLIMPORT
Definition: c.h:1274
#define SIGNAL_ARGS
Definition: c.h:1303
int32_t int32
Definition: c.h:481
uint64_t uint64
Definition: c.h:486
size_t Size
Definition: c.h:559
int ProcNumber
Definition: procnumber.h:24
NON_EXEC_STATIC ProcSignalHeader * ProcSignal
Definition: procsignal.c:104
void SendCancelRequest(int backendPID, int32 cancelAuthCode)
Definition: procsignal.c:726
int SendProcSignal(pid_t pid, ProcSignalReason reason, ProcNumber procNumber)
Definition: procsignal.c:281
ProcSignalReason
Definition: procsignal.h:31
@ PROCSIG_PARALLEL_MESSAGE
Definition: procsignal.h:34
@ PROCSIG_RECOVERY_CONFLICT_BUFFERPIN
Definition: procsignal.h:47
@ PROCSIG_CATCHUP_INTERRUPT
Definition: procsignal.h:32
@ PROCSIG_RECOVERY_CONFLICT_LOCK
Definition: procsignal.h:44
@ PROCSIG_LOG_MEMORY_CONTEXT
Definition: procsignal.h:37
@ PROCSIG_RECOVERY_CONFLICT_LOGICALSLOT
Definition: procsignal.h:46
@ PROCSIG_BARRIER
Definition: procsignal.h:36
@ PROCSIG_RECOVERY_CONFLICT_DATABASE
Definition: procsignal.h:42
@ PROCSIG_WALSND_INIT_STOPPING
Definition: procsignal.h:35
@ PROCSIG_PARALLEL_APPLY_MESSAGE
Definition: procsignal.h:38
@ PROCSIG_RECOVERY_CONFLICT_SNAPSHOT
Definition: procsignal.h:45
@ PROCSIG_RECOVERY_CONFLICT_LAST
Definition: procsignal.h:49
@ PROCSIG_RECOVERY_CONFLICT_FIRST
Definition: procsignal.h:41
@ PROCSIG_NOTIFY_INTERRUPT
Definition: procsignal.h:33
@ PROCSIG_RECOVERY_CONFLICT_TABLESPACE
Definition: procsignal.h:43
@ PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK
Definition: procsignal.h:48
void ProcSignalShmemInit(void)
Definition: procsignal.c:130
void ProcessProcSignalBarrier(void)
Definition: procsignal.c:496
ProcSignalBarrierType
Definition: procsignal.h:55
@ PROCSIGNAL_BARRIER_SMGRRELEASE
Definition: procsignal.h:56
void WaitForProcSignalBarrier(uint64 generation)
Definition: procsignal.c:421
void ProcSignalInit(bool cancel_key_valid, int32 cancel_key)
Definition: procsignal.c:166
uint64 EmitProcSignalBarrier(ProcSignalBarrierType type)
Definition: procsignal.c:353
Size ProcSignalShmemSize(void)
Definition: procsignal.c:116
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition: procsignal.c:671
const char * type