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 1k8BSO-000076-QR for pgsql-committers@arkaria.postgresql.org; Tue, 18 Aug 2020 23:55:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k8BSN-0006hx-KH for pgsql-committers@arkaria.postgresql.org; Tue, 18 Aug 2020 23:55:55 +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 1k8BSN-0006hq-Et for pgsql-committers@lists.postgresql.org; Tue, 18 Aug 2020 23:55:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k8BSL-00078J-EB for pgsql-committers@lists.postgresql.org; Tue, 18 Aug 2020 23:55:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 07INtoti1356511; Tue, 18 Aug 2020 19:55:50 -0400 From: Tom Lane To: Andres Freund cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Fix race condition in snapshot caching when 2PC is used. In-reply-to: <20200818235152.4hxyb3hrvcm7pwom@alap3.anarazel.de> References: <1355915.1597794204@sss.pgh.pa.us> <20200818235152.4hxyb3hrvcm7pwom@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 18 Aug 2020 16:51:52 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1356509.1597794950.1@sss.pgh.pa.us> Date: Tue, 18 Aug 2020 19:55:50 -0400 Message-ID: <1356510.1597794950@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2020-08-18 19:43:24 -0400, Tom Lane wrote: >> Uh, is it really okay to modify that variable with only shared >> ProcArrayLock? > Uh, you're right. I assume it'll fix the buildfarm visible issue > regardless, but we surely don't want to rely on that. Yeah, having a failure show on the buildfarm would take an order of magnitude (at least) tighter timing than what we're seeing now. But I think it could possibly be a problem on big production iron. > I'm inclined to just make ClearTransaction take an exclusive lock - the > rest of the 2PC operations are so heavyweight that I can't imagine > making a difference. When I tested the locking changes in > ProcArrayAdd()/Remove() the more heavyweight locking wasn't at all > visible. I was wondering if it'd be sensible to convert that counter into an atomic variable. That's not real clear, but worth thinking about. regards, tom lane