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 1w255w-000rWJ-0Y for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2026 10:22:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w255v-009Dek-0p for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2026 10:22:44 +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 1w255u-009Dec-28 for pgsql-hackers@lists.postgresql.org; Mon, 16 Mar 2026 10:22:43 +0000 Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w255s-00000000PFu-2GsA for pgsql-hackers@lists.postgresql.org; Mon, 16 Mar 2026 10:22:43 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 7A5B47A01ED; Mon, 16 Mar 2026 06:22:38 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Mon, 16 Mar 2026 06:22:38 -0400 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=1773656558; x=1773742958; bh=YoGCUrGhc1 ntmzHSuw/KBZUCVGJi1SRZLUXmYXe/RjU=; b=cyXVKUk4u4ll2rhJIMc1Cp/6oe xyDikchkNOmmV/k8bMFEu1saFCJn+RCORSKGtJUux1lj1tqRTVLLKULkvewyOFq3 jHBXnY2KsleSmqX39a2Mpxsv5Agwh/zIFCynuwnj6eIO0N8ZLQEPUX4lQBsTCnHJ qCui64FJi796VaT+xMLne7OuHcOxjDH+yqmvdVvteX9UKV0qlUs1fro25qGuoQKR CUbfRErDh0r4P8chvsbZUU+m5uarhb4CZeQeWtrCQxA2m7h/gz5CmK6iUl5TDTyz FUef1pUdVFYhWkXVBm+GWGkLHRwr0QvVLXBJRnRne1/4lSvU/AA6Zbf12Y3Q== 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= 1773656558; x=1773742958; bh=YoGCUrGhc1ntmzHSuw/KBZUCVGJi1SRZLUX mYXe/RjU=; b=QDFMOnaRyV/KaqBzSi0yumQIF2NP8sMhG8KLrPiFjpicT7CnXgS IeIQXg0PcncAc4/Sba/XO8LYxVBPDwIRdNuQY5pf7xn5rWPKxHHJyNWKXxXrb0FG n/FNSQCR1eYT3EzYT6P/Aa/qjimoioFVi5uVV4/ZtDphcf7D/0g8rlDe+oq0Skdi QlmEwV4HrrpeIese60O0bgWnwoyyhGyKd+3XILXlixqm9S1XrWLrK8GIZ4gr1md+ hzoSFklR9BlfCImmG/TXrDTMkSO458gbU/woqXStYaaU/L4UOho7n3Ez7/m35G4k n+AAIFdwK/Cn8ylMQTPvrp9zuxpFjobCoWA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvleekudefucetufdoteggodetrf 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, 16 Mar 2026 06:22:36 -0400 (EDT) Date: Mon, 16 Mar 2026 19:22: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="rWsrufS7v1CQKxQq" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --rWsrufS7v1CQKxQq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 16, 2026 at 09:20:41AM +0000, Bertrand Drouvot wrote: > I did not look closely at the code but did some testing too. I confirm th= at > pg_stat_io and pg_stat_wal are updated when pg_stat_report()= is > triggered. But the stats update is not visible if requested through > pg_stat_get_backend_io() or pg_stat_get_backend_wal()). > I guess that PGSTAT_KIND_BACKEND should also get the PGSTAT_REPORT_TRANSA= CTION > report_context? Yes, I guess that the transaction-level flag should be set as well for the backend stats, due to the fact that WAL and IO stats have it set. >> Note that this is a WIP, which is check-world stable. One thing that >> sticks a bit in mind now is that perhaps we should not allow the >> function for auxiliary processes at all. >=20 > Why? I was feeling that there would be an issue with that, and I did not test it in details yet. For the checkpointer with a busy activity, the IO stats could be interesting to see in live. >> Perhaps we should just have pgstat_flush_pending_entries() provide a >> correct status in line with the property set in a stats kind when we >> try a flush while in a transaction. >=20 > The idea would be to avoid trying to flush stats that don't have pending > entries? I had to work around the assert at the end of pgstat_report_stat(), to tell that under an xact the partial flushes were OK. I was wondering about keeping the end assertion based on solely "force" intact, making the flush routines return a status based on if we are in an xact. > That looks "simpler" that the previous proposal but who would be responsi= ble to > call pg_stat_report()? If that's the client responsabilty that kind of lo= ok weird > to me. If that's the core, how would that be scheduled? I think that the > end solution should prevent to find similar issues as 039549d70f6 fixed, = without > delegating to the client. TBH, I don't like the requirement of setting SIGALRM in all the places where we'd require it for the sake of this proposal, where historically we have never done that, copying a mechanism that already exists in the tree for procsigs, as the previous patch I posted proves we could reuse. It's also not clear to me what a correct frequency of the stat updates should be, and why it would make sense to force that in a GUC; we want to have some information from long-running transactions, where I fear that we will want modularity. A user-settable GUC would fit with this picture, but the requirement of planting the timeouts don't stick for me.. On top of that, I am not really convinced that there is a good reason to remove the existing stat report calls we have already planted in the tree for auxiliary processes, diverging from the stable branches where these exist. With more than one release already out with them, there is more benefit with potentially planting more strategic report calls where they could matter (as added in v18 for WAL senders as one example), when we find a requirement for them. -- Michael --rWsrufS7v1CQKxQq Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmm32ecACgkQnvQgOdby QH3zXRAAjeiP6aTp3OqqBAjALN3B5JciP5S7mz7XWtvmw8JJMb8FxcHx1v383ZyY RQStlRW55oD+3e8IPTDTJwowB74LNC1addocHfIGaYcI4DfhhQq3TL6V0VJq46Se cM+zaDzVBfn9fv+W9Hakw9mCLYpbK1ISUW09WnBgtVAmyMO3am093SpLwW2AGxtB CQAhJ6A1RjJYVukbeHSOkvg/m0XTv9IZx0hLX1O5bKqjvRn24D7zIJzL3vR+jqUC W8JGhQIkzhqBTfaQMmdWQ3B5wjBtZslAW5OOCqixmLBrzwM8IZgRM06ZLH6ighbU d/CPb070wgPUCUgdIqO8ICKnLdQABdZk7PhJJDomq2herIA9S2vOp2Q+Im0sKLeZ rIw5FUzIxXD1sUR2dQQ69ibzU85bDEQer8nQflmc4RfNnTyoSjcb0vDOtGi3vJtd fLWZtT1IWSymR+LpYwSGTQjQUKKkKFx+UeeNrHIhzQjjmPJE3oaUaMCo52FOCA0Q VgYWoTXt9WdJV7oqLGyGI2tuKnaprqOzquOhrrmlkQPfEbbVrTGwiZArTCOGgfpk +OEPF8m67gR3putcXRcowlB4aj9Bi9lFrcId0FDRG2f/EBL31rLT7r9eXyLAQBBF lZHop1FotVExFprDV6RASQUatueYWoUjGTRygoYhxWmzhWRIkho= =+JLn -----END PGP SIGNATURE----- --rWsrufS7v1CQKxQq--