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 1va1Ut-002YZl-2n for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2025 00:52:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1va1Us-00Eg5Q-1H for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2025 00:52:31 +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 1va1Ur-00Eg5H-1Q for pgsql-hackers@lists.postgresql.org; Mon, 29 Dec 2025 00:52:30 +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 1va1Uq-00364r-1v for pgsql-hackers@postgresql.org; Mon, 29 Dec 2025 00:52:29 +0000 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id 2C0B5140002F; Sun, 28 Dec 2025 19:52:27 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Sun, 28 Dec 2025 19:52:27 -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=1766969547; x=1767055947; bh=XXR9s5O8g3 gNgWXsBqmNXgUFLNQQv6hcRRfxFmlPT8c=; b=c2ArWtfE6WCV77+T3vrkTRgIZK 5KAaouPeg03jiIvcZ+bqYrjzjuWV8erYUfhlvLKy8Y0M4VeWfHC75lveyieNoHJJ NWd1MlNbK90du494YzXrESeJNyEVif/AhqCIFtoLuaON0Zx06RLiTQwg5j4aOtTc gNDnlSKwEL436KtHxfrkOFjkxgtya7/JFXG43wN0Y+rt1i246gLJQVq7hVZgx4Tk oWwtSGkO//LmRRiHoYNszZBWbntiLSgD9a3zhuyPQPSEzp3AZak85WZ5/0BdhGzb h2buRlMcj/uYTr4r0wLCB+2lrIWWtSN9fmp938Madm5WkA0DDLtC9GPK0HTw== 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= 1766969547; x=1767055947; bh=XXR9s5O8g3gNgWXsBqmNXgUFLNQQv6hcRRf xFmlPT8c=; b=hmp8zR9dHWLd4a6bpQ57aHAN3q4XHcnv76WoGMi/sLWu0rx1dQa RLi4v7/XATcc6bbc0Ps9ZGYY6OMvhpN9ttmk6MzEOrAxDNbQG6fF814x4BA/Q4JZ hzeg0he2VezIOiJQ8l05yq3c2c1VtTDvNd9JpecmDKMcytRk1nRbYD+e0X9P4hHH 3AqSnrz/n03ZhiiZIajfUlRKNJTHLYWlX7GzHceof5DqOkmwszpO1B9qEHLzm10T Rs40Oh7YqU6gTycK5dz3+kfJb61xnQNtDL2Oit0+o/6uCMAYwecglv817W9w59wa d+ESXJtH9Fx/0QK/Wi2hXZgxkkZGXtZRtGQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdejheejhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehprghvvg hlrdhsthgvhhhulhgvsehgmhgrihhlrdgtohhmpdhrtghpthhtohepmhgrthhsuhhmuhhr rgdrrhihohesfhhujhhithhsuhdrtghomhdprhgtphhtthhopehifigrthgrrdgrhigrse hfuhhjihhtshhurdgtohhmpdhrtghpthhtohepshhmihhthhhpsgdvvdehtdesghhmrghi lhdrtghomhdprhgtphhtthhopehlihdrvghvrghnrdgthhgrohesghhmrghilhdrtghomh dprhgtphhtthhopehkuhhrohgurgdrhhgrhigrthhosehfuhhjihhtshhurdgtohhmpdhr tghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 28 Dec 2025 19:52:24 -0500 (EST) Date: Mon, 29 Dec 2025 09:52:07 +0900 From: Michael Paquier To: Pavel Stehule Cc: "Ryo Matsumura (Fujitsu)" , "Aya Iwata (Fujitsu)" , 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="/YPpcdT7OzpSi0QS" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --/YPpcdT7OzpSi0QS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Dec 26, 2025 at 12:04:47PM +0100, Pavel Stehule wrote: > I am not sure if I understand what you prefer. Seems to me that Iwata-san sides with compatibility. Spoiler alert: I do side with compatibility. See below for more details. > 1. When bgworker is marked as INTERRUPTIBLE, then can be cancelled > immediately - there is full agreement - I don't see any problem - just > probably almost all bgworkers will be not be marked as INTERRUPTIBLE Yes, these can and should be stopped. > 2. When bgworker is not marked as INTERRUPTIBLE, then can it be cancelled? > How dangerous is this? If it cannot be cancelled, then ALTER should wait on > lock forever, or there should be some special timeout - like CREATE, DROP > DATABASE and waiting on template databases. Cancellation is a different thing. bgworkers can be tweaked to answer to specific signals with their own handlers. What we are discussing here is if a signal should be sent to a bgworker or not when performing specific operations. > 3. If the user needs to execute ALTER, then probably he manually terminates > the worker any time. Are currently used workers safe against terminating? > We know so mostly workers will be restarted after timeout - and then it is > "safe". It is really safe? Can we expect it? If it is safe, then we can > implement FORCE clause. Probably any worker can be restarted - and without > safety it is hard to imagine using in the production. That would be up to an extension developer. The new behavior can be useful in some cases. Forcing it by default could lead to unwanted results. > I think there is a fundamental question that should be solved before - what > is a risk of canceling bgworker? The possible reply is so there is not any > risk for correctly implemented bgworkers. And then there is a question if > we still need the flag INTERRUPTIBLE? My opinion for this case is probably > yes, because cancelling can introduce some bigger latency. I can think about two reasons at the top of my mind, at least: 1) Making the background workers non-interruptible is the default behavior that we have since 9.3. Changing the default by allowin these to be interrupted could lead to a silent behavior change that extension developers are not aware of because the bgworker lubrary code would still be compiled as-is, and would still be able to start correctly. This links to my second point. 2) Operator error, and these tend to happen a lot. Somebody with the right to create a database could decide to use as template a database that a bgworker is linked to, leading to failures with operations background workers expect to be able to achieve while online if we change the default, because it does things that are critical and should not be interrupted (one could compare that to what an autovacuum worker does with an antiwraparound work, perhaps, which cannot be interrupted). As a whole, I think that we have more advantages in keeping the default, making the possibility to make a bgworker interruptible an opt-in choice is extra cream that can be added on top of a cake, and one is free to add the extra cream to their portion of the cake. -- Michael --/YPpcdT7OzpSi0QS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmlR0LcACgkQnvQgOdby QH2vkg//Vi2cNR9smhtqJvh3jeOpJErN+UuIMcm+WVGqv4qEVq6zWIl7NZTibJU0 UMYaIEIl2hoRHqRKHw+Z6Dpk1YD0ymoOi61ggKUY0viznzIrMYp5AVyGp1mdd4NV JSUd+uFKyYDmr8TcyyKjS4VbDdyjvUdEbuDtOBx92emspqcK/NnJ83l0X3d+VMvA vdFj1x2rkB/cAqQNu1wU+zYKCvOQyR4kIroO325OjH12mSUkvdhKuKKDmXDMKGij Tyh2Wy36dGdOBKnfB4uTO2d2bsRgyNRRBjmNn4FvIYnEtdE7e7BbFjtFn3I4zbvm f9LY9aYW4Hk01zjFiTl48Z9XBf7i9ccMiw6yNAQj6/TzJ1hjWT2Di/AVJ23VMVgs FB3wEf5Eg9EO16Oh6VG3+SVNB4qqPK8MMQwOryZbml7YhwG7f21bYyUWFuvEEGij 8lv398FkU7qH1pnBWWyHDvr44AEcbQau3Qpm7OR2FQtGupmbgqUarhaI8S5GpXKN sn/qKS9MOYlh6SXRaPwqXX4dwudrA/hGDrf1WpuOt+AZ7Fc4nKxnGc6dDi/Aiu8F upDrp1Bi/jfcm8Pv1Fubr8NtBFvBnUghxdtH/LS26q8YmqkXSBWpjyex7SH0iuse /ozZ1sRP0ySF3g5Z/Ek3ol22UjKzCiohIc9iCZyFOmAGmWTbRwg= =IuB1 -----END PGP SIGNATURE----- --/YPpcdT7OzpSi0QS--