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 1vuffP-000nXI-10 for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Feb 2026 23:48: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 1vuffN-00FyzC-0c for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Feb 2026 23:48: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 1vuffM-00Fyz4-2r for pgsql-hackers@lists.postgresql.org; Mon, 23 Feb 2026 23:48:40 +0000 Received: from fout-b3-smtp.messagingengine.com ([202.12.124.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vuffJ-00000000wiC-2fd6 for pgsql-hackers@lists.postgresql.org; Mon, 23 Feb 2026 23:48:40 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id A1B591D000DD; Mon, 23 Feb 2026 18:48:36 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Mon, 23 Feb 2026 18:48: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=1771890516; x=1771976916; bh=jnyHalI0dN 0tICCJmLcsQCAXEEWoURHtQfwjMPUawLQ=; b=AlP2NE/IQZWrNBgbFUt5tM3EAB ff377qsoFTpTdFtJTUED7fQdgDrW0cZgfXoSWRfWBUFj336c7dIeQBJQLKtNOOsn p5TX03MbmA2kgrMaXdsb9Qyq8/g9oBqaI53vKRLwyPOo2r0mxaZtOKiM43gKyVPv rWcOCeseofjysy5oaswCTHdu7w/ITLWQTzUHpeo3qruUmlS+SVt9kI0so6UxMSJT m2udumCgZ++uMrE1v5AlIDZa0l7UUjOeOji/8ma5M1k8/GNxAT2WOfRtn4e4dsg3 zgrDaWMR8pAaGnUFGlFaqg7L/sMk4ZfuUeNSj4pezUBjUt3jHJ8AV8I/5fbA== 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= 1771890516; x=1771976916; bh=jnyHalI0dN0tICCJmLcsQCAXEEWoURHtQfw jMPUawLQ=; b=freXrinUf6DPE0Ma8CmkJdgLbN6+cO1M5ijDRWL5ITW0ErjE/zR zAvv+W67BuZl3d/+CPn8DWBIzrAILgkTFaTKW7vEx334Kd/dlIc+Q+3VcB0AVPxa dGRFli+eE8DrVvEaCphAMkljs7XMCkn+WiNdVBb5zyfZ9c8a7jjd1Jni2KsQJVwg BnLz8/6N4nmH8V0AZp6M6lLnsCL3yhjP8pVm9BTMccvL+TQrW+XnHRe4tX9Fpp3o uqcAD90USQL3lHWRex27gXfmvn/B0AbT+e46AYpaup5cGDkfEHvVfMRFNT2IsiFP /cz+e/IlKmkCc2rlnOuRbtDQAwJPg+6f+6g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvfeekieduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeggeeg fffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidp nhgspghrtghpthhtohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsggvrh htrhgrnhguughrohhuvhhothdrphhgsehgmhgrihhlrdgtohhmpdhrtghpthhtohepshgr mhhimhhsvghihhesghhmrghilhdrtghomhdprhgtphhtthhopehmrghsrghordhfuhhjih hisehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhi shhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepiihsohhlthdrphgrrh hrrghgihesphgvrhgtohhnrgdrtghomh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 23 Feb 2026 18:48:34 -0500 (EST) Date: Tue, 24 Feb 2026 08:48:31 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: Sami Imseih , Fujii Masao , pgsql-hackers@lists.postgresql.org, Zsolt Parragi Subject: Re: Flush some statistics within running transactions Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Xku8+Uc6A9t7wHbs" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Xku8+Uc6A9t7wHbs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 19, 2026 at 08:01:36AM +0000, Bertrand Drouvot wrote: > On Thu, Feb 19, 2026 at 12:58:12PM +0900, Michael Paquier wrote: >> 2) The timeout requirement itself, relying on a timeout threshold >> controlled by a backend-side configuration. >=20 > What are you concerns with this?=20 I am concerned about the three additional points/requirements: 1) The need for all processes who want to flush non-transactional stats to set up timeouts, unconditionally, which is what the patch shows with the new InitializeTimeouts() calls added for example for auxiliary processes. This forces the use of SIGALRM in these processes, with a new handler, and feels like a requirement too heavy for the sake of some stats flushes. This requires an extra unconditional RegisterTimeout(), as well. 2) The need for all the stats to call pgstat_schedule_anytime_update() in strategical places. This is less of a burden compared to 1), but this leads to more complications in these code paths with the coding requirements, especially for custom stats kinds. 3) Enforcing a flush timeout unconditionally. One thing that slightly concerns me here is that it seems easier to misuse compared to a client-based facility, where a too aggressive setup could stress more the server-side pgstats. It is true that the client-side could be misused too. My main worries are mainly around 1), I guess, with the new SIGALRM handler requirements for all auxiliary processes. Using a procsignal path would allow us to rely on a solution that has the same flexibility, combined with strategic additional flush calls that we could spread depending on requirements we want to enforce in some processes, like in the WAL sender, or perhaps the checkpointer. That seems more careful in the long-run, and this can rely on the interrupt processing for the job. The addition of the property to track if a stats kind of OK to flush outside a transaction boundary is also critical to have, of course. I am sold to the point point of the design about this new property tracked in the stats kind meta-data. >> With that in mind, wouldn't it be simpler if we introduced an API that >> could be used from client applications instead, in a model similar >> what we do for procsignal.c/h?=20 >=20 > That's another angle to look at it but I think that giving this responsab= ility to > the clients would not solve the concerns we had in [1] (that led to 03954= 9d70f6 > and to this thread). It seems to me that a solution/design that does not = allow > us to "revert" 039549d70f6 does not suit our needs. Thoughts? 039549d70f6 goes in line with the "client" prospective, where I would like to think that strategic flush calls are more flexible. > Yeah, after our off-list discussion yesterday, I tried to implement the s= ame > trick that f1e251be80a has done with injection points (nice trick by the = way!), > but that led to: In this case, avoiding an injpoint allocation in a critical section would be a two-step process: - INJECTION_POINT_LOAD(), before the critical section, to warm up the cache and do all the allocations. - INJECTION_POINT_CACHED() with IS_INJECTION_POINT_ATTACHED() (optional), to run the point, in the critical section. This tactic is already in use in the tree. You would have to use a more complicated scheme to make sure that the wait machinery is initialized when using it in a critical section, but that can be worked around as well. See my "state-of-the-art" work of 15f68cebdcec, which, well, happens to work. Not really the best work ever with two points, but it works for this purpose. :D -- Michael --Xku8+Uc6A9t7wHbs Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmmc508ACgkQnvQgOdby QH2HcQ/+N7gYhtqVbZ/GDAVFRjYb8syiCudeXLOc5lA0t6yWKBOdA7DKn57WBvpn ZK65fnjRDhgYvLWtwT7dVkz0NiKtx4EjkvUiESc2Q1e8vqQ0tXJKz9eclNGheO3b 4luHyO7vpVLnyfikiJIXE59iy0rHYspmg24r1R48pIqJtqV51ZYt/uvWCthMNjjC giKLyoA3kheVLzOl5ZbzepKdvEbbnxpQjX6Ol6DA4YWWKlUXkNW4+erQiZMTr6Zz z3LROodOknX4DX1JC9hOss4kiMINtGzth2oLMXmbADKg2xVh5UuBPjXx8pukG5qT vWW9REaP9OALwcZpYGmjqjAS92E8N6S5OOVwEaJlnH1htZlXsUIS7sxrVjSihF76 vhRL+uXg3mH3Fh3xY4fof8Px0Wu0O+DK9vepZfwU8dimK6NHhtvUprp4XFBZ+EB1 PNGMubfr2k1ufkRB16fOMTjS+rqMn3oW1F23R9Rs4jtzGyKYXsI0hBJtP9UcZlNk jX40Npx8UhI+NuR7Hhl8nEAu5KqZHrTZq1nHrW2x9C/V9A7KU9ew3Fcjfx9o5Z2z r5z+0AQTp+nFq2CXhDITlg1aEwmservcGRlVxw/hN/Exr/n9KuHkSZTAnlL/GN2F qshByFmZTDZVGQSdjp5IT904+MOhG0DL1/igXRUNLxL5kfzssCU= =QPb6 -----END PGP SIGNATURE----- --Xku8+Uc6A9t7wHbs--