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

Added PGRPO13 support. Modify Makefile for run installcheck.#20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ololobus merged 7 commits intomasterfromPGPRO13_installcheck
May 11, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions.travis.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,8 @@ notifications:
on_failure: always

env:
- PG_VERSION=13 LEVEL=hardcore USE_TPCDS=1
- PG_VERSION=13
- PG_VERSION=12 LEVEL=hardcore USE_TPCDS=1
- PG_VERSION=12
- PG_VERSION=11 LEVEL=hardcore USE_TPCDS=1
Expand Down
2 changes: 1 addition & 1 deletionDockerfile.tmpl
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ FROM postgres:${PG_VERSION}-alpine

# Install dependencies
RUN apk add --no-cache \
openssl curl git \
openssl curl gitpatch\
perl perl-ipc-run \
make musl-dev gcc bison flex coreutils \
zlib-dev libedit-dev \
Expand Down
23 changes: 13 additions & 10 deletionsMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,29 +22,32 @@ include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/test.conf

$(EXTENSION)--$(EXTVERSION).sql: init.sql
cat $^ > $@

check: isolationcheck

ISOLATIONCHECKS=corner_cases

submake-isolation:
$(MAKE) -C $(top_builddir)/src/test/isolation all
check: isolationcheck

installcheck: isolationcheck-install-force

isolationcheck: | submake-isolation temp-install
$(MKDIR_P) isolation_output
$(pg_isolation_regress_check) \
--temp-config $(top_srcdir)/contrib/pg_query_state/test.conf \
--outputdir=isolation_output \
$(ISOLATIONCHECKS)
$(ISOLATIONCHECKS)

isolationcheck-install-force: all | submake-isolation temp-install
$(MKDIR_P) isolation_output
isolationcheck-install-force: all | submake-isolation submake-pg_query_state temp-install
$(pg_isolation_regress_installcheck) \
--outputdir=isolation_output \
$(ISOLATIONCHECKS)
$(ISOLATIONCHECKS)

submake-isolation:
$(MAKE) -C $(top_builddir)/src/test/isolation all

.PHONY: isolationcheck isolationcheck-install-force check
submake-pg_query_state:
$(MAKE) -C $(top_builddir)/contrib/pg_query_state

temp-install: EXTRA_INSTALL=contrib/pg_query_state
2 changes: 2 additions & 0 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,6 +57,8 @@ export LEVEL=hardcore
export USE_TPCDS=1
export PG_VERSION=12

./mk_dockerfile.sh

