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 1v72Th-00Dq3x-Kg for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Oct 2025 02:03:29 +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 1v72Tf-009VRg-9W for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Oct 2025 02:03:28 +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 1v72Te-009VRW-QO for pgsql-hackers@lists.postgresql.org; Fri, 10 Oct 2025 02:03:27 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v72Td-001L42-0K for pgsql-hackers@postgresql.org; Fri, 10 Oct 2025 02:03:27 +0000 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-b5579235200so1000576a12.3 for ; Thu, 09 Oct 2025 19:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760061802; x=1760666602; darn=postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=PCIaP6MzNuPZtRL4BX8VApJpxbr0/m40EnskQWqSU2A=; b=CXRalpntwjnUDZL+HvCep7xVqhGECre5Wlx/82dw2GY1lDqHjZ/cuZc7/iSiNeztge sK3lEukkZthSFnpk3l21zhRMPhna+6yIJigwxSIaDnesWRIlz5n5T9vDN9usZWa/AUdo sM19ohccn/51iqO+c1rlq5gI8MftTJYG2jE2O/sB6j2SJ16jI6SGciBOmakNr4sBjfTg ROuYnvgXrSA9XaDoemYMTdmHwHdP8cyMvNj0HZ65Jn9jNSixqK01xFFeIiccDrGPh1ti wf+VPzpRHSQjFoyJxbiVsjhMW87FAaYphcbri/DO/Xikf3d5CmjaOU1RHcPpZccFxP0j Kn7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760061802; x=1760666602; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PCIaP6MzNuPZtRL4BX8VApJpxbr0/m40EnskQWqSU2A=; b=O0d7JNBi8VryKpt1+IvJquEFZb3LHr73LRpeqJF0LN48Kik8LMBqNooQ3XliGXraF3 4dX2VJJv/OXDstZLsJH1XD+Vzg3mGq23hN0OGIAbHvRmLJlJgeOUUMnIGHCqLyiuFmsZ ap22MomocywpffcCzuRKb6X2jRbs5g01BZ45ujnjQMSX9FTGZcXfePeV6TxcUnM4///u vK+AMdv2e4gdOOk7blRhyc0ygFYsEJ5beCiobg1Yujt8PciVcp5FfYikvmnRgIiee8d8 qw7lt47SBdLiwx5VPAJecjxVRr7up5A4vR4kdrQl6uU483OZH/tJxtx2LVwrJvkl0FXE Uqiw== X-Forwarded-Encrypted: i=1; AJvYcCUdzfl7/GgFQmSxhpMMkmRmqzRtyLK9b6pimV9ANcbzhaWfyQmoraFCBxMSsc/YMY7nHlv3rk70xk2H4Vd7@postgresql.org X-Gm-Message-State: AOJu0Yw4iUOQrMdGd963Hb2UGytLZlqtz1dtiBtbXbEhYdpN1B/KGPbo OdoWzjiiWqLIvUM3X3knzGVJAZJ3xapIEfhQ0WiZo8BYqx910UngGmL4 X-Gm-Gg: ASbGncvw+lHf6AhQWLWCsaRcvHQ2kNJPsZTkm/5Kvw708JRZNmPkgF9MZVwMpz5zcGM qp874vvRmMx3GKh7rPZUeFo2WDP0Ci+jQchOaihr1bpV9fR+dps7bFtJ/W6RRZyoPNiDTOIv780 EgtMmDJDcmYKobC4Kj9naiUJwyLvPMOD8sZVpsKkKdBuoXqMQpmCOpqhx+rSmCv3IWYTglrWZbe F3xVUL/OPcVFEZXOnvj3EzfahBwN+yM4kucCZ+VyWnVvWnjI/8YTqlDZHGgCDgnUQTDjABSbA/h 7oSMBiGbNo6eSxhQ1wcj7K7p0z/afCdQ3Jn0IypFFGN1IlkWVh4otqQMZOhVzu/R0dYhRnFcwak 3zg3y1Kdxjl3XuIiUuNaNTFR2d0+i2u0J2d4x1mN+dansjaQXV/3oXCenNNabVAw= X-Google-Smtp-Source: AGHT+IE0wFhsznbwL++dTb9f1x738RJABbaXuKfy153eArTC04j83z0qprXwPKcDpirj/krC44UBFg== X-Received: by 2002:a17:903:1b30:b0:27e:ef27:1e47 with SMTP id d9443c01a7336-290272b553fmr120585075ad.31.1760061802404; Thu, 09 Oct 2025 19:03:22 -0700 (PDT) Received: from smtpclient.apple ([170.178.170.211]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29034de6c70sm41570525ad.13.2025.10.09.19.03.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Oct 2025 19:03:21 -0700 (PDT) From: Chao Li Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_8EB0A8EA-E987-4803-95BC-B2CDF60C1F4C" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE Date: Fri, 10 Oct 2025 10:03:06 +0800 In-Reply-To: Cc: "Hayato Kuroda (Fujitsu)" , Michael Paquier , Peter Smith , pgsql-hackers To: "Aya Iwata (Fujitsu)" References: X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_8EB0A8EA-E987-4803-95BC-B2CDF60C1F4C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi Iwata-san, A few comments: > On Oct 9, 2025, at 21:09, Aya Iwata (Fujitsu) = wrote: >=20 > Hi, >=20 > I updated the patch to v0005.=20 >=20 > Regards, > Aya Iwata > Fujitsu Limited > 1 - bgworker.sgml ``` + + BGWORKER_EXIT_AT_DATABASE_CHANGE + + + = BGWORKER_EXIT_AT_DATABASE_CHANGE= + Requests termination of the background worker when the database = it is + connected to undergoes significant changes. The postmaster will = send a + termination signal to the background worker when any of the = following + commands are executed: DROP DATABASE, + ALTER DATABASE RENAME TO, or + ALTER DATABASE SET TABLESPACE. + When CREATE DATABASE TEMPLATE command is = executed, + background workers which connected to target template database = are terminated. + If BGWORKER_SHMEM_ACCESS and + BGWORKER_BACKEND_DATABASE_CONNECTION are not = using, + nothing happens. + + + ``` This paragraph has several English problems: * =E2=80=9CUndergoes significant changes=E2=80=9D sounds vague, better = to say =E2=80=9Cis dropped, renamed or moved to a different = tablespace=E2=80=9D. * =E2=80=9CWhen CREATE DATABASE TEMPLATE command is executed=E2=80=9D - = missing articles. * =E2=80=9Cbackground workers which connected to target template = database=E2=80=9D - wrong tense/relative pronoun. * =E2=80=9Care not using=E2=80=9D should be =E2=80=9Care not used=E2=80=9D= or =E2=80=9Care not set=E2=80=9D Suggested revision: ``` = BGWORKER_EXIT_AT_DATABASE_CHANGE= Requests termination of the background worker when the database it is connected to is dropped, renamed, or moved to a different tablespace. In these cases, the postmaster will send a termination signal to the background worker when any of the following commands are executed: DROP DATABASE, ALTER DATABASE RENAME = TO, or ALTER DATABASE SET TABLESPACE. When a CREATE DATABASE ... TEMPLATE ... command is = executed, background workers connected to the template database used as the source = are also terminated. If neither BGWORKER_SHMEM_ACCESS nor BGWORKER_BACKEND_DATABASE_CONNECTION is set, this = action has no effect. ``` 2 - bgworker.h ``` +#define BGWORKER_EXIT_AT_DATABASE_CHANGE 0x0004 ``` You are using white-spaces between the macro name and value, that=E2=80=99= s why 0x0004 looks not aligned in my IDE. I think you should use a = couple tabs between them. 3 - bgworker.h ``` +extern void TerminateBackgroundWorkersByOid(Oid databaseId); ``` An OID can represent a lot of things. So, instead of suggesting the OID = type by parameter name, I wonder if it is better do that with the = function name, like TerminateBgWorkersByDbOid(Oid oid) 4 - procarray.c ``` + /* + * Terminate all background workers for this database, = if + * they had requested it = (BGWORKER_EXIT_AT_DATABASE_DROP) + */ + TerminateBackgroundWorkersByOid(databaseId); ``` I wonder if the correct parameter should be = BGWORKER_EXIT_AT_DATABASE_CHANGE in the comment, as you are adding = BGWORKER_EXIT_AT_DATABASE_CHANGE with this patch. 5 - bgworker.c ``` +/* + * Cancel background workers. + */ +void +TerminateBackgroundWorkersByOid(Oid databaseId) ``` I think the function name is more descriptive than the function comment. = So, please either remove function comment or enhance it. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_8EB0A8EA-E987-4803-95BC-B2CDF60C1F4C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Hi = Iwata-san,

A few comments:

On Oct 9, 2025, at 21:09, Aya Iwata (Fujitsu) = <iwata.aya@fujitsu.com> wrote:

Hi,

I updated the = patch to v0005.

Regards,
Aya Iwata
Fujitsu = Limited
<v0005-0001-Allow-backg= round-workers-to-be-terminated.patch>

1 - bgworker.sgml
```
+ =    <varlistentry>
+     = <term><literal>BGWORKER_EXIT_AT_DATABASE_CHANGE</literal>= ;</term>
+     <listitem>
+ =      <para>
+       = <indexterm><primary>BGWORKER_EXIT_AT_DATABASE_CHANGE</prima= ry></indexterm>
+       Requests = termination of the background worker when the database it is
+ =       connected to undergoes significant changes. The = postmaster will send a
+       termination = signal to the background worker when any of the following
+ =       commands are executed: <command>DROP = DATABASE</command>,
+       = <command>ALTER DATABASE RENAME TO</command>, or
+ =       <command>ALTER DATABASE SET = TABLESPACE</command>.
+       When = <command>CREATE DATABASE TEMPLATE</command> command is = executed,
+       background workers which = connected to target template database are terminated.
+   =     If <literal>BGWORKER_SHMEM_ACCESS</literal> = and
+       = <literal>BGWORKER_BACKEND_DATABASE_CONNECTION</literal> are = not using,
+       nothing happens.
+ =      </para>
+     = </listitem>
+   =  </varlistentry>
```

T= his paragraph has several English problems:

* = =E2=80=9CUndergoes significant changes=E2=80=9D sounds vague, better to = say =E2=80=9Cis dropped, renamed or moved to a different = tablespace=E2=80=9D.
* =E2=80=9CWhen CREATE DATABASE TEMPLATE = command is executed=E2=80=9D - missing articles.
* = =E2=80=9Cbackground workers which connected to target template = database=E2=80=9D - wrong tense/relative pronoun.
* =E2=80=9Care= not using=E2=80=9D should be =E2=80=9Care not used=E2=80=9D or =E2=80=9Ca= re not set=E2=80=9D

Suggested = revision:

```
<indexterm><= ;primary>BGWORKER_EXIT_AT_DATABASE_CHANGE</primary></indexterm= >
Requests termination of the background worker when the = database it is
connected to is dropped, renamed, or moved to a = different tablespace.
In these cases, the postmaster will send = a termination signal to the
background worker when any of the = following commands are executed:
<command>DROP = DATABASE</command>, <command>ALTER DATABASE RENAME = TO</command>,
or <command>ALTER DATABASE SET = TABLESPACE</command>.

When a = <command>CREATE DATABASE ... TEMPLATE ...</command> command = is executed,
background workers connected to the template = database used as the source are
also = terminated.

If neither = <literal>BGWORKER_SHMEM_ACCESS</literal> = nor
<literal>BGWORKER_BACKEND_DATABASE_CONNECTION</lite= ral> is set, this action
has no = effect.
```

2 - = bgworker.h
```
+#define = BGWORKER_EXIT_AT_DATABASE_CHANGE           =               = 0x0004
```

You are using white-spaces = between the macro name and value, that=E2=80=99s why 0x0004 looks not = aligned in my IDE. I think you should use a couple tabs between = them.

3 - = bgworker.h
```
+extern void = TerminateBackgroundWorkersByOid(Oid = databaseId);
```

An OID can = represent a lot of things. So, instead of suggesting the OID type by = parameter name, I wonder if it is better do that with the function name, = like TerminateBgWorkersByDbOid(Oid oid)

4 - = procarray.c
```
+ /*
+ = * Terminate all background workers for this database, = if
+ = * they had requested it = (BGWORKER_EXIT_AT_DATABASE_DROP)
+ */
+ = TerminateBackgroundWorkersByOid(databaseId);
```

I wonder if the correct parameter should be = BGWORKER_EXIT_AT_DATABASE_CHANGE in the comment, as you are adding = BGWORKER_EXIT_AT_DATABASE_CHANGE with this = patch.

5 - = bgworker.c
```
+/*
+ * Cancel = background workers.
+ = */
+void
+TerminateBackgroundWorkersByOid(Oid = databaseId)
```

I think the = function name is more descriptive than the function comment. So, please = either remove function comment or enhance it.

Best = regards,
--
Chao Li (Evan)
HighGo Software = Co., Ltd.
https://www.highgo.com/




= --Apple-Mail=_8EB0A8EA-E987-4803-95BC-B2CDF60C1F4C--