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.94.2) (envelope-from ) id 1tgHWd-009G7f-Dx for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Feb 2025 06:07:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tgHWc-00FjV0-Cd for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Feb 2025 06:07:38 +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.94.2) (envelope-from ) id 1tgHWb-00FjUs-4h for pgsql-hackers@lists.postgresql.org; Fri, 07 Feb 2025 06:07:38 +0000 Received: from fout-a4-smtp.messagingengine.com ([103.168.172.147]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tgHWY-003gLD-1h for pgsql-hackers@lists.postgresql.org; Fri, 07 Feb 2025 06:07:36 +0000 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfout.phl.internal (Postfix) with ESMTP id D3E9F1380092; Fri, 7 Feb 2025 01:07:33 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Fri, 07 Feb 2025 01:07:33 -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=1738908453; x=1738994853; bh=JlcFJt+bi1 xI6mPxppmwvT8v8rSKhZYSCqb3v1dNBE4=; b=qJAVW705BEO6OmWSmFZQFjOQjJ YMsZHa6qPJo9KZvj9YsU8LWygFuial1z4BZFpp16ImH4wOKl2D5crucYbwxWQsmd CEX+X+RZgjhJyUNMgghrlAbpmTmdQSfgqakwkRUJelZEtyde8WvFmkbaC7MfRGDX WmYqBLaO79xp8PAkoYxf02Qtwa79E11m+GZ9p+qezDeQF/1vTZV50GHsxorvRCT3 n8hUHUYZOU4fmxyb6QlXEk5JQTPr06r9IdRRhE0Dystcu5UlkjCXX7anYNOFTCYb lx3l/uorHihJ4gWj9erCou4zkjje+8M/SFUORcqksd/xqAjYBIgrNEomaehA== 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= 1738908453; x=1738994853; bh=JlcFJt+bi1xI6mPxppmwvT8v8rSKhZYSCqb 3v1dNBE4=; b=ieVOCKNV4+VGW0vFXSno8bnhaQdAC54MtmN+iEMXSkfRtU26IwI 4v2nMQ7VXK1cjfQR0e44RzDNTO6JuKyXMrtAOU5zPlKtamNsIrGibUejepse0drg OURXB71ApHouE+6llDm5q3mE8Zdpx1T4ytK3F9qjuTU5OA10Cwn1DnRJFhaSiu9S M6wg1O1RA26RIemhbMMsTtes5ZE4KN7V/5+gP/5WTt1Wxf1aRNpF8KvgGP1WtxQY JM0evTyGMBW7K56o8va23iTcwSyk79yMMiA9Ew29/wRXZsT5NI25tQ0rYJKNi7Fc cZLPIpPfJMwN7YO7EgOy27Si+WRkx+fUPtQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvkeehtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenfghrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffk fhggtggujgesghdtreertddtudenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrh cuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpefg heehgfdufedugfefleegieffgeefhfekfeffvdehfedutdehteegleetveekteenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghl sehprghquhhivghrrdighiiipdhnsggprhgtphhtthhopedufedpmhhouggvpehsmhhtph houhhtpdhrtghpthhtohepphhgshhqlhesjhdquggrvhhishdrtghomhdprhgtphhtthho pegtohhrvgihrdhhuhhinhhkvghrsehgmhgrihhlrdgtohhmpdhrtghpthhtohepjhhirg hnrdhunhhivhgvrhhsrghlihhthiesghhmrghilhdrtghomhdprhgtphhtthhopehnrght hhgrnhgusghoshhsrghrthesghhmrghilhdrtghomhdprhgtphhtthhopegsrhhutggvse hmohhmjhhirghnrdhushdprhgtphhtthhopegsohgvkhgvfihurhhmodhpohhsthhgrhgv shesghhmrghilhdrtghomhdprhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdruh hspdhrtghpthhtohepmhgrghhnuhhssehhrghgrghnuggvrhdrnhgvthdprhgtphhtthho pehsfhhrohhsthesshhnohifmhgrnhdrnhgvth X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Feb 2025 01:07:29 -0500 (EST) Date: Fri, 7 Feb 2025 15:07:18 +0900 From: Michael Paquier To: Jeff Davis Cc: Corey Huinker , jian he , Nathan Bossart , Bruce Momjian , Matthias van de Meent , Tom Lane , Magnus Hagander , Stephen Frost , Ashutosh Bapat , Peter Smith , PostgreSQL Hackers , alvherre@alvh.no-ip.org Subject: Re: Statistics Import and Export Message-ID: References: <0b4c098ae3968aa23d6accb691f47bdba143aedd.camel@j-davis.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="XDFYX0w6a4LLHgjt" Content-Disposition: inline In-Reply-To: <0b4c098ae3968aa23d6accb691f47bdba143aedd.camel@j-davis.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --XDFYX0w6a4LLHgjt Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 05, 2025 at 08:45:06PM -0800, Jeff Davis wrote: > v45-0001 addresses this by locking both the partitioned index, as well > as its table, in ShareUpdateExclusive mode. That satisfies the in-place > update requirement to take a ShareUpdateExclusiveLock on the > partitioned index, while otherwise being the same as normal indexes > (and therefore unlikely to cause a problem if ANALYZE sets stats on > partitioned indexes in the future). >=20 > That means: > *=A0For indexes: ShareUpdateExclusiveLock on table and AccessShareLock > on index > * For partitioned indexes: ShareUpdateExclusiveLock on table and > ShareUpdateExclusiveLock on index > * Otherwise, ShareupdateExclusiveLock on the relation >=20 > which makes sense to me. The v45-0001 patch itself could use some > cleanup, but I can take care of that at commit time if we agree on the > locking scheme. Fine by me. The regression tests of v45 and v46 are a bit fuzzy regarding the tests around locking for partitioned tables. For example, with v46 applied on top of HEAD, if I manipulate the internals of the patch in stats_check_arg_pair() so as we don't take a lock on the parent table, then a make check is still happy and passes even if the internals are clearly broken. I would recommend to work a bit more the tests by updating the stats of a relation with the SQL functions in a transaction and add some queries on pg_locks for locktype =3D 'relation' that are able to check the locks we are taking when running these operations (return pairs of relation::regclass and mode, for example). Doing that for non-partitioned relations is also something I would do, so as the locking schema we are using is clearly tracked and that future manipulations of the area would help one in tracking problems. Bonus points: scans of pg_locks are cheap tests. -- Michael --XDFYX0w6a4LLHgjt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmeloxYACgkQnvQgOdby QH2elBAAgtVDlNGaHM5VoigVPaRAwnE77nJk5J/pzF2i3dqR/r6c2Zxr//7BRhs0 Zf+hStpeuHJ+5R+pbibczy8VfBkz0ZAVgkGtd8w/mB4lCGiIeW/FitSaxHMXEZuZ myNWVcEjR6dT9a4epIhHnJqUCORTnbe7NThOmS+RPpdJrnAM2bRpSB1lLrthJrNy oH9EplIXk84/7AGi1eE9JD/GcHGkoQQ2smwdF/I+OeKXqePuO3Cri3JCEjg2rLNB u6hnGdtwUl8fFSO7cmCtu88h7qzlOFAUFU1S8rdKIj4KxjkP04Z0vLpLaHs8t9PC xyCWuxPp7a2tr3eVnEWpz8/gC7GOarw5jtEp4wQqiq2hGaWG0Mxy4Uq+yF9+2Eus 1MsgIJbIcg6YGwQgFJi2haoVF4vzjM9roTum+rCfhBSHoLh6s6VPhWIu9JTncklG nuByVia0oSSzb8ePIqsdshEcW1qORdwa2krplB/oGpGhGcgJwvsLTa98UgtENkJS 9gTs4ASNN1T0n6vjgmtJig2jaVzVyeqkn3R6nUV8IZWr78P2qNHIe2QTaAOBJAJW 6aAYssVZ74KxfyeUxmhjrUGWf6HfWFH1DgRlgC5sPTsXWOZniqugk7wNYVXS8sTL YiU5UnHcHeb3L2c6axP/wPsBG4vvMUbLAI/7SLCNuBQ+mFoqVY0= =D61V -----END PGP SIGNATURE----- --XDFYX0w6a4LLHgjt--