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 1vTFBi-00FMF4-1h for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Dec 2025 08:04:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vTFBh-00ABu3-0S for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Dec 2025 08:04:41 +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 1vTFBg-00ABtu-0q for pgsql-hackers@lists.postgresql.org; Wed, 10 Dec 2025 08:04:41 +0000 Received: from fhigh-b3-smtp.messagingengine.com ([202.12.124.154]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vTFBd-004DnA-21 for pgsql-hackers@lists.postgresql.org; Wed, 10 Dec 2025 08:04:40 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 7BF597A016F; Wed, 10 Dec 2025 03:04:35 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Wed, 10 Dec 2025 03:04:35 -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=1765353875; x=1765440275; bh=xK68WI4k7W TWcAHlqMxGoS6Y9FDMl7Ge5fxnMS9fTsI=; b=Y2oeOkIWVMQoLGgNfYVqXELOnq tM3E2jgWNG+N0L70Vc0Ncp8LtYnHG9s8V1kDhazyoNm2O8MTZ9ZZ8oFRMx1rlh52 FjsSKU/u1aXUFQaS6z1W536WLC4sPhx3xRlQNH+5JGTrwAww6Y4OXNtmP9IgKfXZ bPnhIp/Gaoti32RMg9+ERGpyS10yv2pJPbZ1Z+434lNij1snviAbFlonelqMgAwV vFkVbBGk9N5/2pjjP08CPv1qxYsKCjAd9z6ZfY60ctQK4/TstpPjjW35lluKO4ap 8RfTJddpzVP8R95LBl3u4PQo+6pm5TM208Myb1J8BF9hh7hp+EDKVV/z35JA== 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= 1765353875; x=1765440275; bh=xK68WI4k7WTWcAHlqMxGoS6Y9FDMl7Ge5fx nMS9fTsI=; b=PQeu/XLLjy0kkOlE25XHCyJFl3h/qKOKI72ze1DW4TlmIxkL877 a0T7XdGk8babb4thHcUcQEhmpuea2bQSY70cOKzbcTDrKi/+CyPs20YxsqQbPN6T NJMLhDiOvdbATT43GaeklQoia4pRwRTDXUM1mbQK1rvOUG9oCK49vvTGtU/vlVxq ZHxNF4cvRV9xKWC2vUtLRbtyWbO4kXE2BdnM+zoyWNefkf5k0TFE+oLQLeHFTpQd mYAYKdIPCLiyVJgb93KqdOJrg7W7ii9Isq25h8xBfZ79AZynCHcOrP5wO1LmeBRX IQopX0zyJMWkG1Y9uT/o4PjN2swNa8h+ygQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvudeltdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdefhedmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtjeen ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeejieegheevjedvgeektdegveejueeg heeljeeggeffvdfhjeefffeigfejjedvfeenucffohhmrghinhepphhoshhtghhrvghsqh hlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepfedpmh houggvpehsmhhtphhouhhtpdhrtghpthhtohepshgrmhhimhhsvghihhesghhmrghilhdr tghomhdprhgtphhtthhopehlihdrvghvrghnrdgthhgrohesghhmrghilhdrtghomhdprh gtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhq lhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 10 Dec 2025 03:04:34 -0500 (EST) Date: Wed, 10 Dec 2025 17:04:16 +0900 From: Michael Paquier To: Sami Imseih Cc: Chao Li , PostgreSQL Hackers Subject: Re: [Proposal] Adding callback support for custom statistics kinds Message-ID: References: <9252DA7C-C611-4A93-A484-E6CD42557C15@gmail.com> <4E61FDC4-CFBB-4116-980F-75ADD245A1F6@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="su3aFBg80R6gXPbe" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --su3aFBg80R6gXPbe Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Dec 09, 2025 at 05:15:45PM -0600, Sami Imseih wrote: > Thanks for explaining. If there is a good use-case to add more detail to > the =E2=80=9Cend=E2=80=9D callback, it=E2=80=99s not very obvious yet. Ma= ybe in the future, there > will be a convincing reason to do so. The step taken by test_custom_var_stats_file_cleanup() for the STATS_READ case shines for its simplicity. The STATS_DISCARD case is also simple: we know that we want to ditch the stats. Now, it is kind of true that the STATS_WRITE case feels a bit disturbing written this way: we let a module take an action, but we don't actually know the state of the main pgstats file when inside the callback. I mean, you can know how things are going on, but it means that a module can just rely on a check if PGSTAT_STAT_PERMANENT_FILENAME is on disk, but an unlink() could have failed as well. So, yes, I am wondering whether we should do what Chao is suggesting, passing an extra state to the callback to let the module know if we have actually succeeded or failed the operations that have been taken on the main stats file before the callback end_extra_stats is called in the three cases. It does not matter for the STATS_READ case, but it may matter for the STATS_DISCARD or STATS_WRITE case. > When we hit the clean-up code on any =E2=80=9Cerror=E2=80=9D, it should b= e accompanied by > an error log. That is > done in all cases inside pgstat.c, and I expect an extension to log the > error as well. FWIW, I still have the same question as the one posted here about the business in pgstat_initialize(), still present in v6: https://www.postgresql.org/message-id/aTepXZ97PsXpuywI@paquier.xyz This remains unanswered. -- Michael --su3aFBg80R6gXPbe Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmk5KYAACgkQnvQgOdby QH0S/Q//RtmmLire7rNyKWU18nTzoLN8YWe00iZNbd0wH9m0exA6fc1wimOyyFLi DoSjdfwyT042kMn1Jw+52uaGl+iXVPDIztZzDnYX1YHEwu7tZtocrcrhF1Tu9zhJ lZQGho2fIJh9UVC5s0SQjArvX0lBpu7G46V5qUtXtic3aSuTwbbRCondjtkMASXk Kasp0tqJeQnFU4wa+ZKgubm8iovtpcTDj1BqttmSx5Rs6oMQ0EKh4FaPre9hVJ64 2C1x8+EF2UPigGOBBAcSf4MMDhqI4o1x8LOBpQK5/c9rR0Kne3wpn/dirM4vhH5/ /l1izGTecjY6ToDW6AVTxkxe9n9qMorvR841R3VgiJ4NvY5vD0U5MQeWdSzomErB +fgw+zeVKbTSxfTOQOJlYBTgVYMxXg7vwd7RzgYWuxZXFzhS+FkHc/yFJknmF9N/ yayhoP0ZOEybR92BsnaHX1kxL1vGXYMEvjH5SoulDfm29lt5KlAoS7h7vO6Pg8Pc KMEEdJYAI07IanHj/zG9ex5xS5vko1smIE8RQIzl9bWHUjAJIGXaOJolHwRkNkqA cBiQ3u8fzBbMulphqnk8s6/WX52pfMPLlxLPl6uAc+6ZadCNiFdnvnD4vFnMo1wW fTIknfyicH7d0Rt9SGd7f/TEbM2nNkm6hb8gPHfdHmfZ935lxlg= =ajrk -----END PGP SIGNATURE----- --su3aFBg80R6gXPbe--