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 1vcdmt-009DPb-0v for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Jan 2026 06:09:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vcdms-0003af-0S for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Jan 2026 06:09:54 +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 1vcdjh-00HayG-1Q for pgsql-hackers@lists.postgresql.org; Mon, 05 Jan 2026 06:06:38 +0000 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vcdjf-004a4P-2T for pgsql-hackers@postgresql.org; Mon, 05 Jan 2026 06:06:37 +0000 Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-4f4cd02f915so71004911cf.1 for ; Sun, 04 Jan 2026 22:06:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767593193; x=1768197993; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=08ope7Bv68lmsZBDYNOeB2xXZPd8z3c3q0HTcPPT5Uw=; b=d284yCDQP+NiIh+rcnpegD5nrMG3ZG0t5WnZm0hRQpDYEXrVXV9jA4XeOl2plvykz5 aybmQbR6RnhN8eWTtdBTnWJ+OsbXSiuzOwq9H4t6b6cqTHakX4M8/90+uSBqB/G2OS5L 7bCrmKZcxoTMWKyut+eK9J1xM5l8ifJlcGAE2RvZBnmm8YpsDc6k7QWm9JFZTvQkHFPI 7LAQ0S+PUOvnwWd5OFCrfYtHS8y2AtqGyHuoQj4kUrNY61lkHmhNcvwGIyx/U+mDTGGz 8dQhVjegJ85yKSzcKcVH4RmmDMG/XadaJ/YbbGheLu3sLQ4RI7WWHxkS+zftVqd+16PW DRMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767593193; x=1768197993; h=content-transfer-encoding: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=08ope7Bv68lmsZBDYNOeB2xXZPd8z3c3q0HTcPPT5Uw=; b=dV0A4PvLHt6BX+4GWVoqceO9GoUgT1fd6/0SYhHVziw5DGnZLX1u3WIBAQwoOVEFjc 0JT1YzCjLAA4N2GmFUbaDOINTyJk8jzv+BeArmufzAM5nDFrlCOYiOafangB0ru+5T5+ I/O9qJ2OhLHidUBUIMGA9DFBUFh66kuHjKV94zGz/wwPWap/PRxhAVNOIbcO+//15zus whTDsQikDKZ4t3UxI6L4dZ/3Fkc52/4Rjl0ok6HBHU4eisSXjA5X3nCjSXJD/2bPVMN0 1XV0rrZmzKL2nE1B3z4avmqfPgAhYNf7guB+PJTmr5B+eD+CAMCl/XQ0TtPYYA1vRgG/ X6Pw== X-Forwarded-Encrypted: i=1; AJvYcCWH6cO3onGCWHSRo1HRs6lXRESo9NvkIWym/azLApfuDOY9eMziAz4zNlkQo5AeombW6/175pSZa0YIN+yz@postgresql.org X-Gm-Message-State: AOJu0YzqfQLRv5MQ2jcpdpHFcEv1nO4henPM63MC1MLX+nfAHFd3Yvmx Tt/8XFHusSiq3MxwewPlnup/uaZ5sRuvPjC/JIMAkNlevyCrV/NRuPwSdMpHvdpVE4YefPgdSD9 K+uQVjnU23hqzOs++fPlolEujFD8cPOE= X-Gm-Gg: AY/fxX7+qz6wFQq41xhpR3pnjawAQIaBJxXqA9nDWI4qDwYC6HIw8D55HBNUlnCZupB JEv75oa0tAxj7RFR8DuIRcsSZIRp+sfZbbqzsJ1uq7rRy09Ys5sRodua1QnF9BFYkM4fdbazdkn +SwP/84xmJYcdf+SpnYZb6Md26kWC1nVqAeilm3MliSksjjAtkZfecH81HUOwKnNJrMC65VDfjv h3TWrCGDUrLiI0R28fosSRa+jYLZEovsNDn9dt6OG88WKhc62zAv6VwqqQE8wnVvKmn7fb7eAmG 0UhCs6iCz/KsBp5zhLHcnBM9UUd/ X-Google-Smtp-Source: AGHT+IEDH2ai0ifn0djnml/3xYZ9vs+eHCnh8fNgU8OOeFA/LskyPfvLTR+olbuBAM6BNEn6MS/ZW/az0SN9TQFWGCI= X-Received: by 2002:a05:622a:4c15:b0:4ec:fdaa:b31e with SMTP id d75a77b69052e-4f4abce094cmr770685411cf.32.1767593193312; Sun, 04 Jan 2026 22:06:33 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Mon, 5 Jan 2026 17:06:06 +1100 X-Gm-Features: AQt7F2pVWaK4mWM-WeL1HjxptcpYD7WEGXJcHLw081KLP8ha6sfULucZ9rbkj8U Message-ID: Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE To: Michael Paquier Cc: "Aya Iwata (Fujitsu)" , Pavel Stehule , Chao Li , "Hayato Kuroda (Fujitsu)" , pgsql-hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jan 5, 2026 at 2:59=E2=80=AFPM Michael Paquier wrote: > ... > The timing is interesting, I have put my hands on this patch this > morning before you sent your last email, and adjusted the thing in > many ways, finishing with the attached. This includes changes in the > tests to address what I found was lacking and slightly incorrect, new > names for the flag and its related variables, copyright update to > 2026, as well as an additional sanity check when starting the workers, > leading to the updated version attached. The CI is happy with it. > > Thoughts or comments about that? > -- Here are my (mostly trivial) review comments for the latest patch v12-0001. Otherwise, LGTM. =3D=3D=3D=3D=3D=3D src/backend/postmaster/bgworker.c 1. nit + * Terminate all background workers connected to the given database, if th= ey + * had requested it. In procarray.c you changed the equivalent comment to "if they *have* requested it." ~~~ 2. nit + for (int slotno =3D 0; slotno < BackgroundWorkerData->total_slots; ++slot= no) The ++slotno is inconsistent with slotno++ of the preceding function loop. It is a matter of taste... YMMV. =3D=3D=3D=3D=3D=3D src/backend/storage/ipc/procarray.c 3 - * for them to exit. Autovacuum backends are encouraged to exit early by - * sending them SIGTERM, but normal user backends are just waited for. + * for them to exit. Autovacuum backends and background workers are encou= raged + * to exit early by sending them SIGTERM, but normal user backends are jus= t + * waited for. Is that code comment change strictly correct? IIUC, the background workers are stopped by TerminateInterruptibleBgWorkersByDbOid using PMSIGNAL_BACKGROUND_WORKER_CHANGE, not SIGTERM. =3D=3D=3D=3D=3D=3D .../worker_spi/t/002_worker_terminate.pl 4. nit +sub launch_bgworker +{ + my ($node, $database, $testcase, $request_terminate) =3D @_; Everywhere else, you called this flag 'interruptible'; so, should you also change $request_terminate to $interruptible? ~~~ 5. nit +sub run_db_command Would a better name for this be more like 'run_bgworker_interruptible_test' ~~~ 6. +# Confirm that the non-interruptible bgworker is still running. +my $result =3D $node->safe_psql( + "postgres", qq( + SELECT count(1) FROM pg_stat_activity + WHERE backend_type =3D 'worker_spi dynamic';)); Indentation of the "SELECT"? =3D=3D=3D=3D=3D=3D doc/src/sgml/bgworker.sgml 7. + termination signal when any of these commands affect the worker's database: + DROP DATABASE, + ALTER DATABASE RENAME TO, + ALTER DATABASE SET TABLESPACE, or + CREATE DATABASE. This looks OK in the SGML, but not when it is rendered. The multiple commands are separated only by commas, so because the font changes are subtle, it ends up looking like one big comma-separated command. How about using an itemised list like: + + DROP DATABASE + ALTER DATABASE RENAME TO + ALTER DATABASE SET TABLESPACE + CREATE DATABASE + This renders nicely. =3D=3D=3D=3D=3D=3D Kind Regards, Peter Smith. Fujitsu Australia