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 1jMg2M-0003qV-A8 for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2020 22:52:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jMg2K-0004JG-1f for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2020 22:52:40 +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 1jMg2J-0004Ht-Qh for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2020 22:52:39 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jMg2H-00073E-3T for pgsql-hackers@postgresql.org; Thu, 09 Apr 2020 22:52:38 +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 039MqWgB015496; Thu, 9 Apr 2020 18:52:33 -0400 From: Tom Lane To: Andres Freund cc: Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: Catalog invalidations vs catalog scans vs ScanPgRelation() In-reply-to: <20200409223249.pmezmufk24z7t5wu@alap3.anarazel.de> References: <20200229052459.wzhqnbhrriezg4v2@alap3.anarazel.de> <20200229061052.qceiitudgo5es3ns@alap3.anarazel.de> <20200229201707.jvmau4x5nof2dywx@alap3.anarazel.de> <20200409223249.pmezmufk24z7t5wu@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Thu, 09 Apr 2020 15:32:49 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <15494.1586472752.1@sss.pgh.pa.us> Date: Thu, 09 Apr 2020 18:52:32 -0400 Message-ID: <15495.1586472752@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2020-04-09 16:56:03 -0400, Robert Haas wrote: >> That seems like a fairly magical coding rule that will happen to work >> in most practical cases but isn't really a principled approach to the >> problem. > I'm not sure it'd be that magical to only release resources at > CommitTransactionCommand() time. We kinda do that for a few other things > already. I'd be worried about consumption of resources during a long transaction. But maybe we could release at CommandCounterIncrement? Still, I tend to agree with Robert that associating a snap with an open catalog scan is the right way. I have vague memories that a long time ago, all catalog modifications were done via the fetch-from-a- scan-and-update approach. Starting from a catcache tuple instead is a relative newbie. If we're going to forbid using a catcache tuple as the starting point for updates, one way to enforce it would be to have the catcache not save the TID. regards, tom lane