Re: repeated decoding of prepared transactions

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: repeated decoding of prepared transactions
Date: 2021-02-22 02:52:35
Message-ID: CAA4eK1+PVDP34LtPGKWQE7M3K=ZvcsO=emh3MBpSsWcWLghuBA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 22, 2021 at 3:56 AM Andres Freund <andres(at)anarazel(dot)de> wrote:
>
> On 2021-02-21 11:32:29 +0530, Amit Kapila wrote:
> > Here, I am assuming you are asking to disable 2PC both via
> > apply-worker and tablesync worker till the initial sync (aka all
> > tables are in SUBREL_STATE_READY state) phase is complete. If we do
> > that and what if commit prepared happened after the initial sync phase
> > but prepare happened before that?
>
> Isn't that pretty easy to detect? You compare the LSN of the tx prepare
> with the LSN of achieving consistency?
>

I think by LSN of achieving consistency, you mean start_decoding_at
LSN. It is possible that start_decoding_at point has been moved ahead
because of some other unrelated commit that happens between prepare
and commit prepared. Something like below:

LSN for Prepare of xact t1 at 500
LSN for Commit of xact t2 at 520
LSN for Commit Prepared at 550

Say we skipped prepare because 2PC was not enabled but then decoded
and sent Commit of xact t2. I think after this start_decoding_at LSN
will be at 520. So comparing the prepare LSN of xact t1 with
start_decoding_at will lead to skipping the prepare after the restart
and we will just send the commit prepared without prepare and data
when we process LSN of Commit Prepared at 550.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2021-02-22 03:01:58 Re: should INSERT SELECT use a BulkInsertState?
Previous Message Thomas Munro 2021-02-22 02:28:27 Re: Finding cause of test fails on the cfbot site