aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2023-07-21 12:07:52 +0900
committerMichael Paquier <michael@paquier.xyz>2023-07-21 12:07:52 +0900
commit97ff8dd02ca788020021cdafb85d77d4fd3f3125 (patch)
treee98aedfa0fc696cfd94a34b0c5c460807b133ad5 /src
parent9089287aa037fdecb5a52cec1926e5ae9569e9f9 (diff)
downloadpostgresql-97ff8dd02ca788020021cdafb85d77d4fd3f3125.tar.gz
postgresql-97ff8dd02ca788020021cdafb85d77d4fd3f3125.zip
Fix worker_spi when launching workers without shared_preload_libraries
Currently, the database name to connect is initialized only when the module is loaded with shared_preload_libraries, causing any call of worker_spi_launch() to fail if the library is not loaded for a dynamic bgworker launch. Rather than making the GUC defining the database to connect to a PGC_POSTMASTER, this commit switches worker_spi.database to PGC_SIGHUP, loaded even if the module's library is loaded dynamically for a worker. We have been discussing about the integration of more advanced tests in this module, with and without shared_preload_libraries set, so this eases a bit the work planned in this area. No backpatch is done as, while this is a bug, it changes the definition of worker_spi.database. Author: Masahiro Ikeda Reviewed-by: Bharath Rupireddy Discussion: https://postgr.es/m/d30d3ea7d21cb7c9e1e3cc47e301f1b6@oss.nttdata.com
Diffstat (limited to 'src')
-rw-r--r--src/test/modules/worker_spi/worker_spi.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/worker_spi/worker_spi.c
index 7227cfaa45c..ada0fb8ac73 100644
--- a/src/test/modules/worker_spi/worker_spi.c
+++ b/src/test/modules/worker_spi/worker_spi.c
@@ -283,6 +283,11 @@ _PG_init(void)
BackgroundWorker worker;
/* get the configuration */
+
+ /*
+ * These GUCs are defined even if this library is not loaded with
+ * shared_preload_libraries, for worker_spi_launch().
+ */
DefineCustomIntVariable("worker_spi.naptime",
"Duration between each check (in seconds).",
NULL,
@@ -296,6 +301,15 @@ _PG_init(void)
NULL,
NULL);
+ DefineCustomStringVariable("worker_spi.database",
+ "Database to connect to.",
+ NULL,
+ &worker_spi_database,
+ "postgres",
+ PGC_SIGHUP,
+ 0,
+ NULL, NULL, NULL);
+
if (!process_shared_preload_libraries_in_progress)
return;
@@ -312,15 +326,6 @@ _PG_init(void)
NULL,
NULL);
- DefineCustomStringVariable("worker_spi.database",
- "Database to connect to.",
- NULL,
- &worker_spi_database,
- "postgres",
- PGC_POSTMASTER,
- 0,
- NULL, NULL, NULL);
-
MarkGUCPrefixReserved("worker_spi");
/* set up common data for all our workers */