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 1vV8Tc-00E0RF-0n for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Dec 2025 13:19:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vV8Tb-000UJD-0f for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Dec 2025 13:18:59 +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 1vV8Ta-000UJ5-2S for pgsql-hackers@lists.postgresql.org; Mon, 15 Dec 2025 13:18:59 +0000 Received: from mail-yw1-x112a.google.com ([2607:f8b0:4864:20::112a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vV8TZ-000nCA-2p for pgsql-hackers@postgresql.org; Mon, 15 Dec 2025 13:18:58 +0000 Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-78c5b5c1eccso44942337b3.1 for ; Mon, 15 Dec 2025 05:18:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765804736; x=1766409536; 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=av9sITX7DWSeRzAW1qSNY6t0q37s8DXLfqk1ubOsHmk=; b=aYuxoGokLMKydaD7s8bziSSUMIz48kLqpZs9cnasgBDlbpWjVyeYfB7tigzeOgArAz VLRtE/BgebXarKpsxZRHf7xdptSeoflduc2zHYXZxTfLpKG6wl57BHDEo1hmwiQQR2q5 KiDx0rRW5CLisErmR/xM4TfNd4rATeiktdh8HoQwxpBVp4JcWXBjm0VxiHuqsenHQBwr /EbIyPFnjfNNVTIIQxJ9eX8zBUzdGSxApD7g7CBmxZpUd/t25pJGoiWJwjxnqwWaL74a JpsJtr6ff883tnFSgYtp7CKdhLpHCnQBxyRyo8HtimpBz8baHvGA1K4ug9ro61bw/BuZ CHIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765804736; x=1766409536; 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=av9sITX7DWSeRzAW1qSNY6t0q37s8DXLfqk1ubOsHmk=; b=VulJWroy8yzCQuqip6W0zxQP4M9uQLAg63HUh4WRgawm+dUszPgBlvkuh2LDSs9j0P YRbzAqiV5vHrvmw5lFYbvKltTgpbqUADR92AUaiKQG0RVMeOzRXWrUniSVMwBk2d1SI+ Rvb1/yQ6x2Qa2pCAU9DfU8cakpQzN+nrJHlgKXeBlOEpMppi/2rZMKZzOqojmud+zvy+ 6IDp3i7mAzy6sTmpmTyxvxBpZUAgnWd0VW28i0ZxH5Lpwquga9e2bbDb2n/lczuv4ofb /lLdhQXg427PtjQcDOfIG6f82HK/748U/OBCFuCyBaFKObaNb8pO+IBbQuInm8UwLoiQ 1cTw== X-Forwarded-Encrypted: i=1; AJvYcCUJV8f6J9i6HEoV1+5W7MdtgSgmG/EIj9pcq03h7lb4O1MARPPC+X9NeSeICnFfRLB1u/m0Lhc3PwJAZqFa@postgresql.org X-Gm-Message-State: AOJu0YxJ8Odp2JCIBgVOmQES3ZtCYltfA19G4miNApugAb43Q9PGLdpb lf2LgTfZl6l1uXapOLinLApMQ0OFqnCfdDz29k2aNhCKVxCKg91o8PjxsUeU0kXYIisE1SyE2ND Izosi2PLFu0Evt3RAn6k02erf8IYyz4o= X-Gm-Gg: AY/fxX5IyjmWwZYoK3rZSFDCNKzeeVIQ2vxbpTZBNxbKldcJU/VyTVtVQsR7u9xOt24 oMjaiCH45fbGrH7S8kIYG6gQzg834g7Ot4ysIxgmRnVLEHMFuLSqEU6Dla2US+ysg5coFbz3vz1 ow4am1/02N8Yg0d9Jq+BVBHWlWOhOzJIhVQ8kE3MwDuzwKJ1vrAR12ge5Qyj2CGKYMUaDfHE4xM 73/aD2EJ49w5SNV8isgPegtG5NKCbP/Uog6A6fs7tWlE8L0J65Cm4JF1IJ2dNoJqf88jDEEgw+I lnsQ+SUKJcqtB7AatkfnXoC4Q50b8E8xnAy2sbxOU5KEifrQMfPMxr6xwIpIbPJDdpctBcacqGB 66ja16g/U16yawsyCt62KA3+C X-Google-Smtp-Source: AGHT+IH79qwhUzIHVqGZmFvbOzyiuNuJFZ10kQj6bVL/LDs0lmVnfERoTYUdzrwRzYAVTnzJYWr79iE3qMDNlTAroSg= X-Received: by 2002:a05:690c:9c0c:b0:786:5d0a:c273 with SMTP id 00721157ae682-78d6df9f942mr106149287b3.23.1765804736499; Mon, 15 Dec 2025 05:18:56 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Stehule Date: Mon, 15 Dec 2025 14:18:19 +0100 X-Gm-Features: AQt7F2ph8JcDQv-E514L-E3OrITMy3UmmtHclqJKVzaRzIw6cAcNmbNyeAh5nuk Message-ID: Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE To: "Aya Iwata (Fujitsu)" Cc: Michael Paquier , Peter Smith , Chao Li , "Hayato Kuroda (Fujitsu)" , pgsql-hackers Content-Type: multipart/alternative; boundary="0000000000000fd6200645fd74ba" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000fd6200645fd74ba Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable po 15. 12. 2025 v 13:56 odes=C3=ADlatel Aya Iwata (Fujitsu) < iwata.aya@fujitsu.com> napsal: > Hi > > Thank you for your review. > > > From: Pavel Stehule > > Sent: Sunday, December 14, 2025 4:40 PM > > To: Michael Paquier > > Cc: Iwata, Aya/=E5=B2=A9=E7=94=B0 =E5=BD=A9 ; Pe= ter Smith < > smithpb2250@gmail.com>; Chao Li ; Kuroda, > Hayato/=E9=BB=92=E7=94=B0 =E9=9A=BC=E4=BA=BA ;= pgsql-hackers < > pgsql-hackers@postgresql.org> > > Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DRO= P > DATABASE > > > > +#define BGWORKER_EXIT_AT_DATABASE_CHANGE 0x0004 > > > > I am checking this patch, and I think so used names can be little bit > confusing > > > > BGWORKER_EXIT_AT_DATABASE_CHANGE - it is used for disconnecting workers > on the template database, and this database is not changing. > > > > TerminateBgWorkersByDbOid - it doesn't terminate all workers, but only > workers with some special flags > > > > Maybe BGWORKER_INTERRUPTABLE and TerminateInterruptableBgWorkersByDbOid= ? > > Thank you for your advice. > I changed the name of a function and a flag. > > > Another question is if this cancellation should be implicit and should > not require some special flag. > > > > When I want to disconnect connections to database when I do drop, I hav= e > to use FORCE flag > > > > So maybe there should be ALTER DATABASE ... RENAME ... FORCE - or if > FORCE can terminare all workers (without special FLAG) ? > > For the proposed feature, we've added a flag allowing each extension > developer to decide whether to terminate it via DROP/ALTER DATABASE. > Adding a FORCE option to ALTER to let database definition modifiers decid= e > whether to force termination of background workers might be better > discussed in a separate thread. > When I thought about it - there can be a second alternative. Introduce a pair of flags BGWORKER_INTERRUPTABLE and BGWORKER_PROTECTED (the names can be enhanced or changed). BGWORKER_INTERRUPTABLE can be default. ALTER DATABASE RENAME and related commands can stop any non protected workers. ALTER DATABASE RENAME FORCE can stop any workers (including protected). Is there any reason why BGWORKER_INTERRUPTABLE cannot be default? Probably nobody would block some possibly common operations on database level without strong reason. Regards Pavel > Best Regards, > Aya Iwata > --0000000000000fd6200645fd74ba Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


po 15. 12. 2025= v=C2=A013:56 odes=C3=ADlatel Aya Iwata (Fujitsu) <iwata.aya@fujitsu.com> napsal:
Hi

Thank you for your review.

> From: Pavel Stehule <pavel.stehule@gmail.com>
> Sent: Sunday, December 14, 2025 4:40 PM
> To: Michael Paquier <michael@paquier.xyz>
> Cc: Iwata, Aya/=E5=B2=A9=E7=94=B0 =E5=BD=A9 <iwata.aya@fujitsu.com>; Peter S= mith <smithpb= 2250@gmail.com>; Chao Li <li.evan.chao@gmail.com>; Kuroda, Hayato/=E9=BB= =92=E7=94=B0 =E9=9A=BC=E4=BA=BA <kuroda.hayato@fujitsu.com>; pgsql-hackers &l= t;pgsql-h= ackers@postgresql.org>
> Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DR= OP DATABASE
>
> +#define BGWORKER_EXIT_AT_DATABASE_CHANGE=C2=A0 =C2=A0 =C2=A0 =C2=A00x= 0004
>
> I am checking this patch, and I think so used names can be little bit = confusing
>
> BGWORKER_EXIT_AT_DATABASE_CHANGE - it is used for disconnecting worker= s on the template database, and this database is not changing.
>
> TerminateBgWorkersByDbOid - it doesn't terminate all workers, but = only workers with some special flags
>
> Maybe BGWORKER_INTERRUPTABLE and TerminateInterruptableBgWorkersByDbOi= d ?

Thank you for your advice.
I changed the name of a function and a flag.

> Another question is if this cancellation should be implicit and should= not require some special flag.
>
> When I want to disconnect connections to database when I do drop, I ha= ve to use FORCE flag
>
> So maybe there should be ALTER DATABASE ... RENAME ... FORCE - or if F= ORCE can terminare all workers (without special FLAG) ?

For the proposed feature, we've added a flag allowing each extension de= veloper to decide whether to terminate it via DROP/ALTER DATABASE.
Adding a FORCE option to ALTER to let database definition modifiers decide = whether to force termination of background workers might be better discusse= d in a separate thread.

When I thought = about it - there can be a second alternative.

Intr= oduce a pair of flags BGWORKER_INTERRUPTABLE and BGWORKER_PROTECTED (the na= mes can be enhanced or changed). BGWORKER_INTERRUPTABLE can be default.=C2= =A0
ALTER DATABASE RENAME and related commands can stop any non p= rotected workers. ALTER DATABASE RENAME FORCE can stop any workers (includi= ng protected).=C2=A0

Is there any reason why=C2=A0= BGWORKER_INTERRUPTABLE cannot be default? Probably nobody would block some = possibly common operations on database level without strong reason.

Regards

Pavel






Best Regards,
Aya Iwata
--0000000000000fd6200645fd74ba--