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 1tpbc4-008pVH-Ax for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Mar 2025 23:23:48 +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 1tpbc2-00B9Id-2e for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Mar 2025 23:23:46 +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 1tpbc1-00B9IV-Ow for pgsql-hackers@lists.postgresql.org; Tue, 04 Mar 2025 23:23:45 +0000 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tpbbz-000zlN-2u for pgsql-hackers@postgresql.org; Tue, 04 Mar 2025 23:23:44 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.stl.internal (Postfix) with ESMTP id 846DF25402EF; Tue, 4 Mar 2025 18:23:43 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Tue, 04 Mar 2025 18:23:43 -0500 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=fm1; t=1741130623; x=1741217023; bh=SeoeG8HUwZ qT9aLQZwL4CsZmGmjBK5bFw4YaRjUhWf0=; b=6duzGJ+kc5JDBpTtLqZK1NAKEF 2fNUUhv+Bmy7T0Fx4/yaHLT3dGhgSOUk2jtXvk3SKWdeCcEC5lCpyrHSWmvH71MB kydCiwL1ryjrpetHsXwulO0fF2LioYlo1z1GhHssZ+H1lYdYnq3Wc657+izK2j0N HnCHKosWJ2AFGYwXSyiGaPV+rFIsqzJiDnWo7+YN+ltv4lEorpWIzlVZSHkw0xZp bM1jxCHnnOPuLVfjqpjvTRUlLiSa0fXWjGFNUhZF12DbkMYD/+aDRnQu8cLhjHGP UjuW+FIi6SW2VLFV6rIVT8BnPyns9o4PYt7KJRRZnbo+IKWo79EdNvSxRixg== 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=fm1; t= 1741130623; x=1741217023; bh=SeoeG8HUwZqT9aLQZwL4CsZmGmjBK5bFw4Y aRjUhWf0=; b=IW8emFdMdqC597vKHD+T1TIKdFi3psk5c8l87oY+Knm3n4PUZcz Yw0vZypqXz760zZ3AB9p/HEwWoF8jj6RlLc/XbsbPNIicRkcIKZ5ZECn0Ff3Zu5Q nvNnqPPKqYqtKX/vUetu0yzfrL8nEzGxz20Oum3s0wOpXeper5A/l0CqboAVQlb0 URrGiTaeGdnqRcqsocvgiV4MatFdxVKoAGLH0VKmPXx+Bgk6U66T5qjKNgbVHWBv OiVS/RX5PKRbxDDjPjX2bEAfCALWJSMnBVWTRJBVr/HtgcLwJaYnbLyOvxsW+0K6 S4Ht2I0mDAiSTmpPWI6w1084wPYXHjujIrw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdefvdekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnegfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefu kfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivg hruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhep teelieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdejnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggv lhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohephedpmhhouggvpehsmhhtph houhhtpdhrtghpthhtoheprghnughrvghssegrnhgrrhgriigvlhdruggvpdhrtghpthht ohephhhlihhnnhgrkhgrsehikhhirdhfihdprhgtphhtthhopehtohhmrghssehvohhnug hrrgdrmhgvpdhrtghpthhtohepthhhohhmrghsrdhmuhhnrhhosehgmhgrihhlrdgtohhm pdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorh hg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Mar 2025 18:23:41 -0500 (EST) Date: Wed, 5 Mar 2025 08:23:32 +0900 From: Michael Paquier To: Andres Freund Cc: Heikki Linnakangas , Tomas Vondra , Thomas Munro , "pgsql-hackers@postgresql.org" Subject: Re: Refactoring postmaster's code to cleanup after child exit Message-ID: References: <8e710eaa-fcfe-4a0b-ae90-87743083e777@iki.fi> <82eb454e-f9e0-433c-89f5-69f03b09ca32@vondra.me> <31b798ca-c150-4fc9-befe-300dd8bbda3c@iki.fi> <574340ca-c90e-4086-9ae2-cd2f1359e989@iki.fi> <4d964960-72fa-4741-8a7c-879b958eaa29@iki.fi> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vTU432wnFfUYy3oS" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --vTU432wnFfUYy3oS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 04, 2025 at 05:58:42PM -0500, Andres Freund wrote: > On 2024-12-10 12:00:12 +0200, Heikki Linnakangas wrote: >> 2. Move the pgstat_bestart() call earlier in the startup sequence, so th= at a >> backend shows up in pg_stat_activity before it acquires a PGPROC entry, = and >> stays visible until after it has released its PGPROC entry. This would g= ive >> more visibility to backends that are starting up. >=20 > We don't necessarily *have* a PGPROC entry for that backend when we run o= ut of > connections, no? Exactly. If I got this thread's argument right, you cannot have a PGPROC entry that could be plugged into pg_stat_activity that early during the startup process when collecting the startup packet. > For this test, could we perhaps rely on the log messages postmaster logs = when > child processes exit? >=20 > 2025-03-04 17:56:12.528 EST [3509838][not initialized][:0][[unknown]] LOG= : connection received: host=3D[local] > 2025-03-04 17:56:12.528 EST [3509838][client backend][:0][[unknown]] FATA= L: sorry, too many clients already > 2025-03-04 17:56:12.529 EST [3509817][postmaster][:0][] DEBUG: releasing= pm child slot 2 > 2025-03-04 17:56:12.529 EST [3509817][postmaster][:0][] DEBUG: client ba= ckend (PID 3509838) exited with exit code 1 >=20 > I.e. the test could wait for the 'client backend exited' message using > ->wait_for_log()? Matching expected contents in the server logs is a practice I've found to be rather reliable, with wait_for_log(). Why not adding an injection point with a WARNING or a LOG generated, then check the server logs for the code path taken based on the elog() generated with the point name? -- Michael --vTU432wnFfUYy3oS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmfHi3QACgkQnvQgOdby QH0SrRAAoQw9537FTf5mQbl0fpZYs4OgmXSygmnLNk52Sjdl0UX/3xMWR1U5Kq/D deAjYB10KjBQbdQz2LlGgwKfju5wdVnXQNy6Pi5kGrJtF6NxK2CkXHi2On06zpjB f9NPNGjMj+qUAEvZHTF/GM8sYe1evwjBGS1p8/plDZDRpaF0zlgKQ0eElOTygB/b gIqOsKgGj8lX1g1G1Wie0HhWEdCtGd5A1PO6hD2UQ6fraUKdUj9++eg17cAJZFHZ YQEmIL6fVUvJ7Rq68YAjjkGOGq7QvYSDv8p01Cgu0QRqDtHmk2H9B9ToKBlnqNIA jIkL1lMp1lZQM6QKwnKwXrh5EmWDXMV4F+E7Tgac9XeocKjXFPYcdxNmV47PgPrK 4/Y3Z7eZixvRsdxggNKMMAroAXNJFx7S9Gm8bHC/3saEFrPLbjbfSaPFqp6D8zrF uRWhwSEQyVHMpW778ATGFQVPsV+IKTIZTwO+ARhVfatoJECaXqeldIH4Ydtf82vF ZfDY6ZiMFL1LDTroaa0dG9SKCseLgSSGOJFL9BVjthPHWinwLWCfxqKMP+42nDII XMJP0aO59R/RlRydYUk9jmk2YlWWB0rkyQ2EaBSIeMmAye0p4bc8AlzOL7R0p/1B Vl+L8eCnbHJMlXM1S9EkkRMKUsmIIH/ACM8s1XJjGhr4VM4k2HA= =4X6d -----END PGP SIGNATURE----- --vTU432wnFfUYy3oS--