Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*-------------------------------------------------------------------------
 *
 * procsignal.h
 *    Routines for interprocess signaling
 *
 *
 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * src/include/storage/procsignal.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef PROCSIGNAL_H
#define PROCSIGNAL_H
 
#include "storage/procnumber.h"
 
 
/* [PG_CUSTOM: RUDB_PROCESS_SIGNALS] BEGIN: RuDB backend/workers передают собственные ProcSignal через SIGUSR1. */
#define NUM_CUSTOM_PROCSIGNALS 64
 
 
/* [PG_CUSTOM: RUDB_PROCESS_SIGNALS] END */
/*
 * Reasons for signaling a Postgres child process (a backend or an auxiliary
 * process, like checkpointer).  We can cope with concurrent signals for different
 * reasons.  However, if the same reason is signaled multiple times in quick
 * succession, the process is likely to observe only one notification of it.
 * This is okay for the present uses.
 *
 * Also, because of race conditions, it's important that all the signals be
 * defined so that no harm is done if a process mistakenly receives one.
 */
typedef enum
{
    /* [PG_CUSTOM: RUDB_PROCESS_SIGNALS] BEGIN: RuDB backend/workers передают собственные ProcSignal через SIGUSR1. */
    INVALID_PROCSIGNAL = -1,
 
/* [PG_CUSTOM: RUDB_PROCESS_SIGNALS] END */
    PROCSIG_CATCHUP_INTERRUPT,  /* sinval catchup interrupt */
    PROCSIG_NOTIFY_INTERRUPT,   /* listen/notify interrupt */
    PROCSIG_PARALLEL_MESSAGE,   /* message from cooperating parallel backend */
    PROCSIG_WALSND_INIT_STOPPING,   /* ask walsenders to prepare for shutdown  */
    PROCSIG_BARRIER,            /* global barrier interrupt  */
    PROCSIG_LOG_MEMORY_CONTEXT, /* ask backend to log the memory contexts */
    PROCSIG_PARALLEL_APPLY_MESSAGE, /* Message from parallel apply workers */
    PROCSIG_SLOTSYNC_MESSAGE,   /* ask slot synchronization to stop */
    PROCSIG_REPACK_MESSAGE,     /* Message from repack worker */
    PROCSIG_RECOVERY_CONFLICT,  /* backend is blocking recovery, check
                                 * PGPROC->pendingRecoveryConflicts for the
                                 * reason */
    /* [PG_CUSTOM: RUDB_PROCESS_SIGNALS] BEGIN: RuDB backend/workers передают собственные ProcSignal через SIGUSR1. */
    PROCSIG_CUSTOM_1,
    /*
     * PROCSIG_CUSTOM_2,
     * ...,
     * PROCSIG_CUSTOM_N-1,
     */
    PROCSIG_CUSTOM_N = PROCSIG_CUSTOM_1 + NUM_CUSTOM_PROCSIGNALS - 1,
} ProcSignalReason;
 
#define NUM_PROCSIGNALS (PROCSIG_CUSTOM_N + 1)
/* [PG_CUSTOM: RUDB_PROCESS_SIGNALS] END */
 
typedef enum
{
    PROCSIGNAL_BARRIER_SMGRRELEASE, /* ask smgr to close files */
    PROCSIGNAL_BARRIER_UPDATE_XLOG_LOGICAL_INFO,    /* ask to update
                                                     * XLogLogicalInfo */
} ProcSignalBarrierType;
 
/* [PG_CUSTOM: RUDB_PROCESS_SIGNALS] RuDB backend/workers передают собственные ProcSignal через SIGUSR1. */
typedef void (*ProcSignalHandler_type) (void);
 
/*
 * Length of query cancel keys generated.
 *
 * Note that the protocol allows for longer keys, or shorter, but this is the
 * length we actually generate.  Client code, and the server code that handles
 * incoming cancellation packets from clients, mustn't use this hardcoded
 * length.
 */
#define MAX_CANCEL_KEY_LENGTH  32
 
/*
 * prototypes for functions in procsignal.c
 */
extern void ProcSignalInit(const uint8 *cancel_key, int cancel_key_len);
/* [PG_CUSTOM: RUDB_PROCESS_SIGNALS] RuDB backend/workers передают собственные ProcSignal через SIGUSR1. */
extern ProcSignalReason RegisterCustomProcSignalHandler(ProcSignalHandler_type handler);
extern int  SendProcSignal(pid_t pid, ProcSignalReason reason,
                           ProcNumber procNumber);
extern void SendCancelRequest(int backendPID, const uint8 *cancel_key, int cancel_key_len);
 
extern uint64 EmitProcSignalBarrier(ProcSignalBarrierType type);
extern void WaitForProcSignalBarrier(uint64 generation);
extern void ProcessProcSignalBarrier(void);
/* [PG_CUSTOM: RUDB_PROCESS_SIGNALS] RuDB backend/workers передают собственные ProcSignal через SIGUSR1. */
extern void CheckAndHandleCustomSignals(void);
 
extern void procsignal_sigusr1_handler(SIGNAL_ARGS);
 
/* ProcSignalHeader is an opaque struct, details known only within procsignal.c */
typedef struct ProcSignalHeader ProcSignalHeader;
 
#ifdef EXEC_BACKEND
extern PGDLLIMPORT ProcSignalHeader *ProcSignal;
#endif
 
#endif                          /* PROCSIGNAL_H */