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 1k88DZ-0000Sr-Gr for pgsql-committers@arkaria.postgresql.org; Tue, 18 Aug 2020 20:28:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k88DY-00069j-DT for pgsql-committers@arkaria.postgresql.org; Tue, 18 Aug 2020 20:28:24 +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 1k88DX-00069c-Gi for pgsql-committers@lists.postgresql.org; Tue, 18 Aug 2020 20:28:24 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k88DN-0007kR-Iw for pgsql-committers@lists.postgresql.org; Tue, 18 Aug 2020 20:28:23 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id A58905C0148; Tue, 18 Aug 2020 16:28:07 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 18 Aug 2020 16:28:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=t0p70z4UezCUxz6vNx0K7zDzaqc kjYKpIMyb3oucHbk=; b=Ok4QmQVYfIL1tqWpSk3ZEMCHte7C4J3wFihfw0BrRIy ItBleGcFFbSG4b2n523f+TPFT0QdsYUHCdmpVXwHSEhlNYR1p2mLrG58GtBZiLhc 4LdD2CJtQ4vSYbTAcVgnFGZDv3TMqj1yB3/fqUTgefvWTytaMSQFZBAZSzJ6N/7C dmRXGpOOE6ow9g/80l9cmeh+zGDCiHsjg6yyxK8sVyLNc7SxvQ3nIuJrq4xhqpsV rAQ/y6cg8qOtBZM6bq63LjNpBNS1A88wEDPziRuqc2eot+4NJ+/rDex8Jkhadt83 mXoVXj/0Crf7lt0liZWfoiS44t58nzMkofdj7+1oq+g== 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=t0p70z 4UezCUxz6vNx0K7zDzaqckjYKpIMyb3oucHbk=; b=ZgqKyrMAB4UmdVx8Nk6H70 1d5eez57WdhKEKmGwpZbAb7hpFLIFDZheHIVLJBf/Fmeg5yAOaL8u9fxCIhoLIR0 AbZfxTandw053+tNnZAednfhaH26j8+3rewO3yYZg8HMPPHTJJbLH94pScZhtzkv movdfyAvMomoXY7G/ECENnCdnL3IUAu8EZ6WJZ4O2HWh2GFVhbV4hj8ighE4zVAW G1xRh9E4sIv5bZ8e3s/FYhDFUFL8TaEN7IG0FBQWx6alZSCQ6rpeam1NByti/pV3 x/jgnO/5vHbiGvuF3xoETxwxd3fROa+0mGUfLL5OUqHogVCJtO36uIAsI/YMA6+A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddtiedguddvlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeff hfeuffdunecukfhppeeijedrudeitddrvddujedrvdehtdenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghl rdguvg X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-217-250.hsd1.ca.comcast.net [67.160.217.250]) by mail.messagingengine.com (Postfix) with ESMTPA id A08C4306005F; Tue, 18 Aug 2020 16:28:06 -0400 (EDT) Date: Tue, 18 Aug 2020 13:28:05 -0700 From: Andres Freund To: Tom Lane Cc: Michael Paquier , pgsql-committers@lists.postgresql.org Subject: Re: pgsql: snapshot scalability: cache snapshots using a xact completion co Message-ID: <20200818202805.5f7rbfh2zyfkzqqq@alap3.anarazel.de> References: <20200818045246.GC3813@paquier.xyz> <20200818051832.r2lixs4qi5whkqco@alap3.anarazel.de> <1175198.1597728077@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1175198.1597728077@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2020-08-18 01:21:17 -0400, Tom Lane wrote: > Andres Freund writes: > > I'd written to Tom that I was planning to revert unless the number of > > failures were lower than initially indicated. But that actually seems to > > have come to pass (the failures are quicker to report because they don't > > run the subsequent tests, of course). I'd like to let the failures > > accumulate a bit longer, say until tomorrow Midday if I haven't figured > > it out by then. With the hope of finding some detail to help pinpoint > > the issue. > > There's certainly no obvious pattern here, so I agree with waiting for > more data. FWIW, I think I have found the bug, but I'm still working to reproduce the issue reliably enough that I can verify that the fix actually works. The issue is basically that 2PC PREPARE is weird, WRT procarray. The last snapshot built with GetSnapshotData() before the PREPARE doesn't include its own transaction in ->xip[], as normal. PrepareTransaction() removes the "normal" entry with ProcArrayClearTransaction(), which so far doesn't increase the xact completion count. Because the xact completion count is not increased, snapshots can be reused as long as they're taken before the 2PC transaction is finished. That's fine for other backends, but for the backend doing the PrepareTransaction() it's not, because there ->xip doesn't include the own backend. It's a bit tricky to reproduce exactly the issue the BF is occasionally hitting, because the way ->xmax is computed *limits* the damage. Combined with the use of SERIALIZABLE (preventing recomputation of the data snapshot) that makes it somewhat hard to hit. Greetings, Andres Freund