postgres.git / summary / log / commit / refs
commit fd4d93d269c02081958e4c0c214f1d82186e5689
Author: Michael Paquier <michael@paquier.xyz>
Date: Fri Oct 06 00:56:55 2023 +0000
First released in: 17.0
Reverted by: 70d067ceccf0 (in 13.19), c58b0c43d36f (in 14.16), 3d1ecc92a0d1 (in 15.11), 41a252c2ca68 (in 16.7), 15b4c46c328b (in 17.3), 34486b6092e7 (in 18.0)
worker_spi: Fix test failure with BGWORKER_BYPASS_ALLOWCONN
A bgworker can spawn parallel workers of its own when executing queries,
and if the worker uses BGWORKER_BYPASS_ALLOWCONN while the database it
is connected to does not allow connections, a parallel worker would fail
to startup. In the case of this module, the step checking for the
presence of the schema to create was spawning a worker, failing the last
test introduced by 991bb0f9653c.
This issue could be reproduced with debug_parallel_query = 'regress',
for example.
Per buildfarm member crake.
src/test/modules/worker_spi/worker_spi.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/worker_spi/worker_spi.c
index 5d81cf45639..1c619d4b189 100644
--- a/src/test/modules/worker_spi/worker_spi.c
+++ b/src/test/modules/worker_spi/worker_spi.c
@@ -173,6 +173,15 @@ worker_spi_main(Datum main_arg)
BackgroundWorkerInitializeConnection(worker_spi_database,
worker_spi_role, flags);
+ /*
+ * Disable parallel query for workers started with BYPASS_ALLOWCONN so as
+ * these don't attempt connections to the database that may not allow
+ * that.
+ */
+ if (flags & BGWORKER_BYPASS_ALLOWCONN)
+ SetConfigOption("max_parallel_workers_per_gather", "0",
+ PGC_USERSET, PGC_S_OVERRIDE);
+
elog(LOG, "%s initialized with %s.%s",
MyBgworkerEntry->bgw_name, table->schema, table->name);
initialize_worker_spi(table);
[parent: 991bb0f9653c]