Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lvXBu-0000Ym-Ar for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Jun 2021 03:35:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lvXBs-0000d3-5p for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Jun 2021 03:35:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lvXBq-0000cu-Nv for pgsql-bugs@lists.postgresql.org; Tue, 22 Jun 2021 03:35:07 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lvXBm-0000ay-Im for pgsql-bugs@lists.postgresql.org; Tue, 22 Jun 2021 03:35:06 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 05720E2F; Mon, 21 Jun 2021 23:34:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 21 Jun 2021 23:34:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=2AGwcyvvZt6fxbeBsSegH6WrQdj Af4JqNtJ+8wPSO4s=; b=vOJCx0lYnBPZtwnxxU3qSxCWUDsNtbzkP3toeFUVbUt BFWG4P9+RZW8aKj3kWMncVeEKwAMZo9D7cuvLWcuPL/fy+Q6lH0Aeu83GbVYXq7q wmXXP7s36E774VZwltsdKb7+THcRmdMK5dAyRY7eoWRglaRjhupMzuph8ieGDOIZ rBMjVj/1m0FI+oTQPcUXCLYgnFio0/rTI1GfUVYE9bCWwMbRfaeB6pmkP1v6L1wR IhnmvoP4eaHPnzPgNWkcGEaJd7DfrjdblH6nuKPMG7hv4NJnFSJQDVT0vetHRqv7 sJoV/4CmT67pbMUGqb+yRSWHOE4m4x2jWDqqz8bPF0Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=2AGwcy vvZt6fxbeBsSegH6WrQdjAf4JqNtJ+8wPSO4s=; b=fVt+P9rDlShJtD8O1wKiZo xqQ7qDnCg0s9swJ7+rmv0J/BHew50TDIh/q71GvZub3vWWjI8yF+Zcii34HwllV1 d7JfoINbP+6e+ow0PLUqrTre8aGbddsmucLNPb/UHjTm9RZJixItLV4/bNUBkFGF VqYCygWigFfS4WJcV5l8Na9q+gK9DkIT8IMndUG7GhzuRq9UkNuvp1cK4/LeTJTa Glzp1Gd1WY5axvG992egJNv4RL7i4nmRfuVvYwbk5OQqUXhQ1BdPMLuApXLSc7WV 12Jc2tjCtfCViwsVgmvcefGEji0ya+wWy2tuVgwrZEHa//0XMdBuv/tNMQa27S4g == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeegtddgjeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpedvgeduuefhtdeuleettdevjeeh heeiveeuieegleetgeeljeelieeuieehgeevhfenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Jun 2021 23:34:55 -0400 (EDT) Date: Tue, 22 Jun 2021 12:34:52 +0900 From: Michael Paquier To: Tom Lane Cc: Stephen Frost , Alvaro Herrera , exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17062: Assert failed in RemoveRoleFromObjectPolicy() on DROP OWNED policy applied to duplicate role Message-ID: References: <202106181925.x6ka3pktyblk@alvherre.pgsql> <1285334.1624046402@sss.pgh.pa.us> <1573181.1624220108@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xCkxcQcd6vGSHOtf" Content-Disposition: inline In-Reply-To: <1573181.1624220108@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --xCkxcQcd6vGSHOtf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Jun 20, 2021 at 04:15:08PM -0400, Tom Lane wrote: > Here's a draft patch that gets rid of all the seems-to-me-unnecessary > stuff in RemoveRoleFromObjectPolicy(). As I said before, the permission > check seems misguided, the rebuild of non-shared dependencies is a waste > of cycles, and the table locking is neither necessary nor well designed. > In this version, if somebody manages to commit a concurrent table drop, > policy change, etc, you just get a "tuple concurrently deleted" or > equivalent failure. That's much like most other DDL-conflict cases. Hm. This version still removes all the shared dependencies and rebuilds them from scratch for each role. Is that something you intended to change? > (I did not look to see if there's any documentation mentioning the > existing permission check. If there's not, I don't think we need any > doc changes, since this seems to me to be strictly less surprising > than the old behavior.) Don't see any. > There remains the question of whether we could preserve the policy > in the edge case of deleting the last role by letting its polroles go > to empty. But that's clearly not going to be a back-patchable change, > and I'm not terribly interested in working on it personally. What would be the advantage of keeping the policy around anyway? The code behaves like that since its introduction. If you decide to change that, note that the current code would fail to empty pg_policy.polroles as the array gets manipulated only when num_roles > 0. So this could leave around policies with roles part of it even after some DROP OWNED query. - if (!allowSystemTableMods && IsSystemRelation(rel)) - ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("permission denied: \"%s\" is a system catalog", - RelationGetRelationName(rel)))); - - if (!allowSystemTableMods && IsSystemRelation(rel)) - ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("permission denied: \"%s\" is a system - catalog", - RelationGetRelationName(rel)))); Right. This looks like a copy-paste coming from RangeVarCallbackForPolicy() and this removes the need to lock the relation of a policy. -- Michael --xCkxcQcd6vGSHOtf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmDRWlwACgkQnvQgOdby QH20dg//SANxtEfSGareKRF+4WF/khBl/n4zkWrHB1cewTMRdDloIHKVUxI9Nk5M w2Ab+EG1qXZQX9CHndWPYpdRVTzaNFCgXaS08eIi06ETOx8EjKKzdfVY3IBs81Lk rLBbGtpZgOGzBCs+Bbmh5lJC5f/Zb6J7OaHK36G8m5M6lFbpHL0lcCyUGoN+qr7W UFIkfIN50QZTeyoUI5a0JVbEt4T/OD6zKzUU86/dRJcq6TPjXa8DS0OuzbiQgEDT 39t+4SXWlHLR4ieaLUhT9h4BFNz8WMwcCixYV6g5zXHua71vpABOl7pHmrCbIKS7 zhuIKqX6SKo8dacmVzMJTw0Kyipr0aGdiNCQp0Ut/gNv1E0QJsf9FqLOXoxpfNY0 cYp/17DOhzMyHPn5Esj5Y4LTYLkxUBZHzy1wTQ5npafOIdc1K8qtgtUIT0Sz5WKF AE8i6G6Tx1J2HWoh3Pc0xDmPeXuPcFXCxCPgG0gyZCuBfZcL8ArhJVfgJEti2TM6 EiyowQd8XL9vp7S8KjjWIbKOfokPsbGk2unqSPWTxjjJSdUDPNGKwxEsmAflvqDV vNxIN9nbJaja3IS3nkLeo3S61KNFtTmXTL0AqmuutSixCBsL7B83+B35iES96NnE GsV+pnOOYHz6rmc2dQvOIZbF5LBuipwXqx/Lg+pr7G6cKR1K92A= =BZUB -----END PGP SIGNATURE----- --xCkxcQcd6vGSHOtf--