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

Commit7a85e10

Browse files
dlepikhovaololobus
authored andcommitted
Modify custom_signals patches according to [PGPRO-4197]. Remove HOLD_INTERRUPTS in the CheckAndHandleCustomSignals() function to prevent the posible deadlock while using the pg_query_state extension
Authored by: Konstantin Knizhnik <knizhnik@garret.ru>
1 parent4744f6a commit7a85e10

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

‎patches/custom_signals_13.0.patch

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
From709e3b92c31878617ae0fb547bdb69b17639ce23 Mon Sep 17 00:00:00 2001
1+
From1b94d1ff8308ca86f47b6cfdfd9a4909ef43b1ae Mon Sep 17 00:00:00 2001
22
From: Daria Lepikhova <d.lepikhova@postgrespro.ru>
33
Date: Thu, 8 Oct 2020 14:28:43 +0500
4-
Subject: [PATCH 1/2] custom_signals_13.0
4+
Subject: [PATCH] custom_signals_13.0
55

66
---
7-
src/backend/storage/ipc/procsignal.c |92 ++++++++++++++++++++++++++++
7+
src/backend/storage/ipc/procsignal.c |94 ++++++++++++++++++++++++++++
88
src/backend/tcop/postgres.c | 2 +
99
src/include/storage/procsignal.h | 17 +++++
10-
3 files changed,111 insertions(+)
10+
3 files changed,113 insertions(+)
1111

1212
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c
13-
indexffe67acea1..e286977011 100644
13+
index4fa385b0ece..fc1637a2e28 100644
1414
--- a/src/backend/storage/ipc/procsignal.c
1515
+++ b/src/backend/storage/ipc/procsignal.c
16-
@@ -88,12 +88,20 @@ typedef struct
16+
@@ -88,12 +88,21 @@ typedef struct
1717
(((flags) & (((uint32) 1) << (uint32) (type))) != 0)
1818

1919
static ProcSignalHeader *ProcSignal = NULL;
2020
+#define IsCustomProcSignalReason(reason) \
2121
+((reason) >= PROCSIG_CUSTOM_1 && (reason) <= PROCSIG_CUSTOM_N)
2222
+
2323
+static bool CustomSignalPendings[NUM_CUSTOM_PROCSIGNALS];
24+
+static bool CustomSignalProcessing[NUM_CUSTOM_PROCSIGNALS];
2425
+static ProcSignalHandler_type CustomInterruptHandlers[NUM_CUSTOM_PROCSIGNALS];
2526
+
2627
static volatile ProcSignalSlot *MyProcSignalSlot = NULL;
@@ -34,7 +35,7 @@ index ffe67acea1..e286977011 100644
3435
/*
3536
* ProcSignalShmemSize
3637
*Compute space needed for procsignal's shared memory
37-
@@ -235,6 +243,36 @@ CleanupProcSignalState(int status, Datum arg)
38+
@@ -235,6 +244,36 @@ CleanupProcSignalState(int status, Datum arg)
3839
slot->pss_pid = 0;
3940
}
4041

@@ -71,7 +72,7 @@ index ffe67acea1..e286977011 100644
7172
/*
7273
* SendProcSignal
7374
*Send a signal to a Postgres process
74-
@@ -585,9 +623,63 @@ procsignal_sigusr1_handler(SIGNAL_ARGS)
75+
@@ -585,9 +624,64 @@ procsignal_sigusr1_handler(SIGNAL_ARGS)
7576
if (CheckProcSignal(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN))
7677
RecoveryConflictInterrupt(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN);
7778

@@ -118,28 +119,29 @@ index ffe67acea1..e286977011 100644
118119
+{
119120
+int i;
120121
+
121-
+/* Disable interrupts to avoid recursive calls */
122-
+HOLD_INTERRUPTS();
123-
+
124122
+/* Check on expiring of custom signals and call its handlers if exist */
125123
+for (i = 0; i < NUM_CUSTOM_PROCSIGNALS; i++)
126-
+if (CustomSignalPendings[i])
124+
+{
125+
+if (!CustomSignalProcessing[i] && CustomSignalPendings[i])
127126
+{
128127
+ProcSignalHandler_type handler;
129128
+
130129
+CustomSignalPendings[i] = false;
131130
+handler = CustomInterruptHandlers[i];
132131
+if (handler != NULL)
132+
+{
133+
+CustomSignalProcessing[i] = true;
133134
+handler();
135+
+CustomSignalProcessing[i] = false;
136+
+}
134137
+}
135-
+
136-
+RESUME_INTERRUPTS();
138+
+}
137139
+}
138140
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
139-
index411cfadbff..8f9a682da0 100644
141+
index174c72a14bc..0e7366bd58f 100644
140142
--- a/src/backend/tcop/postgres.c
141143
+++ b/src/backend/tcop/postgres.c
142-
@@ -3209,6 +3209,8 @@ ProcessInterrupts(void)
144+
@@ -3221,6 +3221,8 @@ ProcessInterrupts(void)
143145

144146
if (ParallelMessagePending)
145147
HandleParallelMessages();
@@ -149,7 +151,7 @@ index 411cfadbff..8f9a682da0 100644
149151

150152

151153
diff --git a/src/include/storage/procsignal.h b/src/include/storage/procsignal.h
152-
index5cb39697f3..c05f60fa71 100644
154+
index5cb39697f38..c05f60fa719 100644
153155
--- a/src/include/storage/procsignal.h
154156
+++ b/src/include/storage/procsignal.h
155157
@@ -17,6 +17,8 @@
@@ -211,5 +213,5 @@ index 5cb39697f3..c05f60fa71 100644
211213
extern void procsignal_sigusr1_handler(SIGNAL_ARGS);
212214

213215
--
214-
2.17.1
216+
2.25.1
215217

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp