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 1va5rE-003UbS-0b for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2025 05:31:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1va5rD-00FXaF-0I for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2025 05:31:51 +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 1va5rC-00FXa6-27 for pgsql-hackers@lists.postgresql.org; Mon, 29 Dec 2025 05:31:51 +0000 Received: from mail-yx1-xb133.google.com ([2607:f8b0:4864:20::b133]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1va5rB-00383Y-2O for pgsql-hackers@postgresql.org; Mon, 29 Dec 2025 05:31:50 +0000 Received: by mail-yx1-xb133.google.com with SMTP id 956f58d0204a3-6468f0d5b1cso4130888d50.1 for ; Sun, 28 Dec 2025 21:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766986309; x=1767591109; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=S2XWdORKUV/As4ev0oW5dlg10ApSfak/3t+Dr7d9JXg=; b=Lc1o9EQrbJpwTEILpFHdK4w33lSgpZH/deLLOsqnxa/wdlVtc4XB8wcRmSry+2t8DM xPZiCDmWinPR1GtFDu+KJs2tsnOhW75Z5TnPVReZF6OfuOcy53a0BzJ8FAGwL/rwHIqC yPfuu7M2FCrcuapGflyMs/2Z4kptdLNWlbWHyEPN9fPQ015uf8LwZyb5rdswCQ815t4U TEkEIpEfRCamHkGgE65mVahWLi8D1ivRQx0zc6KsWYpxli4Nvm6Bwn+bTSj6f9rTI9xh dcHYdyNA+s/nI1/Gsc7FTl4gyG2LTL2L04OSfVobejbxkMO732SnEJ0stjjz6z5SFajn 2nww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766986309; x=1767591109; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=S2XWdORKUV/As4ev0oW5dlg10ApSfak/3t+Dr7d9JXg=; b=n2xWWg3/h7hdY9BSv6zZ/AaOsXYoOYCKaA0+Oh6TtxL26W32S1kiO14KuON2+YsiW5 nveqEEJbz7BUdAf+eX0ksGBoOIbIy5ke6OCv2pcZdx6D9OrRKNDgOH/HvLGXwXBu/Zrr oKsDx3rwAeZHMlc1kTkwTDEyzS/tOQePTt2qoPKjIr55SE340vNmGQHVmJMn3cZHX86z Ahf9DNFug9jDR4N8dcbxKlJTLeymIESaXXb5mgzSvGJvLqxCqDi2xCIYAZ+kRzlhM255 WxepXtAO6eTdYb05Sb1oolWIQSWYCu0UNRV95JTa0TqGlR38Eq22fdac77yyavLPCQfP SFOw== X-Forwarded-Encrypted: i=1; AJvYcCWSsV6fjR3D2nOrFxyIGdggNYUgU2jz1zUyQab6AE3DVWL0zpGswc3AGlzmucAeyyHtC50mDAUZir3sp9pN@postgresql.org X-Gm-Message-State: AOJu0YwmIxS+Gnvw5pSYxSuVzQbC6aEI3wKfOTuv4SFwCdrtP+Y59jKn +7N0DRMuNu6UYsQjYRWKH3sJpRy20IvouWOr0lVwjxhnw6eyZoDDgh7xDZ57ZVBa3fI4AFiV1pd g3u7el9Pmi9PXrpRFplbWPerbNPjgwag= X-Gm-Gg: AY/fxX48X34AHCVGhiA0YTKJ5I9dLsGye2nR2oggd0038vZSdOHkrTawDJBiqzlWBIW khjpSRdhHPOeRhnIQI76tEMbQ2Jnjfx42FbBX9zAh9bUCiN2kmzRxKoc9bA5+TiXNKO4ZW0edA7 USuF8EztFbF5FB6uh2jlAFRcnDh0IIv/zmDDc/1s3pWLBN5t5Mmbv+3WCUP073fDgHsjctE/ONY nyvkzmKj5c09Tp5Qw+MxeCKx+B424KP7MhqK+k/BRQLq1bBa1LlggiOGTGQgVWbx9kKQLDhgL93 IdaZx5jvBO894/I9ubK/0l3Y4nrkGz4LELEmrABRXjhjdCfWGPSYq/hmetIwk+P2L+nd8K3+8iR ZDdAB+cSit/4sZQ== X-Google-Smtp-Source: AGHT+IFTZRdxPfJ51DAQxCeDcqlInAQ0+D+Ymv6IrLGXd0+uSRhpL97jnb8ln5oO/FmGX/k5l9T/eWtrFXgV3oWWwtM= X-Received: by 2002:a53:e317:0:b0:641:ffaa:4eda with SMTP id 956f58d0204a3-6466a913790mr19831963d50.74.1766986308705; Sun, 28 Dec 2025 21:31:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Stehule Date: Mon, 29 Dec 2025 06:31:11 +0100 X-Gm-Features: AQt7F2oD-MiNSGLiL-YTXquJo8ON-vWJbyHvGVCuOl9hdhGcX6HmbZZD99BmnqU Message-ID: Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE To: Michael Paquier Cc: "Ryo Matsumura (Fujitsu)" , "Aya Iwata (Fujitsu)" , Peter Smith , Chao Li , "Hayato Kuroda (Fujitsu)" , pgsql-hackers Content-Type: multipart/alternative; boundary="00000000000040e31e0647108f92" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000040e31e0647108f92 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi po 29. 12. 2025 v 1:52 odes=C3=ADlatel Michael Paquier napsal: > 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 wai= t > on > > lock forever, or there should be some special timeout - like CREATE, DR= OP > > 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 terminatin= g? > > 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 ca= n > > 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. > ok Regards Pavel > -- > Michael > --00000000000040e31e0647108f92 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

po 29. 12. 2025 v=C2=A01:52 o= des=C3=ADlatel Michael Paquier <m= ichael@paquier.xyz> napsal:
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.=C2=A0 Spoiler alert: I=
do side with compatibility.=C2=A0 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.=C2=A0 When bgworker is not marked as INTERRUPTIBLE, then can it be = cancelled?
> How dangerous is this? If it cannot be cancelled, then ALTER should wa= it on
> lock forever, or there should be some special timeout - like CREATE, D= ROP
> DATABASE and waiting on template databases.

Cancellation is a different thing.=C2=A0 bgworkers can be tweaked to answer=
to specific signals with their own handlers.=C2=A0 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 termi= nates
> the worker any time. Are currently used workers safe against terminati= ng?
> We know so mostly workers will be restarted after timeout - and then i= t is
> "safe".=C2=A0 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 wit= hout
> safety it is hard to imagine using in the production.

That would be up to an extension developer.=C2=A0 The new behavior can be useful in some cases.=C2=A0 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 prob= ably
> 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.=C2=A0 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.=C2=A0 This links to my second point.
2) Operator error, and these tend to happen a lot.=C2=A0 Somebody with the<= br> 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.

ok

Regards
Pavel
=C2=A0
--
Michael
--00000000000040e31e0647108f92--