Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEeZJ-0003TG-UA for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Oct 2018 18:04:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gEeZH-0001N4-0z for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Oct 2018 18:04:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEeZG-0001Mh-Mh for pgsql-hackers@lists.postgresql.org; Mon, 22 Oct 2018 18:04:42 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEeZD-00073W-WB for pgsql-hackers@postgresql.org; Mon, 22 Oct 2018 18:04:41 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 8FDA7CA5; Mon, 22 Oct 2018 14:04:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 22 Oct 2018 14:04:38 -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=dazcvemZijwyJUwvxXhrA58XYx9 ZLvtwyJswx/Qv8iE=; b=eJwXZ6kajgqNAEsGJ+MJK+qnA9kfLSx38XrMc6uGsgJ /2PPGcOTGO7rdEJIWUMhgSa5nbplcYMKNv4rky4OaafaHDxB+Qs2eCFsaTjIdA93 VwkwPzl142U+9B/IPu880OFlunHdfkN76PsJPhes2Zw/Jhxo63lveAOctfjIduOZ GXSHB2+bKvuPWq+0UUWj9PGqUH7T/60pG1H4nlowgkqLUYCtPXgOKWqzkoi4QmG8 qlV601Pr779UgmJ2s1ZyFi3ZAOaF4ctHaCmDInTiUu7mFFIfZUfZq+Eq0z3nMx5I WTkKjgGBCB/ItWFzmaLJNEPTkZjItNe6qAfR/lv1Osw== 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=fm1; bh=dazcve mZijwyJUwvxXhrA58XYx9ZLvtwyJswx/Qv8iE=; b=NoVjsLTAq/YnpauX601ZOU jvUQh/+DOwaf4LFHhNHOtrqFILBbp5ws9xIbJK4FuFi+liGD21EhWvlDwRpMmNLm I0bQOxOtxZ9aZuB8Pum/2xZR2NcHazq39VOx1oQvOdlFTXzmmYTf+9nts/apYUCu NisWbrlP9FG9WrYlia2+dCDkMPP0v+TVPSRkJByzI+55yDCrLl4KUS5VtcFEnoll ws27PThIk8A5OXyAoI5PZpcsbL4sC5o8C58A77Dbd7/eWZeyG/m/Zd7auqASceAv 5FK0jG0KiiQEo+8+99M3iUntKq1um7K5ql8sJ4BDI5cx4yi/jSIRNYLcGO6RaLLg == X-ME-Sender: X-ME-Proxy: Received: from intern.anarazel.de (unknown [172.58.91.4]) by mail.messagingengine.com (Postfix) with ESMTPA id 407ADE48A7; Mon, 22 Oct 2018 14:04:37 -0400 (EDT) Date: Mon, 22 Oct 2018 11:04:35 -0700 From: Andres Freund To: Michael Paquier Cc: Postgres hackers Subject: Re: pgsql: Avoid duplicate XIDs at recovery when building initial snapshot Message-ID: <20181022180435.s4cnwlzsfpmkgbun@alap3.anarazel.de> References: <20181014174240.byktkskdymae7kmy@alap3.anarazel.de> <20181022030326.GE14282@paquier.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181022030326.GE14282@paquier.xyz> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2018-10-22 12:03:26 +0900, Michael Paquier wrote: > (moving to -hackers) > > On Sun, Oct 14, 2018 at 10:42:40AM -0700, Andres Freund wrote: > > I'm unhappy this approach was taken over objections. Without a real > > warning. > > Oops, that was not clear to me. Sorry about that! I did not see you > objecting again after the last arguments I raised. The end of PREPARE > TRANSACTION is designed like that since it has been introduced, so > changing the way the dummy GXACT is inserted before the main one is > cleared from its XID does not sound wise to me. The current design is > also present for a couple of reasons, please see this thread: > https://www.postgresql.org/message-id/13905.1119109281@sss.pgh.pa.us > This has resulted in e26b0abd. None of them explains why having "corrupt" WAL that's later fixed up is a good idea. > Among the things I thought are: > - Clearing the XID at the same time the dummy entry is added, which > actually means to hold on ProcArrayLock longer while doing more at the > end of prepare. I actually don't think you can do that cleanly without > endangering the transaction visibility for other backends, and syncrep > may cause the window to get wider. > - Changing GetRunningTransactionData so as duplicates are removed at > this stage. However this also requires to hold ProcArrayLock for > longer. That's *MUCH* better than what we have right now. GetRunningTransactionData() isn't called all that often, for once, and for another the WAL then is correct. > > Even leaving the crummyness aside, did you check other users of > > XLOG_RUNNING_XACTS, e.g. logical decoding? > > I actually spent some time checking that, so it is not innocent. "innocent"? > SnapBuildWaitSnapshot() waits for transactions to commit or abort based > on the XIDs in the record. And that's the only place where those XIDs > are used so it won't matter to wait twice for the same transaction to > finish. The error callback would be used only once. Right. We used to use it more (and it'd probably caused problems), but since 955a684e0401954a58e956535107bc4b7136d952 it should be ok... Greetings, Andres Freund