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 1vSpbO-006LN0-2S for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Dec 2025 04:45:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vSpbN-002pIp-0G for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Dec 2025 04:45:29 +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.96) (envelope-from ) id 1vSpbM-002pIf-2W for pgsql-hackers@lists.postgresql.org; Tue, 09 Dec 2025 04:45:29 +0000 Received: from fhigh-a3-smtp.messagingengine.com ([103.168.172.154]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vSpbK-003s2I-22 for pgsql-hackers@lists.postgresql.org; Tue, 09 Dec 2025 04:45:28 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id 1ECB614000F5; Mon, 8 Dec 2025 23:45:26 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Mon, 08 Dec 2025 23:45:26 -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=1765255526; x=1765341926; bh=6DmaE9cDL5 kdZVU6phuwNcAhbQf0LNxvA/88C07Rhmo=; b=CRCz4K2lXB+9B4C/HxpQJXwDrN Rd32DVOWaCLep0N+aqD9XP0Np0GxSE+Mlp7QsNG3u3nwFn8jTiv0n8HyJ0KFNy4N j1l+QxjTjhEPOa3GkG7fxkHCAGhmGNfeKS3I75aTG9dJEjpYzZJsPWLWYE1Jf2gZ q8TbXqcF9S3LY3GnFv3HIebqwUgJ/HMdReRX06jwyGJeDXj0Pp72ZP40uklIjcML NziCGjLZaKVCknJr/Via5ywXJnq/ci8W5wEMukknr+l1vKXpByPfhXZ6j7wuN1FV A3RBewTsxjElZh9a3sPdNxqz7osV5zVsGxReFioLVDhdk4hPAHZv8SkGx6Ng== 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= 1765255526; x=1765341926; bh=6DmaE9cDL5kdZVU6phuwNcAhbQf0LNxvA/8 8C07Rhmo=; b=ZG66DV19ttHuUPOxtwWfWQHcKXBNClUx0M61MXIXswNUalZneWu 1KykP0NkVQXmM4Dyr+iBnIfw8GdPQs+uvzrtjRxkdhctnz9A9hlf6Q+OrjsPWcrF ykfzGVmYWTwn31ucDusKrhQxz9a0zvv7u74C/Z/xpkSMMYHCDnfw0BwIweUY3a1G /SCKPXWINrBL9jNHOaes9ala4LwxeeLyEJCQ2GTBQNybHfKSJuGP5p4Q7+DI7r3o 6oVkeGlr6EayP71NoEUW1XYW6LMX5iCCQ+YBAc+yKy2HU+0HzzjlacpVigxsbEK2 BMKa0OUldQdSXBTDn8+AH/2bjJQUu+NEdGg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddukeeifecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehsrghmih hmshgvihhhsehgmhgrihhlrdgtohhmpdhrtghpthhtoheplhhirdgvvhgrnhdrtghhrgho sehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhish htshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 8 Dec 2025 23:45:24 -0500 (EST) Date: Tue, 9 Dec 2025 13:45:17 +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: <4FEEC2B8-D9CF-4BD0-AA7E-44CE3E27ADD8@gmail.com> <5EC13E39-B41E-464A-B382-0ACEB18A15BB@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="CPPyWJl1iIp+4DWY" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --CPPyWJl1iIp+4DWY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 08, 2025 at 09:57:15PM -0600, Sami Imseih wrote: > The way v5 is dealing with a deserialize failure is that when > it goes to error, the pgstat_reset_after_failure() will reset the > stats for all kinds, since pgstat_drop_all_entries() is called > during that call. So there is nothing for an extension to have > to do on its own. The extension will then clean-up resources > at the end when all the kinds are iterated over and > kind_info->end_extra_stats(STATS_READ) is called for each > kind. >=20 > Let me know if I'm still missing something? It seems to me that you are missing nothing here, and that Chao has missed the fact that the end of pgstat_read_statsfile() does a "goto done", meaning that we would take a round of end_extra_stats(STATS_READ) to do all the cleanup after resetting all the stats. That's what I would expect. +static inline bool pgstat_check_extra_callbacks(PgStat_Kind kind); [...] @@ -645,6 +656,13 @@ pgstat_initialize(void) + /* Check a kind's extra-data callback setup */ + for (PgStat_Kind kind =3D PGSTAT_KIND_BUILTIN_MIN; kind <=3D PGSTAT_KIND_= BUILTIN_MAX; kind++) + if (!pgstat_check_extra_callbacks(kind)) + ereport(ERROR, + errmsg("incomplete extra serialization callbacks for stats kind %d", + kind)); Why does this part need to run each time a backend initializes its access to pgstats? Shouldn't this happen only once when a stats kind is registered? pgstat_register_kind() should be the only code path that does such sanity checks. By the way, checking that to_serialized_extra_stats and kind_info->from_serialized_extra_stats need to be both defined is fine as these are coupled together, but I am not following the reason why end_extra_stats would need to be included in the set? For example, a stats kind could decide to add some data to the main pgstats file without creating extra files, hence they may not need to define end_extra_stats. -- Michael --CPPyWJl1iIp+4DWY Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmk3qV0ACgkQnvQgOdby QH2fmg//VaY2eJr7GTdnXTMo72MoZT26Eh+2xiMPGRIn9tF0AXzM4XG0CHhabnTb 7dSsAo89HznmpcRim144HErB9x+CzseCvedtCQEOh0CeG5Z3fVPACkG7NAvPLUe4 xLwYj1T2Gr2aBKtns5IwucQTp3TV5lVRRQ/o72qeACAPOZ+wix7q5FK7vz2HwI3Q P/1Tp1xxCBChPXTxYMey/DUZOhFMwtjNyWRy+wcVIRxuk/tI9V3vSg9sSMBl0lQu YOUfh8QkGsyNLGn3M86wM669f9FpYqS1OZvryjshUZF9pxO/KLYyc9N4pJt0Y+bw G1HR7N6o19mzt7K63TAR2zlSKn7sgAnCPKnTnoxhWvq9bnUbFWUj7GGBrwlqr71w J7TnVugYgt93gNxoX29S2NlPiJgDFpumr1S6s5IHelkdrZwTbZWtSwViwVC1ZNiE 6JErBcz9FRydhUotRfvS/44SoVtmFftjoNUHPvJFjSF4y7IgwPkjHpo7y6If/guX gzxnPuxKrOzNX1MqZdVAird2nIaIBDIRnA1PQzbTOgKk3U/kprh5FJwlrfr1zq/V R5qCjDscDsQ3gge6kC4E+zJU8LOeAusYUaBnO/2xj0CuZwU1yzs7JClvfqKQFIiF 0kqYMz7UoUXoGE/lId5/M9IY9k9R3mRSzYjUaAGhEkxXhqVhloo= =y9CZ -----END PGP SIGNATURE----- --CPPyWJl1iIp+4DWY--