Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vcbl5-008unW-19 for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Jan 2026 03:59:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vcbl4-00HBaw-0u for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Jan 2026 03:59:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vcbl3-00HBao-0z for pgsql-hackers@lists.postgresql.org; Mon, 05 Jan 2026 03:59:54 +0000 Received: from fhigh-a6-smtp.messagingengine.com ([103.168.172.157]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vcbl1-004Fvx-2a for pgsql-hackers@postgresql.org; Mon, 05 Jan 2026 03:59:53 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 226B014000A1; Sun, 4 Jan 2026 22:59:50 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Sun, 04 Jan 2026 22:59:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1767585590; x=1767671990; bh=wyLcpGNkFw 3u7jqyV5VF0UWqT3YVx6kIRB4t89gxUTA=; b=SRSAQisbzV3fcw9N831Vvi3Cb6 Pc+5EYEdgZkhMeChD4ZdklgpovH46fXeGcpk+z+dvO9xTiHZtcomAVw3lmQu9cdd baiQ+VEdBkunenMk/RDt6bLkRmLKvf0DtJsPV9N/gJOEhYY4lKys87pHedPj3APj c5MEXhwlTmM2/+gYaqv7upyvy1X74KUiJMcM3ob390fJS7isF96Nd1ycISzenfQ5 MDch3AAMVei7wmYhChnwTwcPsrxT5bQBEtB4aNBgFTftuMeavUTxTgTDlSB1w8IE g7B7/norRvzJfN9+IRK/eo8qEebGMVn8tZV/60O2bvHWV2BV3eZN4VHRNSgg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1767585590; x=1767671990; bh=wyLcpGNkFw3u7jqyV5VF0UWqT3YVx6kIRB4 t89gxUTA=; b=z4KZSF4BiCxtx6eqPyInpMNEyBE1ENYaRMLtVmR+9N1dw40iNu3 ZGS7Y/G7CfYSHA9c9umFNzajAYxO9wnEQbBbdSGrZRRx1MA3w0vNiXrZLOkN3W9c 00IkfWTnAqHD5lNvXRPLJgBZ+9HTBL7BFxlJKHb7UppBHKL2zFT9eU4fpzo5Qpew Mq8Yx/dcMWsOn/yR8OXZGo0VtSh/7T3X69+VmMXaWsIMpw3ggblAjXAUSd72Vjab 0sUIKa3pl+ug0X2PYzewxVgPDztneQNim8RM3Ccw7H+l0tzDhe6UAbcJIY4qsXXn MC/M7jc9xD8WbPVCl1SMIS++O7kPvQRM/vA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdeliedvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeeipdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehsmhhith hhphgsvddvhedtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepihifrghtrgdrrgihrges fhhujhhithhsuhdrtghomhdprhgtphhtthhopehprghvvghlrdhsthgvhhhulhgvsehgmh grihhlrdgtohhmpdhrtghpthhtoheplhhirdgvvhgrnhdrtghhrghosehgmhgrihhlrdgt ohhmpdhrtghpthhtohepkhhurhhouggrrdhhrgihrghtohesfhhujhhithhsuhdrtghomh dprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhr gh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 4 Jan 2026 22:59:47 -0500 (EST) Date: Mon, 5 Jan 2026 12:59:30 +0900 From: Michael Paquier To: Peter Smith Cc: "Aya Iwata (Fujitsu)" , Pavel Stehule , Chao Li , "Hayato Kuroda (Fujitsu)" , pgsql-hackers Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="eotPXKKGoGtulf0B" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --eotPXKKGoGtulf0B Content-Type: multipart/mixed; boundary="+i1iNwUgarm6ZeP0" Content-Disposition: inline --+i1iNwUgarm6ZeP0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 05, 2026 at 01:44:55PM +1100, Peter Smith wrote: > It is not at all clear to me if you are advocating for the flag to be > called INTERRUPTABLE or to be called PROTECTED? Actually, INTERRUPTABLE is still wrong. INTERRUPTIBLE reads more like correct English.=20 > IIUC, behaviour-wise it ultimately ends up the same, just the flags > are different names with opposite meanings and defaults. Still, you > need to choose ASAP because this decision touches a lot of code, > comments and tests. Well, not exactly. I think that there is a pretty good argument in not breaking an existing behavior silently, which is what PROTECTED is about. > It seems that when Michael wrote, there were "more advantages in ... > make a bgworker interruptible an opt-in choice" [1], he is favouring > keeping it as the INTERRUPTABLE flag -- e.g. discard patch 0002. Am I > reading this thread correctly? You are reading that right: I do not see a point in 0002. The timing is interesting, I have put my hands on this patch this morning before you sent your last email, and adjusted the thing in many ways, finishing with the attached. This includes changes in the tests to address what I found was lacking and slightly incorrect, new names for the flag and its related variables, copyright update to 2026, as well as an additional sanity check when starting the workers, leading to the updated version attached. The CI is happy with it. Thoughts or comments about that? -- Michael --+i1iNwUgarm6ZeP0 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0001-Allow-background-workers-to-be-terminated-at-DRO.patch" Content-Transfer-Encoding: quoted-printable =46rom 0ec550bdc60de4f2aaa5e81f8c7079d7818ee7dc Mon Sep 17 00:00:00 2001 =46rom: "iwata.aya" Date: Thu, 11 Sep 2025 21:16:51 +0900 Subject: [PATCH v12] Allow background workers to be terminated at DROP DATABASE --- src/include/postmaster/bgworker.h | 8 + src/backend/postmaster/bgworker.c | 51 ++++++ src/backend/storage/ipc/procarray.c | 28 +++- src/test/modules/worker_spi/Makefile | 4 + src/test/modules/worker_spi/meson.build | 4 + .../worker_spi/t/002_worker_terminate.pl | 148 ++++++++++++++++++ .../modules/worker_spi/worker_spi--1.0.sql | 3 +- src/test/modules/worker_spi/worker_spi.c | 5 + doc/src/sgml/bgworker.sgml | 19 +++ 9 files changed, 264 insertions(+), 6 deletions(-) create mode 100644 src/test/modules/worker_spi/t/002_worker_terminate.pl diff --git a/src/include/postmaster/bgworker.h b/src/include/postmaster/bgw= orker.h index 5f84f48aa0d8..8acca22947d5 100644 --- a/src/include/postmaster/bgworker.h +++ b/src/include/postmaster/bgworker.h @@ -59,6 +59,13 @@ */ #define BGWORKER_BACKEND_DATABASE_CONNECTION 0x0002 =20 +/* + * Exit the bgworker if its database is involved in a CREATE, ALTER or DROP + * database command. It requires BGWORKER_SHMEM_ACCESS and + * BGWORKER_BACKEND_DATABASE_CONNECTION. + */ +#define BGWORKER_INTERRUPTIBLE 0x0004 + /* * This class is used internally for parallel queries, to keep track of the * number of active parallel workers and make sure we never launch more th= an @@ -128,6 +135,7 @@ extern const char *GetBackgroundWorkerTypeByPid(pid_t p= id); =20 /* Terminate a bgworker */ extern void TerminateBackgroundWorker(BackgroundWorkerHandle *handle); +extern void TerminateInterruptibleBgWorkersByDbOid(Oid databaseId); =20 /* This is valid in a running worker */ extern PGDLLIMPORT BackgroundWorker *MyBgworkerEntry; diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgw= orker.c index af02eea754fa..6408510d6554 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -26,6 +26,7 @@ #include "storage/lwlock.h" #include "storage/pmsignal.h" #include "storage/proc.h" +#include "storage/procarray.h" #include "storage/procsignal.h" #include "storage/shmem.h" #include "tcop/tcopprot.h" @@ -665,6 +666,17 @@ SanityCheckBackgroundWorker(BackgroundWorker *worker, = int elevel) /* XXX other checks? */ } =20 + /* Interruptible workers require a database connection */ + if ((worker->bgw_flags & BGWORKER_INTERRUPTIBLE) && + !(worker->bgw_flags & BGWORKER_BACKEND_DATABASE_CONNECTION)) + { + ereport(elevel, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("background worker \"%s\": cannot make background workers inte= rruptible without database access", + worker->bgw_name))); + return false; + } + if ((worker->bgw_restart_time < 0 && worker->bgw_restart_time !=3D BGW_NEVER_RESTART) || (worker->bgw_restart_time > USECS_PER_DAY / 1000)) @@ -1399,3 +1411,42 @@ GetBackgroundWorkerTypeByPid(pid_t pid) =20 return result; } + +/* + * Terminate all background workers connected to the given database, if th= ey + * had requested it. + */ +void +TerminateInterruptibleBgWorkersByDbOid(Oid databaseId) +{ + bool signal_postmaster =3D false; + + LWLockAcquire(BackgroundWorkerLock, LW_EXCLUSIVE); + + /* + * Iterate through slots, looking for workers connected to the given + * database. + */ + for (int slotno =3D 0; slotno < BackgroundWorkerData->total_slots; ++slot= no) + { + BackgroundWorkerSlot *slot =3D &BackgroundWorkerData->slot[slotno]; + + if (slot->in_use && + (slot->worker.bgw_flags & BGWORKER_INTERRUPTIBLE)) + { + PGPROC *proc =3D BackendPidGetProc(slot->pid); + + if (proc && proc->databaseId =3D=3D databaseId) + { + slot->terminate =3D true; + signal_postmaster =3D true; + } + } + } + + LWLockRelease(BackgroundWorkerLock); + + /* Make sure the postmaster notices the change to shared memory. */ + if (signal_postmaster) + SendPostmasterSignal(PMSIGNAL_BACKGROUND_WORKER_CHANGE); +} diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/= procarray.c index 52f886bf84fb..4c5efb7f9d20 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -56,11 +56,13 @@ #include "catalog/pg_authid.h" #include "miscadmin.h" #include "pgstat.h" +#include "postmaster/bgworker.h" #include "port/pg_lfind.h" #include "storage/proc.h" #include "storage/procarray.h" #include "utils/acl.h" #include "utils/builtins.h" +#include "utils/injection_point.h" #include "utils/lsyscache.h" #include "utils/rel.h" #include "utils/snapmgr.h" @@ -3687,8 +3689,9 @@ CountUserBackends(Oid roleid) * CountOtherDBBackends -- check for other backends running in the given DB * * If there are other backends in the DB, we will wait a maximum of 5 seco= nds - * for them to exit. Autovacuum backends are encouraged to exit early by - * sending them SIGTERM, but normal user backends are just waited for. + * for them to exit. Autovacuum backends and background workers are encou= raged + * to exit early by sending them SIGTERM, but normal user backends are just + * waited for. * * The current backend is always ignored; it is caller's responsibility to * check whether the current backend uses the given DB, if it's important. @@ -3713,10 +3716,19 @@ CountOtherDBBackends(Oid databaseId, int *nbackends= , int *nprepared) =20 #define MAXAUTOVACPIDS 10 /* max autovacs to SIGTERM per iteration */ int autovac_pids[MAXAUTOVACPIDS]; - int tries; =20 - /* 50 tries with 100ms sleep between tries makes 5 sec total wait */ - for (tries =3D 0; tries < 50; tries++) + /* + * Retry up to 50 times with 100ms between attempts (max 5s total). Can be + * reduced to 3 attempts (max 0.3s total) to speed up tests. + */ + int ntries =3D 50; + +#ifdef USE_INJECTION_POINTS + if (IS_INJECTION_POINT_ATTACHED("reduce-ncounts")) + ntries =3D 3; +#endif + + for (int tries =3D 0; tries < ntries; tries++) { int nautovacs =3D 0; bool found =3D false; @@ -3766,6 +3778,12 @@ CountOtherDBBackends(Oid databaseId, int *nbackends,= int *nprepared) for (index =3D 0; index < nautovacs; index++) (void) kill(autovac_pids[index], SIGTERM); /* ignore any error */ =20 + /* + * Terminate all background workers for this database, if they have + * requested it (BGWORKER_INTERRUPTIBLE). + */ + TerminateInterruptibleBgWorkersByDbOid(databaseId); + /* sleep, then try again */ pg_usleep(100 * 1000L); /* 100ms */ } diff --git a/src/test/modules/worker_spi/Makefile b/src/test/modules/worker= _spi/Makefile index 024b34cdbb35..e7c5c059e321 100644 --- a/src/test/modules/worker_spi/Makefile +++ b/src/test/modules/worker_spi/Makefile @@ -6,6 +6,10 @@ EXTENSION =3D worker_spi DATA =3D worker_spi--1.0.sql PGFILEDESC =3D "worker_spi - background worker example" =20 +EXTRA_INSTALL =3D src/test/modules/injection_points + +export enable_injection_points + TAP_TESTS =3D 1 =20 ifdef USE_PGXS diff --git a/src/test/modules/worker_spi/meson.build b/src/test/modules/wor= ker_spi/meson.build index e9236bc27e71..6475e23f6017 100644 --- a/src/test/modules/worker_spi/meson.build +++ b/src/test/modules/worker_spi/meson.build @@ -26,8 +26,12 @@ tests +=3D { 'sd': meson.current_source_dir(), 'bd': meson.current_build_dir(), 'tap': { + 'env': { + 'enable_injection_points': get_option('injection_points') ? 'yes' : = 'no', + }, 'tests': [ 't/001_worker_spi.pl', + 't/002_worker_terminate.pl' ], }, } diff --git a/src/test/modules/worker_spi/t/002_worker_terminate.pl b/src/te= st/modules/worker_spi/t/002_worker_terminate.pl new file mode 100644 index 000000000000..2be3a122fe54 --- /dev/null +++ b/src/test/modules/worker_spi/t/002_worker_terminate.pl @@ -0,0 +1,148 @@ +# Copyright (c) 2026, PostgreSQL Global Development Group + +# Test background workers can be terminated by db commands + +use strict; +use warnings FATAL =3D> 'all'; +use PostgreSQL::Test::Cluster; +use PostgreSQL::Test::Utils; +use Test::More; + +# This test depends on injection points to detect whether background worke= rs +# remain. +if ($ENV{enable_injection_points} ne 'yes') +{ + plan skip_all =3D> 'Injection points not supported by this build'; +} + +# Ensure the worker_spi dynamic worker is launched on the specified databa= se. +# Returns the PID of the worker launched. +sub launch_bgworker +{ + my ($node, $database, $testcase, $request_terminate) =3D @_; + my $offset =3D -s $node->logfile; + + # Launch a background worker on the given database. + my $pid =3D $node->safe_psql( + $database, qq( + SELECT worker_spi_launch($testcase, '$database'::regdatabase, 0, '= {}', $request_terminate); + )); + + # Check that the bgworker is initialized. + $node->wait_for_log( + qr/LOG: worker_spi dynamic worker $testcase initialized with .*\..*/, + $offset); + my $result =3D $node->safe_psql($database, + "SELECT count(*) > 0 FROM pg_stat_activity WHERE pid =3D $pid;"); + is($result, 't', "dynamic bgworker $testcase launched"); + + return $pid; +} + +# Run query and verify that the bgworker with the specified PID has been +# terminated. +sub run_db_command +{ + my ($node, $command, $testname, $pid) =3D @_; + my $offset =3D -s $node->logfile; + + $node->safe_psql('postgres', $command); + + $node->wait_for_log( + qr/terminating background worker \"worker_spi dynamic\" due to administr= ator command/, + $offset); + + my $result =3D $node->safe_psql('postgres', + "SELECT count(*) =3D 0 FROM pg_stat_activity WHERE pid =3D $pid;"); + is($result, 't', "dynamic bgworker stopped for $testname"); +} + +my $node =3D PostgreSQL::Test::Cluster->new('mynode'); +$node->init; +$node->start; + +# Check if the extension injection_points is available, as it may be +# possible that this script is run with installcheck, where the module +# would not be installed by default. +if (!$node->check_extension('injection_points')) +{ + plan skip_all =3D> 'Extension injection_points not installed'; +} + +$node->safe_psql('postgres', 'CREATE EXTENSION worker_spi;'); + +# Launch a background worker without BGWORKER_INTERRUPTIBLE. +my $pid =3D launch_bgworker($node, 'postgres', 0, 'false'); + +# Ensure CREATE DATABASE WITH TEMPLATE fails because a non-interruptible +# bgworker exists. + +# The injection point 'reduce-ncounts' reduces the number of backend +# retries, allowing for shorter test runs. See CountOtherDBBackends(). +$node->safe_psql('postgres', "CREATE EXTENSION injection_points;"); +$node->safe_psql('postgres', + "SELECT injection_points_attach('reduce-ncounts', 'error');"); + +my $stderr; + +$node->psql( + 'postgres', + "CREATE DATABASE testdb WITH TEMPLATE postgres", + stderr =3D> \$stderr); +ok( $stderr =3D~ + "source database \"postgres\" is being accessed by other users", + "background worker blocked the database creation"); + +# Confirm that the non-interruptible bgworker is still running. +my $result =3D $node->safe_psql( + "postgres", qq( + SELECT count(1) FROM pg_stat_activity + WHERE backend_type =3D 'worker_spi dynamic';)); + +is($result, '1', + "background worker is still running after CREATE DATABASE WITH TEMPLATE"); + +# Terminate the non-interruptible worker for the next tests. +$node->safe_psql( + "postgres", qq( + SELECT pg_terminate_backend(pid) + FROM pg_stat_activity WHERE backend_type =3D 'worker_spi dynamic';= )); + +# The injection point is not used anymore, release it. +$node->safe_psql('postgres', + "SELECT injection_points_detach('reduce-ncounts');"); + +# Check that BGWORKER_INTERRUPTIBLE allows background workers to be +# terminated with database-related commands. + +# Test case 1: CREATE DATABASE WITH TEMPLATE +$pid =3D launch_bgworker($node, 'postgres', 1, 'true'); +run_db_command( + $node, + "CREATE DATABASE testdb WITH TEMPLATE postgres", + "CREATE DATABASE WITH TEMPLATE", $pid); + +# Test case 2: ALTER DATABASE RENAME +$pid =3D launch_bgworker($node, 'testdb', 2, 'true'); +run_db_command( + $node, + "ALTER DATABASE testdb RENAME TO renameddb", + "ALTER DATABASE RENAME", $pid); + +# Preparation for the next test, create a tablespace. +my $tablespace =3D PostgreSQL::Test::Utils::tempdir; +$node->safe_psql('postgres', + "CREATE TABLESPACE test_tablespace LOCATION '$tablespace'"); + +# Test case 3: ALTER DATABASE SET TABLESPACE +$pid =3D launch_bgworker($node, 'renameddb', 3, 'true'); +run_db_command( + $node, + "ALTER DATABASE renameddb SET TABLESPACE test_tablespace", + "ALTER DATABASE SET TABLESPACE", $pid); + +# Test case 4: DROP DATABASE +$pid =3D launch_bgworker($node, 'renameddb', 4, 'true'); +run_db_command($node, "DROP DATABASE renameddb", "DROP DATABASE", $pid); + +done_testing(); diff --git a/src/test/modules/worker_spi/worker_spi--1.0.sql b/src/test/mod= ules/worker_spi/worker_spi--1.0.sql index 84deb6199f63..f5e9621b0d1e 100644 --- a/src/test/modules/worker_spi/worker_spi--1.0.sql +++ b/src/test/modules/worker_spi/worker_spi--1.0.sql @@ -7,7 +7,8 @@ CREATE FUNCTION worker_spi_launch(index int4, dboid oid DEFAULT 0, roleoid oid DEFAULT 0, - flags text[] DEFAULT '{}') + flags text[] DEFAULT '{}', + interruptible boolean DEFAULT false) RETURNS pg_catalog.int4 STRICT AS 'MODULE_PATHNAME' LANGUAGE C; diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/wo= rker_spi/worker_spi.c index 7b0cd2e99b4a..d1e4a2bd9520 100644 --- a/src/test/modules/worker_spi/worker_spi.c +++ b/src/test/modules/worker_spi/worker_spi.c @@ -404,10 +404,15 @@ worker_spi_launch(PG_FUNCTION_ARGS) Size ndim; int nelems; Datum *datum_flags; + bool interruptible =3D PG_GETARG_BOOL(4); =20 memset(&worker, 0, sizeof(worker)); worker.bgw_flags =3D BGWORKER_SHMEM_ACCESS | BGWORKER_BACKEND_DATABASE_CONNECTION; + + if (interruptible) + worker.bgw_flags |=3D BGWORKER_INTERRUPTIBLE; + worker.bgw_start_time =3D BgWorkerStart_RecoveryFinished; worker.bgw_restart_time =3D BGW_NEVER_RESTART; sprintf(worker.bgw_library_name, "worker_spi"); diff --git a/doc/src/sgml/bgworker.sgml b/doc/src/sgml/bgworker.sgml index 2c393385a91f..6c45aeafef6b 100644 --- a/doc/src/sgml/bgworker.sgml +++ b/doc/src/sgml/bgworker.sgml @@ -108,6 +108,25 @@ typedef struct BackgroundWorker =20 + + BGWORKER_INTERRUPTIBLE + + + BGWORKER_INTERRUPTIBLE + Requests termination of the background worker when its connected dat= abase is + dropped, renamed, moved to a different tablespace, or used as a temp= late for + CREATE DATABASE. Specifically, the postmaster sen= ds a + termination signal when any of these commands affect the worker's da= tabase: + DROP DATABASE, + ALTER DATABASE RENAME TO, + ALTER DATABASE SET TABLESPACE, or + CREATE DATABASE. + Requires both BGWORKER_SHMEM_ACCESS and + BGWORKER_BACKEND_DATABASE_CONNECTION. + + + + =20 --=20 2.51.0 --+i1iNwUgarm6ZeP0-- --eotPXKKGoGtulf0B Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmlbNyIACgkQnvQgOdby QH1WLw/+OcIDTgGvR1W0aap9mgUR/lYvjh5MfR5qF+Jw27QVzUiA80VWib5K7mTp Usu4y/UJtk1JcgwXoswVin83JoLN7yE38PMdnvZ6AcHRl2HhloEW/fKK6/QaVhmq GlzhR+rw0OJs25yG6F+pFrJXh2O9Dg284YjQMGxfF97YYLWOxaMwyruVgUBDQJiJ uTd3AFwC2pXOJ5OLTVNIyipLV0tVSp/xVIK4ZVdlzWIWnd2f4EJPAZRB6NJQKj93 lwM5Id9eiy0HRDAe1rgNnJuQGVaLJnjx91eLR0sGPZK4seAUtafdwHwFF12oud9/ 46ld2BY+CHcnJuttES/rui3wte+7h/1Fv0LMyLqdlwdKG8p5cvwZTToEOrDSnjES AIGX5d05/g0jlGl4lCq+dl/Pc5QOVjn0mPFS3i+YHHkLy50Nnqd5XJg27b5mLQxZ EBW4CLa/erZLgdNGjOB5QccmmlVbRuKnwzaQk6z58VtPZmwXQvcf3LRf9OVEhyQP HBCmGq1hFcn0cFh5b6WHgTHboAaZisDqd48B0Hi3GQWD9227A25me40k9LplUcyC W8+hcHyK+kMC83FhefjArKnKai3bnui79kfD3gINreJ28vU5M+yIPdWy40VhTFje IKDYTmdI80liTFgIxnhJqgF6Radgb3gKeahPhcmUYvIIrMfTWQs= =+nW8 -----END PGP SIGNATURE----- --eotPXKKGoGtulf0B--