Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4nI1-00063i-Pt for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2019 13:54:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h4nI0-0002t3-C5 for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2019 13:54:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4nHz-0002mW-Vj for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2019 13:54:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4nHx-0007kn-Dp for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2019 13:54:22 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x2FDsJek030793; Fri, 15 Mar 2019 09:54:19 -0400 From: Tom Lane To: Robert Haas cc: Alvaro Herrera , PostgreSQL Hackers Subject: Re: hyrax vs. RelationBuildPartitionDesc In-reply-to: References: <20190313164232.GA5270@alvherre.pgsql> <7448.1552497345@sss.pgh.pa.us> <7961.1552498252@sss.pgh.pa.us> <10788.1552501588@sss.pgh.pa.us> <3969.1552581380@sss.pgh.pa.us> <15943.1552601288@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Fri, 15 Mar 2019 09:35:32 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30791.1552658059.1@sss.pgh.pa.us> Date: Fri, 15 Mar 2019 09:54:19 -0400 Message-ID: <30792.1552658059@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas writes: > On Thu, Mar 14, 2019 at 6:08 PM Tom Lane wrote: >> And it's >> still calling get_rel_relkind() in the rd_pdcxt context, potentially >> leaking a *lot* of stuff into that normally-long-lived context, since >> that will result in fresh catcache (and thence potentially relcache) >> loads in some cases. > That's really unfortunate. I know CLOBBER_CACHE_ALWAYS testing has a > lot of value, but get_rel_relkind() is the sort of function that > developers need to be able to call without worrying with creating a > massive memory leak. I don't find that to be a concern. The bug here is that random code is being called while CurrentMemoryContext is pointing to a long-lived context, and that's just a localized violation of a well understood coding convention. I don't think that that means we need some large fire drill in response. >> What I'm thinking, therefore, is that 2455ab488 had the right idea but >> didn't take it far enough. We should remove the temp-context logic it >> added to RelationBuildPartitionDesc and instead put that one level up, >> in RelationBuildDesc, where the same temp context can serve all of these >> leak-prone sub-facilities. > Yeah, that sounds good. OK, I'll have a go at that today. >> Possibly it'd make sense to conditionally compile this so that we only >> do it in a CLOBBER_CACHE_ALWAYS build. I'm not very sure about that, > I lean toward thinking it makes more sense to be consistent, but I'm > not sure that's right. My feeling right now is that the its-okay-to-leak policy has been in place for decades and we haven't detected a problem with it before. Hence, doing that differently in normal builds should require some positive evidence that it'd be beneficial (or at least not a net loss). I don't have the time or interest to collect such evidence. But I'm happy to set up the patch to make it easy for someone else to do so, if anyone is sufficiently excited about this to do the work. regards, tom lane