docker-compose build
docker-compose run tests
```
Expand Down
67 changes: 67 additions & 0 deletionsexpected/corner_cases_3.out
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
Parsed test spec with 2 sessions

starting permutation: s1_pg_qs_1
step s1_pg_qs_1: select pg_query_state(1);
ERROR: backend with pid=1 not found

starting permutation: s1_pg_qs_2
step s1_pg_qs_2: select pg_query_state(pg_backend_pid());
ERROR: attempt to extract state of current process

starting permutation: s1_save_pid s2_pg_qs_counterpart
step s1_save_pid: select save_own_pid(0);
save_own_pid


s2: INFO: state of backend is idle
step s2_pg_qs_counterpart: select pg_query_state(counterpart_pid(0));
pg_query_state


starting permutation: s1_save_pid s1_disable_pg_qs s2_pg_qs_counterpart
step s1_save_pid: select save_own_pid(0);
save_own_pid


step s1_disable_pg_qs: set pg_query_state.enable to off;
s2: INFO: query execution statistics disabled
step s2_pg_qs_counterpart: select pg_query_state(counterpart_pid(0));
pg_query_state


starting permutation: s1_set_bob s2_set_bob s1_save_pid s2_pg_qs_counterpart
step s1_set_bob: set role bob;
step s2_set_bob: set role bob;
step s1_save_pid: select save_own_pid(0);
save_own_pid


s2: INFO: state of backend is idle
step s2_pg_qs_counterpart: select pg_query_state(counterpart_pid(0));
pg_query_state


starting permutation: s1_set_bob s2_set_su s1_save_pid s2_pg_qs_counterpart
step s1_set_bob: set role bob;
step s2_set_su: set role super;
step s1_save_pid: select save_own_pid(0);
save_own_pid


s2: INFO: state of backend is idle
step s2_pg_qs_counterpart: select pg_query_state(counterpart_pid(0));
pg_query_state


starting permutation: s1_set_bob s2_set_alice s1_save_pid s2_pg_qs_counterpart
step s1_set_bob: set role bob;
step s2_set_alice: set role alice;
step s1_save_pid: select save_own_pid(0);
save_own_pid


step s2_pg_qs_counterpart: select pg_query_state(counterpart_pid(0));
ERROR: permission denied
unused step name: s1_enable_pg_qs
unused step name: s1_pg_qs_counterpart
unused step name: s2_save_pid
206 changes: 206 additions & 0 deletionspatches/custom_signals_13.0.patch
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c
index 4fa385b0ece..fc1637a2e28 100644
--- a/src/backend/storage/ipc/procsignal.c
+++ b/src/backend/storage/ipc/procsignal.c
@@ -88,12 +88,21 @@ typedef struct
(((flags) & (((uint32) 1) << (uint32) (type))) != 0)

static ProcSignalHeader *ProcSignal = NULL;
+#define IsCustomProcSignalReason(reason) \
+((reason) >= PROCSIG_CUSTOM_1 && (reason) <= PROCSIG_CUSTOM_N)
+
+static bool CustomSignalPendings[NUM_CUSTOM_PROCSIGNALS];
+static bool CustomSignalProcessing[NUM_CUSTOM_PROCSIGNALS];
+static ProcSignalHandler_type CustomInterruptHandlers[NUM_CUSTOM_PROCSIGNALS];
+
static volatile ProcSignalSlot *MyProcSignalSlot = NULL;

static bool CheckProcSignal(ProcSignalReason reason);
static void CleanupProcSignalState(int status, Datum arg);
static void ProcessBarrierPlaceholder(void);

+static void CheckAndSetCustomSignalInterrupts(void);
+
/*
* ProcSignalShmemSize
*Compute space needed for procsignal's shared memory
@@ -235,6 +244,36 @@ CleanupProcSignalState(int status, Datum arg)
slot->pss_pid = 0;
}

+/*
+ * RegisterCustomProcSignalHandler
+ *Assign specific handler of custom process signal with new
+ *ProcSignalReason key.
+ *
+ * This function has to be called in _PG_init function of extensions at the
+ * stage of loading shared preloaded libraries. Otherwise it throws fatal error.
+ *
+ * Return INVALID_PROCSIGNAL if all slots for custom signals are occupied.
+ */
+ProcSignalReason
+RegisterCustomProcSignalHandler(ProcSignalHandler_type handler)
+{
+ProcSignalReason reason;
+
+if (!process_shared_preload_libraries_in_progress)
+ereport(FATAL, (errcode(ERRCODE_INTERNAL_ERROR),
+errmsg("cannot register custom signal after startup")));
+
+/* Iterate through custom signal slots to find a free one */
+for (reason = PROCSIG_CUSTOM_1; reason <= PROCSIG_CUSTOM_N; reason++)
+if (!CustomInterruptHandlers[reason - PROCSIG_CUSTOM_1])
+{
+CustomInterruptHandlers[reason - PROCSIG_CUSTOM_1] = handler;
+return reason;
+}
+
+return INVALID_PROCSIGNAL;
+}
+
/*
* SendProcSignal
*Send a signal to a Postgres process
@@ -585,9 +624,64 @@ procsignal_sigusr1_handler(SIGNAL_ARGS)
if (CheckProcSignal(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN))
RecoveryConflictInterrupt(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN);

+CheckAndSetCustomSignalInterrupts();
+
SetLatch(MyLatch);

latch_sigusr1_handler();

errno = save_errno;
}
+
+/*
+ * Handle receipt of an interrupt indicating any of custom process signals.
+ */
+static void
+CheckAndSetCustomSignalInterrupts()
+{
+ProcSignalReasonreason;
+
+for (reason = PROCSIG_CUSTOM_1; reason <= PROCSIG_CUSTOM_N; reason++)
+{
+if (CheckProcSignal(reason))
+{
+
+/* set interrupt flags */
+InterruptPending = true;
+CustomSignalPendings[reason - PROCSIG_CUSTOM_1] = true;
+}
+}
+
+SetLatch(MyLatch);
+}
+
+/*
+ * CheckAndHandleCustomSignals
+ *Check custom signal flags and call handler assigned to that signal
+ *if it is not NULL
+ *
+ * This function is called within CHECK_FOR_INTERRUPTS if interrupt occurred.
+ */
+void
+CheckAndHandleCustomSignals(void)
+{
+int i;
+
+/* Check on expiring of custom signals and call its handlers if exist */
+for (i = 0; i < NUM_CUSTOM_PROCSIGNALS; i++)
+{
+if (!CustomSignalProcessing[i] && CustomSignalPendings[i])
+{
+ProcSignalHandler_type handler;
+
+CustomSignalPendings[i] = false;
+handler = CustomInterruptHandlers[i];
+if (handler != NULL)
+{
+CustomSignalProcessing[i] = true;
+handler();
+CustomSignalProcessing[i] = false;
+}
+}
+}
+}
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 174c72a14bc..0e7366bd58f 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3221,6 +3221,8 @@ ProcessInterrupts(void)

if (ParallelMessagePending)
HandleParallelMessages();
+
+CheckAndHandleCustomSignals();
}


diff --git a/src/include/storage/procsignal.h b/src/include/storage/procsignal.h
index 5cb39697f38..c05f60fa719 100644
--- a/src/include/storage/procsignal.h
+++ b/src/include/storage/procsignal.h
@@ -17,6 +17,8 @@
#include "storage/backendid.h"


+#define NUM_CUSTOM_PROCSIGNALS 64
+
/*
* Reasons for signaling a Postgres child process (a backend or an auxiliary
* process, like checkpointer). We can cope with concurrent signals for different
@@ -29,6 +31,8 @@
*/
typedef enum
{
+INVALID_PROCSIGNAL = -1,/* Must be first */
+
PROCSIG_CATCHUP_INTERRUPT,/* sinval catchup interrupt */
PROCSIG_NOTIFY_INTERRUPT,/* listen/notify interrupt */
PROCSIG_PARALLEL_MESSAGE,/* message from cooperating parallel backend */
@@ -43,6 +47,14 @@ typedef enum
PROCSIG_RECOVERY_CONFLICT_BUFFERPIN,
PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK,

+PROCSIG_CUSTOM_1,
+/*
+ * PROCSIG_CUSTOM_2,
+ * ...,
+ * PROCSIG_CUSTOM_N-1,
+ */
+PROCSIG_CUSTOM_N = PROCSIG_CUSTOM_1 + NUM_CUSTOM_PROCSIGNALS - 1,
+
NUM_PROCSIGNALS/* Must be last! */
} ProcSignalReason;

@@ -55,6 +67,8 @@ typedef enum
*/
PROCSIGNAL_BARRIER_PLACEHOLDER = 0
} ProcSignalBarrierType;
+/* Handler of custom process signal */
+typedef void (*ProcSignalHandler_type) (void);

/*
* prototypes for functions in procsignal.c
@@ -63,12 +77,15 @@ extern Size ProcSignalShmemSize(void);
extern void ProcSignalShmemInit(void);

extern void ProcSignalInit(int pss_idx);
+extern ProcSignalReason
+RegisterCustomProcSignalHandler(ProcSignalHandler_type handler);
extern intSendProcSignal(pid_t pid, ProcSignalReason reason,
BackendId backendId);

extern uint64 EmitProcSignalBarrier(ProcSignalBarrierType type);
extern void WaitForProcSignalBarrier(uint64 generation);
extern void ProcessProcSignalBarrier(void);
+extern void CheckAndHandleCustomSignals(void);

extern void procsignal_sigusr1_handler(SIGNAL_ARGS);

--
2.25.1

Loading

[8]ページ先頭

©2009-2025 Movatter.jp