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.94.2) (envelope-from ) id 1v5bji-009Fwy-Vb for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Oct 2025 03:18:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v5bjf-004YNo-Ek for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Oct 2025 03:18:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v5bjf-004YNa-4k for pgsql-hackers@lists.postgresql.org; Mon, 06 Oct 2025 03:18:04 +0000 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v5bjd-000bb8-2h for pgsql-hackers@postgresql.org; Mon, 06 Oct 2025 03:18:03 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 83FB7EC00BE; Sun, 5 Oct 2025 23:18:00 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Sun, 05 Oct 2025 23:18:00 -0400 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=1759720680; x=1759807080; bh=/869qt0D1g BsFTk0WowbV1w4S7EZ/Vp8osjX7PQWv0k=; b=daX1aNbWgpI2znhI0XCBaMnvjL z/e8Mo/qvO0oQQC0H2l4HdDaR2tfPvdNHGw9er14ekum37Pjl/2WONQv6FxXV6Cw +s8ten70pWIPNrQgzDWy1y0mcSLnUtqje+wFA2hckOh0feZUvIkoDJ6+ve7VW5k6 S/MJms9QAlq98QiiQBIyZ0n8krXdoXIZv7b5ZQQVJY2NXcQTTwo5T+qaxPU5Wv/T JJKVpKg0BWt3qDUNm8pxjoF/tWJYT8zJJn1Esih1xu0HEZ1fhXzcGIK0Q1FYzhAm SLRg7VsXuJsE74XcYRR2TS6n21GSmtT4NdXjdYX34UjR7opGWsR56MzEXL/g== 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= 1759720680; x=1759807080; bh=/869qt0D1gBsFTk0WowbV1w4S7EZ/Vp8osj X7PQWv0k=; b=A0sqlZniHTNUJ+3NJV3BMlIidd7UCo7n7G8bcBBshteihn0U2VB 29n7K2EZCDJi6i6iiSE15DIfkxABjS3yIF4GKjIn3I3fqandEYzpksqTUr2T1d0f m5fGURBoA13FKEhbQN/2xr3MDKSTzbwi+pRPvG1jZIpPA6PEryoA0jdm4j70PHoJ Iw6tsb8ijrx5IQXunIO6Qsjrmu+KLNzlFa5PIOTtZVDreFHsmaLwehdwm6AxRivx 1854ElQEPE81Q/qgOwFevU+NrGK37UyR3lE8jedLCfpnQkIxbrPzXMfjySAsJj+f +nX1mu9nQFbOYpoTV0wT7yLSMRgVW69R1KQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdelieeggecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehkuhhroh gurgdrhhgrhigrthhosehfuhhjihhtshhurdgtohhmpdhrtghpthhtohepihifrghtrgdr rgihrgesfhhujhhithhsuhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrh hssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 5 Oct 2025 23:17:58 -0400 (EDT) Date: Mon, 6 Oct 2025 12:17:46 +0900 From: Michael Paquier To: "Hayato Kuroda (Fujitsu)" Cc: "Aya Iwata (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="mSIJ+Llf+HQSShsf" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --mSIJ+Llf+HQSShsf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Oct 06, 2025 at 01:59:08AM +0000, Hayato Kuroda (Fujitsu) wrote: > Per my understanding, we already have a facility that terminates a backgr= ound > worker, TerminateBackgroundWorker(). So, I'm afraid your proposal has alr= eady > been done by combining this function and ProcessUtility_hook. The main take that I am getting here from Iwata-san is that this would lead to less code duplication. Another item, which you are not mentioning, is that this would be more flexible with bgworkers that have been starting dynamically, where shared_preload_libraries may not be used, still a bgworker would need to react. So the suggestion of a new API to control if a bgworker should be stopped like any other backend when there is a database activity worth it is a good one, as long as it is in line with what we do with normal backends. AcceptBackgroundWorkerCancel() is going backwards, IMO. Wouldn't it be better to pass it down as an option in bgw_flags, to mark that a bgworker connected to a database can be shutdown due to the effect of a database getting dropped or moved? There could be an argument behind using bgw_extra, but that would not be in line with the database connection argument which is a state defined when a bgworker is registered. > So, is the main benefit of the patch to shorten extensions codes which us= es > bgworker? I'd ask for the addition of tests when it comes to such a facility, and your proposal has none of that. I would suggest worker_spi with an option that can be passed to worker_spi_launch().=20 -- Michael --mSIJ+Llf+HQSShsf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmjjNNoACgkQnvQgOdby QH2jCQ/+L9YWVpC+MZoGTIvRoFf5oh7d330HCdibTmeN52fIY8MX/PLPoavCU7U6 85P4tdsXUJoTgk3ssdgtd7ZSSiTgWPwghZQTEHJ0GOT2tWll+0rbkoTCqscjuGJp MTUpXLNZyiS01yVSuV8Ft4pcUUKi6nGxkajNlmPOUrgEDd2CVIZuynQzPMANJ6Ko jnHJfQzowg9xVXLWinSjU/GiFoSfYOhg6XVfmpK1QBuc6EbH7D4Yvd9FVrKWnthf 2RuZ17ANeb0GI+dnqLgvAfrUprERFru3gG8VlXPMw1MLmcYi4Lmq52SpHtRbgl5l 4bLJSRASM1OKYsoHiNTFUxo5XNYdCHdQwRBLjkDo99oIiJZf6kGxJVmu+Wc6rlqE ahNB5Re9LBIpTb55yC1zQxjxxBbuh0zidyFvSebVemIKS4UvFEpmWSvhPGyw6ks2 uQEQlYhHOSK1mDHbCC9DcM1BYRqgPCFb+JpdJlPqAn9svfuGMeQ7quS0Rg4vA7nS n6lxI42a09M68ob2YIPUnwVhISFyv3y7ke3VNZj2+ri4XXX+iLB0gfEg0qOr3kab PARO4/gADCXBn/JxNA+67y+VgbiKz3fAN173U+pS5D8USDkW2WfkN+k99UWdKz2D dLiOdg76ijusmS3DsR/Pssnwr5Xr1OYxbl8X8r6jgzTYrzDZVMw= =Pgj5 -----END PGP SIGNATURE----- --mSIJ+Llf+HQSShsf--