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 1vNiPB-00BpOD-1Y for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Nov 2025 02:03:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vNiP9-005wXO-1d for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Nov 2025 02:03:43 +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 1vNiP8-005wXE-1i for pgsql-hackers@lists.postgresql.org; Tue, 25 Nov 2025 02:03:43 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vNiP5-001KqE-2d for pgsql-hackers@lists.postgresql.org; Tue, 25 Nov 2025 02:03:42 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id D36311D0019D; Mon, 24 Nov 2025 21:03:36 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Mon, 24 Nov 2025 21:03:36 -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=fm3; t=1764036216; x=1764122616; bh=WEGVIv/CYt u5PSic+5loCNvl9yTj8MOV1SVTRbQNhNY=; b=EiUtARZ+1caBNONtbL/tuG/OXD 2Xa+51flLzJwMtXWFWhSSE2jZnHaEjLPAYQJ+fd1RH8D2vITwlJ07pVo0SM2IKA2 +f2yHM2mvVaJR/+5ZhHKc13NXicTtaQcJmxocHOvYDXzQMtfMu4NhdzrcTBSHGBA VwzBiVRW7STmXN+9P4TWh7ed78zTRDSsFjadMHn7IgUomlJR7TI9xWeRlM2AUe+J b05JKKkdn4Z750wfD1K5qNwlomYfS07X35nCzf0pAarx3eguUntFwLaxHFBFrs/7 lS9kINtlDtwgC/eXppJWeelDxI3ritokikGBbz2MLV8owxswj9a4o8FB+hUg== 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=fm3; t= 1764036216; x=1764122616; bh=WEGVIv/CYtu5PSic+5loCNvl9yTj8MOV1SV TRbQNhNY=; b=dONdbxXfiyfOrO5l9/T7zOQZ9GyqElz3NETmRbDXvj/C1qHRMx/ 0x/lhzT0AwAd4yWSbxrUwdTbsxPYlnK48puqLRuTInDNom6NdMAwXp3TRqt7kDla ushqgn05+nfgx6mY7w2y3C9UJ0ZG3EAUZgeFJ91tAVIB3ZMsPMKnyX0N+slqal9g DpB1A09XnT58sCuVzhXaVDJbeTcgdM41S/xWOTUmIMdE37/P/IrLywSzR/S/jXyT PmBvRmeZg8mHbonWKXrNcQ0Jn5RDmZkYDrzJ7+ocEAREczpmnOBJ/rBITEAA8+I8 ngJfbCQ4QzLk20nV72LKKM+qGGFnPljyjig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvgedtvdefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeggeeg fffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidp nhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshgrmh himhhsvghihhesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgv rhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 24 Nov 2025 21:03:35 -0500 (EST) Date: Tue, 25 Nov 2025 11:03:22 +0900 From: Michael Paquier To: Sami Imseih Cc: PostgreSQL Hackers Subject: Re: [Proposal] Adding callback support for custom statistics kinds Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ygdrJBdks8wPMJSw" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --ygdrJBdks8wPMJSw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 24, 2025 at 06:18:26PM -0600, Sami Imseih wrote: > After second thought, I am not too thrilled with extending reset_all_cb > to take responsibility for file cleanup, etc. I think it should just rema= in > used to reset stats only. >=20 > I think the best way forward will be to introduce a callback to be used by > custom kinds only. This callback will be responsible for cleaning up files > and related resources at the end of the write stats, read stats, and disc= ard > stats paths. The callback will provide back to the extension a status > (READ, WRITE, DISCARD) and the extension will know how to clean up the > resources it created depending on the situation. I guess that READ and WRITE are the cases that happen on success of these respective operations. DISCARD is the failure case when one of these fail. > So, unlike my original proposal, this puts more responsibility on the > extension to track and clean up its files, but this seems like the best > approach to take here. That may be something we should do anyway. It means that the modules are responsible for the tracking the file(s) they open, still they could also decide operations different than the backend for the main pgstats file, optionally, depending on the state of the reads and writes (aka success or failure of these). > Also, I am now leaning towards creating a separate test module rather than > trying to do too much unrelated testing in injection points. It is defini= tely > convenient to use injection points, but I think we can do better testing = with > a separate module. This module can also serve as an example for extension > developers. You are right that it may be cleaner this way. Do you think that it could make sense to move some of the existing "template" code of injection_points there? One part of the proposed patch that felt independent to me was the renaming and publishing of the two write/read routines for the stats files, so I have extracted that in your first patch to reduce the blast, and applied that as it can also be useful on its own. -- Michael --ygdrJBdks8wPMJSw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmklDmoACgkQnvQgOdby QH1tMxAAm4NaZ1zFYE318+8R7p3zwMlZKGxPQn5IoewLmciygGC1Z9HHAKvFwRJm KE8GTErxpVY3TF4eopIMWfOJ6RwvnhYzUp7OPIRaKi5nTxWEj2L3W7qSttxckDTu t5NrTAQ6t3CURNg9L1H80FNZAdw5xSBA9ouV1aFSZK+lBwuB5EJey4t2SF9cQXt6 NzrcmImQHvZU00WwjRj5OKrhVq5uEm1McBjqiSsi+e6/rvfm8RSmMaAQ2DIyRlSr 9/LajyiNVxsuUVkmZHB7d2wAR2Zqb6X71WUjU81OeSp/QtvO1quQeKnTnCMkWhD+ mEgtLYeZjVEdBuYCsxajoHMODmIZB5Yp7yRmp40M+kjd5dVs2Yh3RHMExfj7C8MA muERZy8o/p5c2OfCsVsGpasqnQBIJj/YJls+SD8Eb6RXemIsjCv65PvYfWTPqWxp yUzWeygsgZ/OpYeZxLZZsfYnk4vQYdHdu7N9tSoM25gI6Eq5Ieaa4oIkjI2rw1th J7uQZekXw3G9pc0urVUkT/h2CSecERhtGTksDiuX1/H/lcbuL3M8lYM8Mu7QkMgY 3G5fstnm1ICmmmC+/B3/46qCcT6bwpsZ/cqcRdTBlaW1wV4F7ADG2IaZBh4L5TCP 7k2iVOh/tVi57cFmdiurn1+FLVAmIwPcUcMww85yYCzaj1bTeko= =KwZ2 -----END PGP SIGNATURE----- --ygdrJBdks8wPMJSw--