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 1w9cFO-001acM-0a for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 05:11:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w9cFL-006YiE-2q for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 05:11:36 +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 1w9cFL-006Yi6-0T for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 05:11:36 +0000 Received: from fout-b6-smtp.messagingengine.com ([202.12.124.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w9cFI-00000000qd7-1a49 for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 05:11:35 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id C442F1D000B8; Mon, 6 Apr 2026 01:11:29 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Mon, 06 Apr 2026 01:11:30 -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=fm2; t=1775452289; x=1775538689; bh=p5FpuJRFdO Eck94kOKmJzE3bJVd+HYuKLsMEDq5CqMk=; b=dbNbqQGJ2bIcVsKE5ce68//WYx xaHnOY9Ad9BWFJm829RKECY20CgNewJOOtyEIXJ4eZLCYo2qXXZcYUhaG+EBWz5L aVBIU7GeSdDkobekaKHe2za1qpSR2qXqYapWmCqrcnMNYgTlUCcl77D+vb3CQF6K qJweBdQO8wod7QBUCBx3HWExNg+G9zTLt28MTnlNPMWUUnllr9+ztQLs3HQWTXlV Tc2So0EhIh7A0AHX6IR1Xtd8gF27Qb1a1aEa+AvZ31T/Cjn+yZKei8hKJL9VJOOL j0iTyIJm2rG0ZugPR2AgZSETYF5wz4SNKMcsv6XD/Z6qYm57qTkwwapo8R4A== 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=fm2; t= 1775452289; x=1775538689; bh=p5FpuJRFdOEck94kOKmJzE3bJVd+HYuKLsM EDq5CqMk=; b=dro0mxyrGOoBm8owBRHcZih32gyNnhOJgUD9u2uRLQ2j0opFJRX 89yUpnsbpy5g0OVnx8ZK5zs4sz4KTbbdkJaA7/45ee1h7Q3PYjggYZz7fgVsJOyr n5vHL62kZEaRtFPC8kuZUG+1ImrhU4+tarPr9L/b6OFHCtToo63enH9Kxi49k32Q adMupDKD327D4ESGdH6xG1ExVkwx7WQOiPMwrtsS/5beQDcXN5w1wQATTvOT3bWh o55K7HapfHs8LFULfvtrURA+NRwL6OD6mIc4wgfcDTSZYFOx4Jto1AEQZrPJIwio F5BBi8a2cN/fplTmSgdMj8AWkKWRclBGDlw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduieekudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeeipdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegsvghrth hrrghnuggurhhouhhvohhtrdhpghesghhmrghilhdrtghomhdprhgtphhtthhopehtohhm rghssehvohhnughrrgdrmhgvpdhrtghpthhtoheprghnughrvghssegrnhgrrhgriigvlh druggvpdhrtghpthhtohepphhgshhqlhesjhdquggrvhhishdrtghomhdprhgtphhtthho pehhthgrmhhfihgushesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrg gtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 6 Apr 2026 01:11:26 -0400 (EDT) Date: Mon, 6 Apr 2026 14:11:21 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: Tomas Vondra , Andres Freund , Jeff Davis , Greg Sabino Mullane , pgsql-hackers@lists.postgresql.org Subject: Re: Adding locks statistics Message-ID: References: <1af63e6d-16d5-4d5b-9b03-11472ef1adf9@vondra.me> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xHO7SDolA9bWCz7w" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --xHO7SDolA9bWCz7w Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 31, 2026 at 07:10:51AM +0000, Bertrand Drouvot wrote: > On Mon, Mar 30, 2026 at 06:11:17PM +0200, Tomas Vondra wrote: >> Isn't pgstat_lock_flush_cb a bit broken with nowait=3Dtrue? It'll skip >> flushing stats for that particular lock type, but then it'll happily >> reset the pending stats anyway, forgetting the stats. >>=20 >> AFAIK it should keep the pending stats, and flush them sometime lager, >> when the lock is not contended. That's what the other flush callbacks >> do, at least. This probably means it needs to reset the entries one by >> one, not the whole struct at once. >=20 > Oh right, it's currently misbehaving, thanks for the warning! Not misbehaving, mistaken. This would create loss of stats data that should have been flushed. I should not have missed that, sorry about that. A single-lock approach is also something we do for SLRU and WAL data, and these are much hotter. At the exception of one comment that could be simplified, the code removed is correct, so addressed this one as well.=20 -- Michael --xHO7SDolA9bWCz7w Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmnTQHkACgkQnvQgOdby QH1Ekw//ej4PqMQOzfLuOuj4hoYZ5GM6O0YcBGHYc9dE6t2CBL1/WVKxBsaRG5EK 0UguwszBcSvUXmUChuFp8VklX6gbagJQKtngCdSCpCqPP3JJA7r1fUQ3Kl1Q8ZsR i9vn3Ygnb8wUNfoOVjUJnvXzjw4Ki/wH8xQctoV0oi970/yVZnmHm/K/ByCDZxHY Q7+isEObieVE7pZ2CdOXxxOi44f+UjIWP2pld0toEwZs5wG2BXtY9E1NFivQXY9k 4q2irE9rgmqXgJ1WSyLlfWjRM4BcjLJoYNqcM74skG5Ob879SWoiA4egNEPI4DkQ LxkTYZq/eUlo1UjNSSi7gCQAVFWAXuKwqr1Ghy1UNrABz9cknt2++QS2Sgv/syuD LWRcB5jtyb8fpP+AqUq+ZAl+pLBTAtpI/TmQZyU1yjx0E1X3uR3cHfYsuHB2htxV /kGTQV0hbfjGcisB2dcjiEn1D1aJybAlAx9fL3PHGfom8X4VJEXSwC7IJerkr61F vYva7l4picOTetyZ8pNXv6nmgPf/t296pufNdFLs3bABewfQD07wOXgpUH+z2VHq GNOn8Q7CY8kEA+n/8XlW1rwRmWBOZWZmg8runpn3+tV6qKusimHcey4cDx2aC9zt OruiWo0DBQLSlQMslHOH3RXgtA6T5c+20BDHezSvzE2F3JI6620= =0z53 -----END PGP SIGNATURE----- --xHO7SDolA9bWCz7w--