Re: repeated decoding of prepared transactions

From: Markus Wanner <markus(dot)wanner(at)enterprisedb(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Markus Wanner <markus(dot)wanner(at)enterprisedb(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Ajin Cherian <itsajin(at)gmail(dot)com>, Simon Riggs <simon(at)enterprisedb(dot)com>, ashutosh(dot)bapat(dot)oss(at)gmail(dot)com, petr(dot)jelinek(at)enterprisedb(dot)com
Subject: Re: repeated decoding of prepared transactions
Date: 2021-02-08 15:06:30
Message-ID: e7c6a5c6-f1a8-fb89-3080-e7f5ad0f35da@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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?

> (unless the server needs to be restarted due to some reason)

Right, the repetition occurs only after a restart of the walsender in
between a prepare and a commit prepared record.

> That anyway is true without this work as well where restart_lsn can be
> advanced on commits. We haven't changed anything in that regard.

I did not mean to blame the patch, but merely try to understand some of
the design decisions behind it.

And as I just learned, even if we managed to avoid the repetition, a
restarted walsender still needs to see prepared transactions as
in-progress in its snapshots. So we cannot move forward the restart_lsn
to after a prepare record (until the final commit or rollback is consumed).

Best Regards

Markus

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-02-08 16:14:24 Re: Made ecpg compatibility mode and run-time behaviour options case insensitive
Previous Message iwata.aya@fujitsu.com 2021-02-08 14:57:47 RE: libpq debug log