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 1v9F4l-00DSmI-EA for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Oct 2025 03:54:50 +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 1v9F4k-009o9X-6q for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Oct 2025 03:54:49 +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.94.2) (envelope-from ) id 1v9F4j-009o9P-TU for pgsql-hackers@lists.postgresql.org; Thu, 16 Oct 2025 03:54:48 +0000 Received: from fhigh-a2-smtp.messagingengine.com ([103.168.172.153]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1v9F4g-0021DB-2Z for pgsql-hackers@postgresql.org; Thu, 16 Oct 2025 03:54:48 +0000 Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3AE7E14000F4; Wed, 15 Oct 2025 23:54:46 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Wed, 15 Oct 2025 23:54:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1760586886; x=1760673286; bh=Fn5ZLndX6b 79HKIHk/aor2xT/sVr0SSDcaIgTMwOToE=; b=HRYGELnqtcvjvWHnRBdOGxemb3 ZKUBjj65bnPwC+KV/2hJ223/yPtM7OvAV+TK9phB0gunUxbBsYs2E8vxD4pWM9k9 uEFtiQcL5SurgdBfmavH+/9L0/pNAkF22zX9xeshRuqF3wIJ40Eel7mz2oV1obtN 0E5fH8jXjHJeFjDCZCEfrEMQ8SRpSMG8D6rJ9+8MlGlJ/uLcB7bG5UWJaQu0SRSo I85aj3Cr1QOtF6J1cGDjKGOuOO5NJY8d80QmEgPWd+aYwVJ8cV9DBkq9OhxVyTF+ kM3hiLt9PwImE/B8uDzleDxDzDq16W5V94MQusha1hvuvx33YIa0DbZUmAOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1760586886; x=1760673286; bh=Fn5ZLndX6b79HKIHk/aor2xT/sVr0SSDcaI gTMwOToE=; b=xGout2kZkNcNOxpKe1w9/h2XHeQFNDHCvcfqG7IxJPZbYMN636V o4gp2pxT6S28YqoXDHdg/d43aqvNFKb7heTkKHX/IRYSbpYxufpayEIHot96Plki rwR8vVZ0ieCd5+unWV4WdTN+fgGdRwWegGPFKCGZ0QuKn5mlXrxO5UcpTVyF/mSz 6Kn/o6TeS8f1lQJnpdbzIEKocr0BzHflulUTB5odnfxh95kH1rg24p5aZ/Ao8aez WDfcTMcTmHRLaVMS92K52D8LSoi2k5jGYDUss3Xv3PawW1Oc9ScGPh6MlGs2hn+M W23hMJerGsjtSBv4UIExJeupjlhZkqOqNug== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduvdehvdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeggeeg fffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidp nhgspghrtghpthhtohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihifrg htrgdrrgihrgesfhhujhhithhsuhdrtghomhdprhgtphhtthhopehsmhhithhhphgsvddv hedtsehgmhgrihhlrdgtohhmpdhrtghpthhtoheplhhirdgvvhgrnhdrtghhrghosehgmh grihhlrdgtohhmpdhrtghpthhtohepkhhurhhouggrrdhhrgihrghtohesfhhujhhithhs uhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvsh hqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 15 Oct 2025 23:54:43 -0400 (EDT) Date: Thu, 16 Oct 2025 12:54:31 +0900 From: Michael Paquier To: "Aya Iwata (Fujitsu)" Cc: 'Peter Smith' , Chao Li , "Hayato Kuroda (Fujitsu)" , pgsql-hackers Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="VgLTlR48wNPj/NbY" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --VgLTlR48wNPj/NbY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 15, 2025 at 02:48:43AM +0000, Aya Iwata (Fujitsu) wrote: > Thank you for your comments. I updated this patch to v0007. + * Exit the bgworker when its database is dropped, renamed, moved to a + * different tablespace, or used as a template for CREATE DATABASE. I don't think that we need to list all these operations in details here. We could just say "if its database is involved in a CREATE, ALTER or DROP database command". The docs should provide these details, of course. +#define BGWORKER_EXIT_AT_DATABASE_CHANGE 0x0004=20 Flag name works here. # XXX This spends more than 5 seconds because the backend retries counting # number of connecting processes 50 times. See CountOtherDBBackends(). And that's annoying. Let's activate what I call the cheat mode for this one: an injection point that, if defined, enforces a lower number of tries when we loop over the workers to stop. That would make the test much faster when using a worker that should not be stopped, without impacting the coverage. I suspect that your new test 002_worker_terminate.pl has a race condition in run_db_command(): are you sure that the bgworker has enough time to be reported as stopped in the server logs once safe_psql() finishes to run the database command given by the caller? On very slow and/or loaded machines, particularly, that could hurt the stability. It seems to me that this should use a wait_for_log() instead of a log_contains(), waiting for the worker to be reported as stopped depending on the command executed. Shouldn't this test also check that worker 0 (the one that does not have the flag set) is still running at the end of the test? I assume that querying pg_stat_activity would be enough at the end of the script. -- Michael --VgLTlR48wNPj/NbY Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmjwbHcACgkQnvQgOdby QH1tjw//RCSZr5jWcf8mIcA5rxa1arzaINEHJXzr2mKcS71PlrxN4tK6IQWQEtDa xc/2oXm4NRg3zD9TMV4TSUaDaMKyUYhgRN8t2i7Nug3uO9sF+IrmFb2ys/rSMSvE s2cSuzfU15KVDC6wcLFkEy7gs1S3bQXF61+45voXdDUIcBjsUswKAVmLLFgkYXC8 oJQ24Fq3Wkma/5m2L9y2QF9s72EHuO+nHb0cgVefM/FHyEqGXMKbW/wtpaB5QnTk yYFgxjtnrR93Uo+PTl7LU+X7xkavGUnlgg0OuB/4FCYg5yzJ2s6Cv34ZF9LReAZk ial9LFNJkmkJvMW5GyPEBebjXCzDbHY7RkPug2gl/rB37/P0smZVMyckDxrXiamQ SOa1E09OfZkQn0oMnri1Ma5wmZs4nmL8wq+Sx9AuShaNKmOb2Or8ZDoe+tfCxULp VDy+z+hECBeExZcv1KCQb8WKGtK4rOUSJQJBlTUrM/dvomcuAEo03mKmw75ZmGWY 7c0gr7bfOa0Dx1bj/E+Xz2FqLpz9bCu5dOhJanT9fMWpZj2Vsk4Bzs2xg7IDmTJA kfg0pZbuEmnUx1BZArZRlTWuWEN/5rfTuwkz2Cg96rA/uo0BmprgKuzrnfIazzdr LXqiR8DGfvcyw8O4AtW/dPYr14kRRsBuixtMiM9SCWYuj/KQATM= =XH8N -----END PGP SIGNATURE----- --VgLTlR48wNPj/NbY--