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 1va2c9-002o4x-2W for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2025 02:04:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1va2c7-00F3CP-1r for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2025 02:04:04 +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 1va2c6-00F3CH-2R for pgsql-hackers@lists.postgresql.org; Mon, 29 Dec 2025 02:04:04 +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 1va2c5-0036YC-2i for pgsql-hackers@postgresql.org; Mon, 29 Dec 2025 02:04:02 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 0693C1400062; Sun, 28 Dec 2025 21:04:00 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Sun, 28 Dec 2025 21:04:00 -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=1766973840; x=1767060240; bh=rslDa+m+Cz /rdW6jsqWDbn720wHmXK79YyW8eOf6Ukk=; b=fa/bUdH+LRBaKOmMDQpLndUqsR A9OTaTzroQStcgs43TavgBmX8zuFo/M6sjLkndCf4SJ7GiwVq7rA/ugHlnR2Y3gC 17jI1VVDUCoOQDoKD7MUWAnGiIfARA71z+lmIeJ782Ej8AN6bi8kd2U1hQbJZ+lD 6vFUpqPbi1RhyCplZJM3CfTwNf+KwBixK61GP7iaNpMYXrhP3roZQc7Tnp4UEK77 MW5HBdyGPZL5lDEwC6z7vESxNuVacIsUsKv2xDVhsNo0gk+nl/lubdD1uuK5K1Ku 1tAYNGwjWp35Xt0QICNLz/F0QHQANvHyarc4la573au7hGdczPPRnlBOdGBw== 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= 1766973840; x=1767060240; bh=rslDa+m+Cz/rdW6jsqWDbn720wHmXK79YyW 8eOf6Ukk=; b=DUwX0fw4sVb2IT8+vmCiihNDBwc93/UWEIwsBFsyTt3mmmTayX4 eFwqVZuSqsVt/Cyjs5T0KC0fU6m1Aaa/elhEYrKE2Ml3seZu4sUKP3WTdHhY80Cq v1ZkhwkX7+yM/+bd8iauzETQXfPSx+xJBqTvfXVAVJtnfElGpHJce/FNGiqYTenp hEq+1OmneaiOrm6I8aCKjUEIMLnnH7cWxelqX51FOS39CBD/9Nq8mhLceWCLt924 ZhpO3mrSl6kU1ogXfwQv325MUYe0bAx35RyqbTAV94RnZyg0/1eZu6w0QV9juP0r 4v1/fG8FgMGWpaBHyIP+i/OLetmIqiZpTCQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdejheeklecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehmrghtsh humhhurhgrrdhrhihosehfuhhjihhtshhurdgtohhmpdhrtghpthhtohepihifrghtrgdr rgihrgesfhhujhhithhsuhdrtghomhdprhgtphhtthhopehprghvvghlrdhsthgvhhhulh gvsehgmhgrihhlrdgtohhmpdhrtghpthhtohepshhmihhthhhpsgdvvdehtdesghhmrghi lhdrtghomhdprhgtphhtthhopehlihdrvghvrghnrdgthhgrohesghhmrghilhdrtghomh dprhgtphhtthhopehkuhhrohgurgdrhhgrhigrthhosehfuhhjihhtshhurdgtohhmpdhr tghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 28 Dec 2025 21:03:57 -0500 (EST) Date: Mon, 29 Dec 2025 11:03:39 +0900 From: Michael Paquier To: "Ryo Matsumura (Fujitsu)" Cc: "Aya Iwata (Fujitsu)" , 'Pavel Stehule' , Peter Smith , 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="neA8os+yp0GAmUQd" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --neA8os+yp0GAmUQd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 26, 2025 at 10:17:27AM +0000, Ryo Matsumura (Fujitsu) wrote: > +1 to Allow-background-workers-to-be-terminated >=20 > The result is same, so I think it's better to prioritize compatibility. >=20 > PGWORKER_PROTECTED would be used in scenarios like the following: > Existing features are probably not designed to be forcibly stopped. > Therefore, all existing features should have PROTECTED applied to them. > Most newly implemented features will also have PROTECTED applied because = it requires less thought and is safer. > Only considerate developers of features that can easily guarantee safety = would adopt the default. We could design things so as we have a second flag to force a bgworker to be non-interuptible, then we could force that either the interruptible flag or the non-interruptible flag should be set. What is mentioned as a problem is that 0 implies that the non-interruptible is enforced. I don't think that we would have much to gain by doing that, as it would just lead to extension breakages that we can avoid. > In conclusion, this is no different from BGWORKER_INTERRUPTABLE. > Therefore, I think it's better to prioritize compatibility. Looking finally at the patch, I like the simplicity of what you are doing here. + Requires both BGWORKER_SHMEM_ACCESS and + BGWORKER_BACKEND_DATABASE_CONNECTION. SanityCheckBackgroundWorker() does not enforce this check when registering a bgworker. But shouldn't we do so when the interruptible flag is set? +void +TerminateInterruptableBgWorkersByDbOid(Oid databaseId) Fine by me to aim for simplicity with this interface, discarding my previous fancy comment about the extensibility we could do here. Matsumura-san and I have also discussed a bit that offline at the last JPUG, where I said that I'm OK with simpler at the end. One issue with the test as written, as of run_db_command(), is that we make sure that a worker is stopped by scanning the output of the logs. This approach may detect incorrect patterns, unfortunately. For example, if the termination logic has a bug it may be possible that the worker found as terminated is the first one created by the test, which we expect to always run. While the log is mandatory to have, I have a suggestion to make that even better: let's keep track in run_db_command() of the PIDs of the worker processes we expect to exist after running each database command, then make sure that the list of PIDs match with what we expect. This is a bit simpler in the case of this test as we only expect one matching PID. -- Michael --neA8os+yp0GAmUQd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmlR4XsACgkQnvQgOdby QH3rhg/9HTmEfVlHGBq1UlX0tEIOBOBWqj96edwbILTPiCmH1Ekp1Cl46KNeEnxi NNwDGCdaRSJyuh1yNuW1U2dQJTF8tjYDUqkFbhWrH0DkV3c4rWwES4f7RYLB0IhQ 9ynt/+8PgsDDUDD/5rSQV2zQtrRlYOrbDw17JF+CcLWzoH5NGr8tbEz+ngPlWKnF 34YGt+L+9Orr6wmdk/rBwr1QfRYBzo8kEB2vaL+8NiPYF0l2iXqn+9eeJiktYMNL I0XXBQld0l3O6uRMWQcOr77hO7nMDSsezxC1kakVfzdQ0YtYDU3hcT0NYy5hYirI kFf7HmEjb3lD3ymOOf7CAt9x2zBhiGSnEbOEK7Lmf5Wi6nhM+JjL1/hV24p9W32R WWDSh6Bwzzw3Fp1IpYXTCi5ElvPhlEReX7CgOfADi2/MTotL491M6Yrtoo+LDNGU KDD4RDRX3emhG/DZeef5/sShSCfAWS2C0NyHAll/Iu77lXUXNHaP6AVQG/gDAbeD tWQgRpf2SJPlQFvX8SumXG0vO6zym+W7bkn6vXZly0LpSrIl5JJWPs0ac+DeiGwl 4fQH26Vq/qjDpX1y/EadAy1swOHR5nMdR0mAX1N2vWwoSRjAkXx+WK/kuff9GwzD oNH29omiOUeShmzo3DZVrJXVvROl9TDK/I0ezUeKqZCxGYyyqG0= =geMu -----END PGP SIGNATURE----- --neA8os+yp0GAmUQd--