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 1k8BIZ-0008B2-Px for pgsql-committers@arkaria.postgresql.org; Tue, 18 Aug 2020 23:45:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k8BIY-0000ba-No for pgsql-committers@arkaria.postgresql.org; Tue, 18 Aug 2020 23:45:46 +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 1k8BIX-0000bS-1A for pgsql-committers@lists.postgresql.org; Tue, 18 Aug 2020 23:45:46 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k8BIP-0001IZ-4b for pgsql-committers@lists.postgresql.org; Tue, 18 Aug 2020 23:45:44 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 841855C0111; Tue, 18 Aug 2020 19:45:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 18 Aug 2020 19:45:34 -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=vNtZKkhm5rJUp0Nar1yjFhV0hHW 76SoPKQE2weXNQ3o=; b=VwiVDnCPJEN5C94Pt4e3CW55wRf1HK+fcyqwr4ktQXW iiQWWaMQdt2qU/kgPaiuanJ9DYKWPKNdhkRQlFjeeZuGyUFlO8lmGwxn681mCcQq DF/XCjiP3/SfI5TMKrV4QRhPirEhMGHd+i0VVIuqLQGik/d+qDKjcLuEW4cQMpBP pa5S8S/8QvkRYyEf1ZzBlMzfqlJ2uAqEIF+MH5ajnGkFIAOMm0IwBBl2zFCn5bj8 CGT8ICdRUXpq6Lg4MaHHy48DmBvNXpMx+9U/6wvYZBRyv02TkbIkbwusOrltRbXZ 5kwUQXGoiU61oJoUGNV4Dg3DYQpDO2dQ7tHF4T4UZqA== 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=vNtZKk hm5rJUp0Nar1yjFhV0hHW76SoPKQE2weXNQ3o=; b=tvT1V80Z6QFfg/ppemzz+8 pgDRnJ5kKco6l02Q56Pcojr6XKVTw2Q9Bl7u3VEjIH5oQbM1Fxy0KGhrpwB6PoLm OoX1fHgWJijspx4wrV7zT4ttSE9eil5UarApJGfTY4kuvZl+4jpMtaQ8w/4m+Qxs JHK1EMzwL+aTASOvzSKoCLjXQymdL1jJGqvXcd9idq50yMTuACyxyHtG3GcZgsrD aPG7nvrhoU8Y41VK6hZIgq9Q0qDwq2DLDHS4YGXeUKbR+A525qlsooLjn869spXo b7eNQAWyQBpOrjKEggoDAkqT5HVSSBpI23RGJ/GivlmpJVwtTk4hUQEYae53mgog == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddtjedgvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedukefhkeelueegveetheelffffjeegleeuudelfeefuedtleffueejfffh ueffudenucfkphepieejrdduiedtrddvudejrddvhedtnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdr uggv 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 51742306005F; Tue, 18 Aug 2020 19:45:33 -0400 (EDT) Date: Tue, 18 Aug 2020 16:45:32 -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: <20200818234532.uiafo5br5lo6zhya@alap3.anarazel.de> References: <20200818045246.GC3813@paquier.xyz> <20200818051832.r2lixs4qi5whkqco@alap3.anarazel.de> <1175198.1597728077@sss.pgh.pa.us> <20200818202805.5f7rbfh2zyfkzqqq@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200818202805.5f7rbfh2zyfkzqqq@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-08-18 13:28:05 -0700, Andres Freund wrote: > 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. I pushed a fix. After a while I figured out that it's not actually that hard to test reliably. But it does require multiple sessions interacting, particularly another session needs to acquire and commit a transaction id that's later than the prepared transaction's. I think it's worth adding an isolation test. But it doesn't seem like extending prepared-transactions.spec makes too much sense, it doesn't fit in well. It's a lot easier to reproduce the issue without SERIALIZABLE, for example. Generally the file seems more about serializable than 2PC... So unless somebody disagrees I'm gonna add a new prepared-transactions-2.spec. Greetings, Andres Freund