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 1kbBLD-0005RZ-T3 for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Nov 2020 23:40:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kbBLC-00088Y-Qh for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Nov 2020 23:40:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kbBLB-00088R-SB for pgsql-hackers@lists.postgresql.org; Fri, 06 Nov 2020 23:40:22 +0000 Received: from [66.111.4.27] (helo=out3-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kbBL9-0001ci-Di for pgsql-hackers@postgresql.org; Fri, 06 Nov 2020 23:40:20 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 82FFB5C008E; Fri, 6 Nov 2020 18:40:08 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 06 Nov 2020 18:40:08 -0500 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:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=ix++NMmm7GDVmwZwV io9OIsqASdq1/7BWvtv2sgzHO0=; b=fhiEKEcfQg52ZcHnQ8e0ty08aqgrQ4aA/ cnGeheGnwM7SrOmk+D+adrWu5xjvBnAcKqpLATN0wI699kKTj/hxvStoJJ0J1wFl tcl6LuZd+Gue+QkFeUgH3NqSOEfKY3SFzbq4R4VI5PlfRSs+LTgnOYHm9Nf/X6o7 gJeicAA/7H4f+v0AefumS6B2SyFKRocwrl1cXXIgxDe0mdZ7MOudT+5a3yJopZcN Tm0tbySOwRcxdV0Ydw8Gel+vpW9uk8KVxSBqNZ1OPh0ccZadpu9wRlxZsiDVO8f4 r69L7Ub7BEcBl8jdXrRiHAtl/wPOU1cP9KkPqS36VOtYV3Ipa3WoQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddutddguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggujggfsehttdertddtredvnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpeevgfelveegueejgefhgeetgefhgeehieefheehleetteei udeiiefhgffgheffteenucfkphepudeltddrleehrdduledrudegkeenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghl vhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.148]) by mail.messagingengine.com (Postfix) with ESMTPA id B3775328041B; Fri, 6 Nov 2020 18:40:07 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 1DDBC2A0FDA; Fri, 6 Nov 2020 20:40:05 -0300 (-03) Date: Fri, 6 Nov 2020 20:40:05 -0300 From: Alvaro Herrera To: Michael Paquier Cc: Justin Pryzby , pgsql-hackers@postgresql.org Subject: Re: list_free() in index_get_partition() Message-ID: <20201106234005.GA23227@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201106003235.GC21123@paquier.xyz> User-Agent: Mutt/1.10.1 (2018-07-13) X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.27 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Nov-06, Michael Paquier wrote: > On Thu, Nov 05, 2020 at 02:36:06PM -0600, Justin Pryzby wrote: > > Seems to be missing. > > Any code paths calling index_get_partition() is in tablecmds.c, > involving commands that are not that hot with such lookups, but that > could be an issue if this gets called by some out-of-core code if > memory context cleanup is sloppy. So I agree to fix this one and > backpatch down to 12. I'd like to apply your fix, except if Alvaro > thinks differently as that's his commit originally. So let's wait a > bit first. Agreed; I'll get this pushed now. Thanks for reporting. > > The 2nd patch does some more cleanup - Before, a failed syscache lookup would > > ERROR, but I don't think that's supposed to happen. get_rel_relispartition() > > would instead return false, and we won't call get_partition_parent(). > > The cache lookup error is here as a safeguard to remind that any code > path calling index_get_partition() needs a proper lock on the > relations involved before doing such lookups, so that's a defensive > move. By switching the code as you do in 0002, you could mask such > logical problems as different errors could get raised. So I don't > think that it is a good idea. Yeah, I'm not so sure either. I have memories of purposefully not using get_rel_relispartition there, but I don't remember exactly why and it's not in the archives.