Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite820f9d

Browse files
authored
Merge pull request#33 from postgrespro/PGPRO-5278-2
porting to version 15 and minor improvements to version 14
2 parentsaa9fbed +612f955 commite820f9d

6 files changed

+475
-21
lines changed

‎patches/custom_signals_14.0.patch

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
From f2632ea7cd03119c55b8aa0ef60f529380ca2536 Mon Sep 17 00:00:00 2001
2-
From: Kovalenko Anastasia <s2180445@gse.cs.msu.ru>
3-
Date: Tue, 24 Aug 2021 16:22:28 +0300
4-
Subject: [PATCH] custom-signals
5-
6-
---
7-
src/backend/storage/ipc/procsignal.c | 94 ++++++++++++++++++++++++++++
8-
src/backend/tcop/postgres.c | 2 +
9-
src/include/storage/procsignal.h | 17 +++++
10-
3 files changed, 113 insertions(+)
11-
121
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c
132
index defb75a..4245d28 100644
143
--- a/src/backend/storage/ipc/procsignal.c

‎patches/custom_signals_15.0.patch

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c
2+
index defb75a..4245d28 100644
3+
--- a/src/backend/storage/ipc/procsignal.c
4+
+++ b/src/backend/storage/ipc/procsignal.c
5+
@@ -95,6 +95,13 @@ typedef struct
6+
#define BARRIER_CLEAR_BIT(flags, type) \
7+
((flags) &= ~(((uint32) 1) << (uint32) (type)))
8+
9+
+#define IsCustomProcSignalReason(reason) \
10+
+((reason) >= PROCSIG_CUSTOM_1 && (reason) <= PROCSIG_CUSTOM_N)
11+
+
12+
+static bool CustomSignalPendings[NUM_CUSTOM_PROCSIGNALS];
13+
+static bool CustomSignalProcessing[NUM_CUSTOM_PROCSIGNALS];
14+
+static ProcSignalHandler_type CustomInterruptHandlers[NUM_CUSTOM_PROCSIGNALS];
15+
+
16+
static ProcSignalHeader *ProcSignal = NULL;
17+
static ProcSignalSlot *MyProcSignalSlot = NULL;
18+
19+
@@ -103,6 +110,8 @@ static void CleanupProcSignalState(int status, Datum arg);
20+
static void ResetProcSignalBarrierBits(uint32 flags);
21+
static bool ProcessBarrierPlaceholder(void);
22+
23+
+static void CheckAndSetCustomSignalInterrupts(void);
24+
+
25+
/*
26+
* ProcSignalShmemSize
27+
*Compute space needed for procsignal's shared memory
28+
@@ -246,6 +255,36 @@ CleanupProcSignalState(int status, Datum arg)
29+
slot->pss_pid = 0;
30+
}
31+
32+
+/*
33+
+ * RegisterCustomProcSignalHandler
34+
+ *Assign specific handler of custom process signal with new
35+
+ *ProcSignalReason key.
36+
+ *
37+
+ * This function has to be called in _PG_init function of extensions at the
38+
+ * stage of loading shared preloaded libraries. Otherwise it throws fatal error.
39+
+ *
40+
+ * Return INVALID_PROCSIGNAL if all slots for custom signals are occupied.
41+
+ */
42+
+ProcSignalReason
43+
+RegisterCustomProcSignalHandler(ProcSignalHandler_type handler)
44+
+{
45+
+ProcSignalReason reason;
46+
+
47+
+if (!process_shared_preload_libraries_in_progress)
48+
+ereport(FATAL, (errcode(ERRCODE_INTERNAL_ERROR),
49+
+errmsg("cannot register custom signal after startup")));
50+
+
51+
+/* Iterate through custom signal slots to find a free one */
52+
+for (reason = PROCSIG_CUSTOM_1; reason <= PROCSIG_CUSTOM_N; reason++)
53+
+if (!CustomInterruptHandlers[reason - PROCSIG_CUSTOM_1])
54+
+{
55+
+CustomInterruptHandlers[reason - PROCSIG_CUSTOM_1] = handler;
56+
+return reason;
57+
+}
58+
+
59+
+return INVALID_PROCSIGNAL;
60+
+}
61+
+
62+
/*
63+
* SendProcSignal
64+
*Send a signal to a Postgres process
65+
@@ -679,7 +718,62 @@ procsignal_sigusr1_handler(SIGNAL_ARGS)
66+
if (CheckProcSignal(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN))
67+
RecoveryConflictInterrupt(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN);
68+
69+
+CheckAndSetCustomSignalInterrupts();
70+
+
71+
SetLatch(MyLatch);
72+
73+
errno = save_errno;
74+
}
75+
+
76+
+/*
77+
+ * Handle receipt of an interrupt indicating any of custom process signals.
78+
+ */
79+
+static void
80+
+CheckAndSetCustomSignalInterrupts()
81+
+{
82+
+ProcSignalReasonreason;
83+
+
84+
+for (reason = PROCSIG_CUSTOM_1; reason <= PROCSIG_CUSTOM_N; reason++)
85+
+{
86+
+if (CheckProcSignal(reason))
87+
+{
88+
+
89+
+/* set interrupt flags */
90+
+InterruptPending = true;
91+
+CustomSignalPendings[reason - PROCSIG_CUSTOM_1] = true;
92+
+}
93+
+}
94+
+
95+
+SetLatch(MyLatch);
96+
+}
97+
+
98+
+/*
99+
+ * CheckAndHandleCustomSignals
100+
+ *Check custom signal flags and call handler assigned to that signal
101+
+ *if it is not NULL
102+
+ *
103+
+ * This function is called within CHECK_FOR_INTERRUPTS if interrupt occurred.
104+
+ */
105+
+void
106+
+CheckAndHandleCustomSignals(void)
107+
+{
108+
+int i;
109+
+
110+
+/* Check on expiring of custom signals and call its handlers if exist */
111+
+for (i = 0; i < NUM_CUSTOM_PROCSIGNALS; i++)
112+
+{
113+
+if (!CustomSignalProcessing[i] && CustomSignalPendings[i])
114+
+{
115+
+ProcSignalHandler_type handler;
116+
+
117+
+CustomSignalPendings[i] = false;
118+
+handler = CustomInterruptHandlers[i];
119+
+if (handler != NULL)
120+
+{
121+
+CustomSignalProcessing[i] = true;
122+
+handler();
123+
+CustomSignalProcessing[i] = false;
124+
+}
125+
+}
126+
+}
127+
+}
128+
\ No newline at end of file
129+
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
130+
index 8cea10c..dd77c98 100644
131+
--- a/src/backend/tcop/postgres.c
132+
+++ b/src/backend/tcop/postgres.c
133+
@@ -3364,6 +3364,8 @@ ProcessInterrupts(void)
134+
if (ParallelMessagePending)
135+
HandleParallelMessages();
136+
137+
+CheckAndHandleCustomSignals();
138+
+
139+
if (LogMemoryContextPending)
140+
ProcessLogMemoryContextInterrupt();
141+
}
142+
diff --git a/src/include/storage/procsignal.h b/src/include/storage/procsignal.h
143+
index eec186b..74af186 100644
144+
--- a/src/include/storage/procsignal.h
145+
+++ b/src/include/storage/procsignal.h
146+
@@ -17,6 +17,8 @@
147+
#include "storage/backendid.h"
148+
149+
150+
+#define NUM_CUSTOM_PROCSIGNALS 64
151+
+
152+
/*
153+
* Reasons for signaling a Postgres child process (a backend or an auxiliary
154+
* process, like checkpointer). We can cope with concurrent signals for different
155+
@@ -29,6 +31,8 @@
156+
*/
157+
typedef enum
158+
{
159+
+INVALID_PROCSIGNAL = -1,/* Must be first */
160+
+
161+
PROCSIG_CATCHUP_INTERRUPT,/* sinval catchup interrupt */
162+
PROCSIG_NOTIFY_INTERRUPT,/* listen/notify interrupt */
163+
PROCSIG_PARALLEL_MESSAGE,/* message from cooperating parallel backend */
164+
@@ -44,6 +48,14 @@ typedef enum
165+
PROCSIG_RECOVERY_CONFLICT_BUFFERPIN,
166+
PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK,
167+
168+
+PROCSIG_CUSTOM_1,
169+
+/*
170+
+ * PROCSIG_CUSTOM_2,
171+
+ * ...,
172+
+ * PROCSIG_CUSTOM_N-1,
173+
+ */
174+
+PROCSIG_CUSTOM_N = PROCSIG_CUSTOM_1 + NUM_CUSTOM_PROCSIGNALS - 1,
175+
+
176+
NUM_PROCSIGNALS/* Must be last! */
177+
} ProcSignalReason;
178+
179+
@@ -56,6 +68,8 @@ typedef enum
180+
*/
181+
PROCSIGNAL_BARRIER_PLACEHOLDER = 0
182+
} ProcSignalBarrierType;
183+
+/* Handler of custom process signal */
184+
+typedef void (*ProcSignalHandler_type) (void);
185+
186+
/*
187+
* prototypes for functions in procsignal.c
188+
@@ -64,12 +78,15 @@ extern Size ProcSignalShmemSize(void);
189+
extern void ProcSignalShmemInit(void);
190+
191+
extern void ProcSignalInit(int pss_idx);
192+
+extern ProcSignalReason
193+
+RegisterCustomProcSignalHandler(ProcSignalHandler_type handler);
194+
extern intSendProcSignal(pid_t pid, ProcSignalReason reason,
195+
BackendId backendId);
196+
197+
extern uint64 EmitProcSignalBarrier(ProcSignalBarrierType type);
198+
extern void WaitForProcSignalBarrier(uint64 generation);
199+
extern void ProcessProcSignalBarrier(void);
200+
+extern void CheckAndHandleCustomSignals(void);
201+
202+
extern void procsignal_sigusr1_handler(SIGNAL_ARGS);
203+
204+
--
205+
2.25.1
206+

‎patches/runtime_explain_14.0.patch

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
From 71a353d4cac663db43c57452f925082a233c0e49 Mon Sep 17 00:00:00 2001
2-
From: Kovalenko Anastasia <s2180445@gse.cs.msu.ru>
3-
Date: Mon, 23 Aug 2021 15:29:59 +0300
4-
Subject: [PATCH] runtime-explain
5-
6-
---
7-
src/backend/commands/explain.c | 153 ++++++++++++++++++++++++++++-----
8-
src/include/commands/explain.h | 2 +
9-
2 files changed, 133 insertions(+), 22 deletions(-)
10-
111
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
122
index 10644dfac4..7106ed4257 100644
133
--- a/src/backend/commands/explain.c

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp