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 1vcab4-008jwY-0l for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Jan 2026 02:45:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vcab1-00GzT2-0s for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Jan 2026 02:45: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.96) (envelope-from ) id 1vcab0-00GzSu-2s for pgsql-hackers@lists.postgresql.org; Mon, 05 Jan 2026 02:45:27 +0000 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vcaay-004YYd-1J for pgsql-hackers@postgresql.org; Mon, 05 Jan 2026 02:45:26 +0000 Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-4f34c5f2f98so153216631cf.1 for ; Sun, 04 Jan 2026 18:45:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767581121; x=1768185921; 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=OQaur7AVzL7VMkGrAVicjsY3TJ9pVmsJNHYBmOi8Wjk=; b=TWtVaBrgI1Au+XJu0LMEVPjkQf3DTEgUKX/WwiS3ANIPWVC1CuhnKBjJaVV/tHOwjK 8zRc7dUNsSl0s2q9wa9Q9CtVl1mjFjaunxsEH+cjjUHqRku6BI99dxPz1atz0OyKsWMe bEW3RQxnJD41DbD+sxGZe5HU4/7Wp1l9LVrEmhiJPlJZTy8fXJU5OuGGxqgNa3na5+Xg jGAueL6sKtJy9GJKVhfCcX3Lva8npfRDRoDjONbT8TigGpNdkq/wMDmfmsi6/jTfndL6 +aWBumwMVBOSVDrUh/aHGdr2wY3FiCxEMfzmS1SVdsxinwQFyKDbbmqdaqSdmX3NJ0Mp EVSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767581121; x=1768185921; 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=OQaur7AVzL7VMkGrAVicjsY3TJ9pVmsJNHYBmOi8Wjk=; b=Xtv+UvInPeINUVARteKlHRczRwrIOGuzEp7CRpr8uMINJIDZj6rbaCfRAQsFRTEBtE 4/JHq4g6oNLthZtlMuQMb8PzGhL7tu+vLtVVBA2EWNbjh523ZzEwb6e2gg0Vx/n19O6F OaPIIIMY2N0nLQ/EDNEd1c6Qycgm/64c8dtSw3OkHRof3dxmpxdGopAvw6hNFIHN577Y dBZDkzDJUHBXaKrudZOEy5dnxLrkuB+iNrhNtQlwwzZ7iHTPgou0xzfL9nFmEXQ2yu8c 8QKjPXXz4udRjDe0pvbPsfPwUa47RWRMHoYQAu8Q2p7OCfkcqlryYwrz2/bmBH2TvMH5 luZQ== X-Forwarded-Encrypted: i=1; AJvYcCU0fFRGgOhsMqo1JlYlL95ck7E2pzBboWi6ze4oHMwXCvrnd7jOStzL0hAU8kwmOjjF1LrWal/j2fP4eNm2@postgresql.org X-Gm-Message-State: AOJu0YwI1n5Km2pDtkFMrBIGRAjpDe8xV7M4cOIMp0AWQf59hpsnp4OA XEpeUbS1h0fLXucfKRWVRFRwqhhaCm84YWkIuG+R6wsmHGsbAS9W78t9X03dZAr3vN3sB3JOQOf svFjadDjEJkWuMhJTMToZNIFLN0VgGec= X-Gm-Gg: AY/fxX4VQ1TvZwyNBGo9ySSEBNw6DD8Iv5nZDbfZImBubcmjp66kzjP3e+XpmBeunEC SvjastOjx9cBC5iUa90/n2HFsrWcaAMc3YibLoH9C9V2fUauflMXK4lOgZ10roQHhMiImK/tIup AORnP0LRBKk7q84Vm8RFMB21ajD5NFnqZjRtXQQcQWYHVNT8bvNV059oOV5zNnfLmf0vK/J2WF+ g6Rjxmr1iLhbJMwTP7czZaobBK3805ZszaNZI1OV+lmnP1uUZYaEiHsZMx9YCR1xS6wgghh9ncH CfYccJMf50xUixlOub9gPr5gGEIF X-Google-Smtp-Source: AGHT+IHVuwOue+Fth1tqSFi+3SeEy6MzQdMOz4i779HY3GR8S+lcQIqKFRwxqWsIdfMSK//e4t30xjWZcLrKxsmlSD4= X-Received: by 2002:a05:622a:1248:b0:4ec:ef62:8c81 with SMTP id d75a77b69052e-4f4abd8c6bdmr606939241cf.47.1767581121508; Sun, 04 Jan 2026 18:45:21 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Mon, 5 Jan 2026 13:44:55 +1100 X-Gm-Features: AQt7F2osKyh9AFCsY2UzJGLgLySai6gjauLhACleegVWvoEZMaBy2pX2ENfiEZA Message-ID: Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE To: "Aya Iwata (Fujitsu)" Cc: Pavel Stehule , Michael Paquier , Chao Li , "Hayato Kuroda (Fujitsu)" , pgsql-hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Iwata-San. It is not at all clear to me if you are advocating for the flag to be called INTERRUPTABLE or to be called PROTECTED? IIUC, behaviour-wise it ultimately ends up the same, just the flags are different names with opposite meanings and defaults. Still, you need to choose ASAP because this decision touches a lot of code, comments and tests. It seems that when Michael wrote, there were "more advantages in ... make a bgworker interruptible an opt-in choice" [1], he is favouring keeping it as the INTERRUPTABLE flag -- e.g. discard patch 0002. Am I reading this thread correctly? ~~~ Anyway, just in case you are PROTECTED is still under consideration, then below are some review comments for the v11-0002 patch. ====== doc/src/sgml/bgworker.sgml 1a. The commit message says that "default behavior to Terminate." which I assumed means that by default, the PROTECTED is *note* set. But the default behaviour is not mentioned in the SGML help? 1b. Also, the INTERRUPTABLE flag was documented that it required both BGWORKER_SHMEM_ACCESS and BGWORKER_BACKEND_DATABASE_CONNECTION as well. But did it make sense to document that those are both still required for PROTECTED? ====== src/backend/postmaster/bgworker.c 2. TerminateInterruptableBgWorkersByDbOid: AFAIK, you only called the function this name because of the INTERRUPTABLE flag. But, if you are going to use PROTECTED instead, then the function name should likewise change to something like TerminateUnprotectedBgWorkersByDbOid. ====== src/backend/storage/ipc/procarray.c CountOtherDBBackends: 3. /* * Terminate all background workers for this database, if they had - * requested it (BGWORKER_INTERRUPTABLE) + * requested it (BGWORKER_PROTECTED) */ The comment seems wrong because BGWORKER_PROTECTED means do NOT terminate it because it is protected. So the comment should be more like: Terminate all background workers for this database, unless they are flagged as BGWORKER_PROTECTED. ====== src/include/postmaster/bgworker.h 4. -#define BGWORKER_INTERRUPTABLE 0x0004 +#define BGWORKER_PROTECTED 0x0004 You cannot change the name to have the opposite meaning, without also rewriting the preceding code comment. ====== src/test/modules/worker_spi/t/002_worker_terminate.pl 5. -# Ensure CREATE DATABASE WITH TEMPLATE fails because background worker retains +# Ensure CREATE DATABASE WITH TEMPLATE sucseeds because background worker retains Typo - "sucseeds" Typo - "background worker retains" ?? Do you mean "remains" ?? ~~~ 6. The code below: my $result = $node->safe_psql( $database, qq( SELECT worker_spi_launch($testcase, oid, 0, '{}', $request_terminate) IS NOT NULL FROM pg_database WHERE datname = '$database'; )); ... seems contradictary because the 4th parameter ($request_terminate) of worker_spi_launch() was changed to *prevent* termination, not request it. e.g. bool prevent_termination = PG_GETARG_BOOL(4); It makes me doubtful about the testcode validity/correctness, given that the parameter now has the opposite meaning from patch 0001, but still the test is passing. ====== [1] https://www.postgresql.org/message-id/aVHQt-asgKx5dnap%40paquier.xyz Kind Regards, Peter Smith. Fujitsu Australia