Re: repeated decoding of prepared transactions - Mailing list pgsql-hackers

From Ashutosh Bapat
Subject Re: repeated decoding of prepared transactions
Date
Msg-id CAExHW5s2JAnYC4vNdes-DGQdjkOBRukUa_LLqRbNmKENLE33kg@mail.gmail.com
Whole thread Raw
In response to Re: repeated decoding of prepared transactions  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: repeated decoding of prepared transactions
Re: repeated decoding of prepared transactions
List pgsql-hackers
On Tue, Feb 9, 2021 at 8:32 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> On Mon, Feb 8, 2021 at 8:36 PM Markus Wanner
> <markus.wanner@enterprisedb.com> wrote:
> >
> > Hello Amit,
> >
> > thanks for your very quick response.
> >
> > On 08.02.21 11:13, Amit Kapila wrote:
> > > /*
> > >   * It is possible that this transaction is not decoded at prepare time
> > >   * either because by that time we didn't have a consistent snapshot or it
> > >   * was decoded earlier but we have restarted. We can't distinguish between
> > >   * those two cases so we send the prepare in both the cases and let
> > >   * downstream decide whether to process or skip it. We don't need to
> > >   * decode the xact for aborts if it is not done already.
> > >   */
> >
> > The way I read the surrounding code, the only case a 2PC transaction
> > does not get decoded a prepare time is if the transaction is empty.  Or
> > are you aware of any other situation that might currently happen?
> >
>
> We also skip decoding at prepare time if we haven't reached a
> consistent snapshot by that time. See below code in DecodePrepare().
> DecodePrepare()
> {
> ..
> /* We can't start streaming unless a consistent state is reached. */
> if (SnapBuildCurrentState(builder) < SNAPBUILD_CONSISTENT)
> {
> ReorderBufferSkipPrepare(ctx->reorder, xid);
> return;
> }
> ..
> }

Can you please provide steps which can lead to this situation? If
there is an earlier discussion which has example scenarios, please
point us to the relevant thread.

If we are not sending PREPARED transactions that's fine, but sending
the same prepared transaction as many times as the WAL sender is
restarted between sending prepare and commit prepared is a waste of
network bandwidth. The wastage is proportional to the amount of
changes in the transaction and number of such transactions themselves.
Also this will cause performance degradation. So if we can avoid
resending prepared transactions twice that will help.

-- 
Best Wishes,
Ashutosh Bapat



pgsql-hackers by date:

Previous
From: "Andrey V. Lepikhov"
Date:
Subject: Re: [POC] Fast COPY FROM command for the table with foreign partitions
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: Is Recovery actually paused?