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

Commit3402536

Browse files
dlepikhovaololobus
authored andcommitted
Added PGRPO13 support. Modify Makefile for run installcheck. Modify script for docker running
1 parentfeaebcd commit3402536

8 files changed

+559
-16
lines changed

‎.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ notifications:
1818
on_failure:always
1919

2020
env:
21+
-PG_VERSION=13 LEVEL=hardcore USE_TPCDS=1
22+
-PG_VERSION=13
2123
-PG_VERSION=12 LEVEL=hardcore USE_TPCDS=1
2224
-PG_VERSION=12
2325
-PG_VERSION=11 LEVEL=hardcore USE_TPCDS=1

‎Dockerfile.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM postgres:${PG_VERSION}-alpine
22

33
# Install dependencies
44
RUN apk add --no-cache \
5-
openssl curl git \
5+
openssl curl gitpatch\
66
perl perl-ipc-run \
77
make musl-dev gcc bison flex coreutils \
88
zlib-dev libedit-dev \

‎Makefile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ endif
2525
$(EXTENSION)--$(EXTVERSION).sql: init.sql
2626
cat$^>$@
2727

28+
ISOLATIONCHECKS=corner_cases
29+
2830
check: isolationcheck
2931

30-
ISOLATIONCHECKS=corner_cases
32+
installcheck:
33+
$(pg_isolation_regress_installcheck)$(ISOLATIONCHECKS)
3134

3235
submake-isolation:
3336
$(MAKE) -C$(top_builddir)/src/test/isolation all
@@ -37,14 +40,6 @@ isolationcheck: | submake-isolation temp-install
3740
$(pg_isolation_regress_check)\
3841
--temp-config$(top_srcdir)/contrib/pg_query_state/test.conf\
3942
--outputdir=isolation_output\
40-
$(ISOLATIONCHECKS)
41-
42-
isolationcheck-install-force: all | submake-isolation temp-install
43-
$(MKDIR_P) isolation_output
44-
$(pg_isolation_regress_installcheck)\
45-
--outputdir=isolation_output\
46-
$(ISOLATIONCHECKS)
47-
48-
.PHONY: isolationcheck isolationcheck-install-force check
43+
$(ISOLATIONCHECKS)
4944

5045
temp-install: EXTRA_INSTALL=contrib/pg_query_state

‎expected/corner_cases_3.out

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
Parsed test spec with 2 sessions
2+
3+
starting permutation: s1_pg_qs_1
4+
step s1_pg_qs_1: select pg_query_state(1);
5+
ERROR: backend with pid=1 not found
6+
7+
starting permutation: s1_pg_qs_2
8+
step s1_pg_qs_2: select pg_query_state(pg_backend_pid());
9+
ERROR: attempt to extract state of current process
10+
11+
starting permutation: s1_save_pid s2_pg_qs_counterpart
12+
step s1_save_pid: select save_own_pid(0);
13+
save_own_pid
14+
15+
16+
s2: INFO: state of backend is idle
17+
step s2_pg_qs_counterpart: select pg_query_state(counterpart_pid(0));
18+
pg_query_state
19+
20+
21+
starting permutation: s1_save_pid s1_disable_pg_qs s2_pg_qs_counterpart
22+
step s1_save_pid: select save_own_pid(0);
23+
save_own_pid
24+
25+
26+
step s1_disable_pg_qs: set pg_query_state.enable to off;
27+
s2: INFO: query execution statistics disabled
28+
step s2_pg_qs_counterpart: select pg_query_state(counterpart_pid(0));
29+
pg_query_state
30+
31+
32+
starting permutation: s1_set_bob s2_set_bob s1_save_pid s2_pg_qs_counterpart
33+
step s1_set_bob: set role bob;
34+
step s2_set_bob: set role bob;
35+
step s1_save_pid: select save_own_pid(0);
36+
save_own_pid
37+
38+
39+
s2: INFO: state of backend is idle
40+
step s2_pg_qs_counterpart: select pg_query_state(counterpart_pid(0));
41+
pg_query_state
42+
43+
44+
starting permutation: s1_set_bob s2_set_su s1_save_pid s2_pg_qs_counterpart
45+
step s1_set_bob: set role bob;
46+
step s2_set_su: set role super;
47+
step s1_save_pid: select save_own_pid(0);
48+
save_own_pid
49+
50+
51+
s2: INFO: state of backend is idle
52+
step s2_pg_qs_counterpart: select pg_query_state(counterpart_pid(0));
53+
pg_query_state
54+
55+
56+
starting permutation: s1_set_bob s2_set_alice s1_save_pid s2_pg_qs_counterpart
57+
step s1_set_bob: set role bob;
58+
step s2_set_alice: set role alice;
59+
step s1_save_pid: select save_own_pid(0);
60+
save_own_pid
61+
62+
63+
step s2_pg_qs_counterpart: select pg_query_state(counterpart_pid(0));
64+
ERROR: permission denied
65+
unused step name: s1_enable_pg_qs
66+
unused step name: s1_pg_qs_counterpart
67+
unused step name: s2_save_pid

‎patches/custom_signals_13.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 4fa385b0ece..fc1637a2e28 100644
3+
--- a/src/backend/storage/ipc/procsignal.c
4+
+++ b/src/backend/storage/ipc/procsignal.c
5+
@@ -88,12 +88,21 @@ typedef struct
6+
(((flags) & (((uint32) 1) << (uint32) (type))) != 0)
7+
8+
static ProcSignalHeader *ProcSignal = NULL;
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 volatile ProcSignalSlot *MyProcSignalSlot = NULL;
17+
18+
static bool CheckProcSignal(ProcSignalReason reason);
19+
static void CleanupProcSignalState(int status, Datum arg);
20+
static void ProcessBarrierPlaceholder(void);
21+
22+
+static void CheckAndSetCustomSignalInterrupts(void);
23+
+
24+
/*
25+
* ProcSignalShmemSize
26+
*Compute space needed for procsignal's shared memory
27+
@@ -235,6 +244,36 @@ CleanupProcSignalState(int status, Datum arg)
28+
slot->pss_pid = 0;
29+
}
30+
31+
+/*
32+
+ * RegisterCustomProcSignalHandler
33+
+ *Assign specific handler of custom process signal with new
34+
+ *ProcSignalReason key.
35+
+ *
36+
+ * This function has to be called in _PG_init function of extensions at the
37+
+ * stage of loading shared preloaded libraries. Otherwise it throws fatal error.
38+
+ *
39+
+ * Return INVALID_PROCSIGNAL if all slots for custom signals are occupied.
40+
+ */
41+
+ProcSignalReason
42+
+RegisterCustomProcSignalHandler(ProcSignalHandler_type handler)
43+
+{
44+
+ProcSignalReason reason;
45+
+
46+
+if (!process_shared_preload_libraries_in_progress)
47+
+ereport(FATAL, (errcode(ERRCODE_INTERNAL_ERROR),
48+
+errmsg("cannot register custom signal after startup")));
49+
+
50+
+/* Iterate through custom signal slots to find a free one */
51+
+for (reason = PROCSIG_CUSTOM_1; reason <= PROCSIG_CUSTOM_N; reason++)
52+
+if (!CustomInterruptHandlers[reason - PROCSIG_CUSTOM_1])
53+
+{
54+
+CustomInterruptHandlers[reason - PROCSIG_CUSTOM_1] = handler;
55+
+return reason;
56+
+}
57+
+
58+
+return INVALID_PROCSIGNAL;
59+
+}
60+
+
61+
/*
62+
* SendProcSignal
63+
*Send a signal to a Postgres process
64+
@@ -585,9 +624,64 @@ procsignal_sigusr1_handler(SIGNAL_ARGS)
65+
if (CheckProcSignal(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN))
66+
RecoveryConflictInterrupt(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN);
67+
68+
+CheckAndSetCustomSignalInterrupts();
69+
+
70+
SetLatch(MyLatch);
71+
72+
latch_sigusr1_handler();
73+
74+
errno = save_errno;
75+
}
76+
+
77+
+/*
78+
+ * Handle receipt of an interrupt indicating any of custom process signals.
79+
+ */
80+
+static void
81+
+CheckAndSetCustomSignalInterrupts()
82+
+{
83+
+ProcSignalReasonreason;
84+
+
85+
+for (reason = PROCSIG_CUSTOM_1; reason <= PROCSIG_CUSTOM_N; reason++)
86+
+{
87+
+if (CheckProcSignal(reason))
88+
+{
89+
+
90+
+/* set interrupt flags */
91+
+InterruptPending = true;
92+
+CustomSignalPendings[reason - PROCSIG_CUSTOM_1] = true;
93+
+}
94+
+}
95+
+
96+
+SetLatch(MyLatch);
97+
+}
98+
+
99+
+/*
100+
+ * CheckAndHandleCustomSignals
101+
+ *Check custom signal flags and call handler assigned to that signal
102+
+ *if it is not NULL
103+
+ *
104+
+ * This function is called within CHECK_FOR_INTERRUPTS if interrupt occurred.
105+
+ */
106+
+void
107+
+CheckAndHandleCustomSignals(void)
108+
+{
109+
+int i;
110+
+
111+
+/* Check on expiring of custom signals and call its handlers if exist */
112+
+for (i = 0; i < NUM_CUSTOM_PROCSIGNALS; i++)
113+
+{
114+
+if (!CustomSignalProcessing[i] && CustomSignalPendings[i])
115+
+{
116+
+ProcSignalHandler_type handler;
117+
+
118+
+CustomSignalPendings[i] = false;
119+
+handler = CustomInterruptHandlers[i];
120+
+if (handler != NULL)
121+
+{
122+
+CustomSignalProcessing[i] = true;
123+
+handler();
124+
+CustomSignalProcessing[i] = false;
125+
+}
126+
+}
127+
+}
128+
+}
129+
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
130+
index 174c72a14bc..0e7366bd58f 100644
131+
--- a/src/backend/tcop/postgres.c
132+
+++ b/src/backend/tcop/postgres.c
133+
@@ -3221,6 +3221,8 @@ ProcessInterrupts(void)
134+
135+
if (ParallelMessagePending)
136+
HandleParallelMessages();
137+
+
138+
+CheckAndHandleCustomSignals();
139+
}
140+
141+
142+
diff --git a/src/include/storage/procsignal.h b/src/include/storage/procsignal.h
143+
index 5cb39697f38..c05f60fa719 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+
@@ -43,6 +47,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+
@@ -55,6 +67,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+
@@ -63,12 +77,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+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp