From: Andres Freund <andres@anarazel.de>
To: Michael Paquier <michael@paquier.xyz>
Cc: Postgres hackers <pgsql-hackers@postgresql.org>
Subject: Re: pgsql: Avoid duplicate XIDs at recovery when building initial snapshot
Date: Mon, 22 Oct 2018 11:04:35 -0700
Message-ID: <20181022180435.s4cnwlzsfpmkgbun@alap3.anarazel.de> (raw)
In-Reply-To: <20181022030326.GE14282@paquier.xyz>
References: <E1gBgPY-0006hw-HN@gemulon.postgresql.org>
<20181014174240.byktkskdymae7kmy@alap3.anarazel.de>
<20181022030326.GE14282@paquier.xyz>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: andres@anarazel.de, michael@paquier.xyz, pgsql-hackers@postgresql.org
Subject: Re: pgsql: Avoid duplicate XIDs at recovery when building initial snapshot
In-Reply-To: <20181022180435.s4cnwlzsfpmkgbun@alap3.anarazel.de>
References: <E1gBgPY-0006hw-HN@gemulon.postgresql.org> <20181014174240.byktkskdymae7kmy@alap3.anarazel.de> <20181022030326.GE14282@paquier.xyz> <20181022180435.s4cnwlzsfpmkgbun@alap3.anarazel.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox