Fix misplaced shared_preload_libraries_in_progress check in few extensions

Started by Bharath Rupireddyalmost 3 years ago2 messages
#1Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
1 attachment(s)

Hi,

I'm attaching a patch to do $subject in autoprewarm.c and worker_spi
extensions. The way it is right now doesn't hurt anyone, but why to
fail after defining custom GUCs if we aren't loading them via
shared_preload_libraries.

Thoughts?

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachments:

v1-0001-Fix-misplaced-shared_preload_libraries_in_progres.patchapplication/octet-stream; name=v1-0001-Fix-misplaced-shared_preload_libraries_in_progres.patchDownload
From edabc369310562e6828f5877fc7944d9f3cb013a Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Sat, 18 Mar 2023 04:47:19 +0000
Subject: [PATCH v1] Fix misplaced shared_preload_libraries_in_progress check
 in few extensions

---
 contrib/pg_prewarm/autoprewarm.c         | 6 +++---
 src/test/modules/worker_spi/worker_spi.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/contrib/pg_prewarm/autoprewarm.c b/contrib/pg_prewarm/autoprewarm.c
index 93835449c0..2c5520d70e 100644
--- a/contrib/pg_prewarm/autoprewarm.c
+++ b/contrib/pg_prewarm/autoprewarm.c
@@ -111,6 +111,9 @@ static int	autoprewarm_interval = 300; /* dump interval */
 void
 _PG_init(void)
 {
+	if (!process_shared_preload_libraries_in_progress)
+		return;
+
 	DefineCustomIntVariable("pg_prewarm.autoprewarm_interval",
 							"Sets the interval between dumps of shared buffers",
 							"If set to zero, time-based dumping is disabled.",
@@ -123,9 +126,6 @@ _PG_init(void)
 							NULL,
 							NULL);
 
-	if (!process_shared_preload_libraries_in_progress)
-		return;
-
 	/* can't define PGC_POSTMASTER variable after startup */
 	DefineCustomBoolVariable("pg_prewarm.autoprewarm",
 							 "Starts the autoprewarm worker.",
diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/worker_spi/worker_spi.c
index f536120bf1..3fc342764b 100644
--- a/src/test/modules/worker_spi/worker_spi.c
+++ b/src/test/modules/worker_spi/worker_spi.c
@@ -282,6 +282,9 @@ _PG_init(void)
 {
 	BackgroundWorker worker;
 
+	if (!process_shared_preload_libraries_in_progress)
+		return;
+
 	/* get the configuration */
 	DefineCustomIntVariable("worker_spi.naptime",
 							"Duration between each check (in seconds).",
@@ -296,9 +299,6 @@ _PG_init(void)
 							NULL,
 							NULL);
 
-	if (!process_shared_preload_libraries_in_progress)
-		return;
-
 	DefineCustomIntVariable("worker_spi.total_workers",
 							"Number of workers.",
 							NULL,
-- 
2.34.1

#2Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Bharath Rupireddy (#1)
Re: Fix misplaced shared_preload_libraries_in_progress check in few extensions

At Sat, 18 Mar 2023 10:26:42 +0530, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote in

Hi,

I'm attaching a patch to do $subject in autoprewarm.c and worker_spi
extensions. The way it is right now doesn't hurt anyone, but why to
fail after defining custom GUCs if we aren't loading them via
shared_preload_libraries.

Thoughts?

I don't think they're misplaced at least for pg_prewram. pg_prewarm
worker allows to be executed after startup and the variable is still
used by such prewarm worker processes, but the patch make the variable
stop working in that case.

I didn't look at the part for worker_spi.c.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center