Re: Found issues related with logical replication and 2PC

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Found issues related with logical replication and 2PC
Date: 2024-08-07 10:02:08
Message-ID: CAA4eK1LW5jt5-WkXN22Vub+5-oiGDGB5LkDVeCE+rYTzak7gdg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 7, 2024 at 12:38 PM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
>
> On Wed, Jul 24, 2024 at 12:25 PM Hayato Kuroda (Fujitsu)
> <kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
> >
> > Issue #1
> >
> > When handling a PREPARE message, the subscriber mistook the wrong lsn position
> > (the end position of the last commit) as the end position of the current prepare.
> > This can be fixed by adding a new global variable to record the end position of
> > the last prepare. 0001 patch fixes the issue.
>
> Thanks for the patches. I have started reviewing this. I reviewed and
> tested patch001 alone.
>

It makes sense. As both are different bugs we should discuss them separately.

> I have a query, shouldn't the local-lsn stored in
> apply_handle_commit_prepared() be the end position of
> 'COMMIT_PREPARED' instead of 'PREPARE'? I put additional logging on
> sub and got this:
>
> LOG: apply_handle_prepare - prepare_data.end_lsn: 0/15892E0 ,
> XactLastPrepareEnd: 0/1537FD8.
> LOG: apply_handle_commit_prepared - prepare_data.end_lsn: 0/1589318
> , XactLastPrepareEnd: 0/1537FD8.
>
> In apply_handle_prepare(), remote-lsn ('0/15892E0') is end position of
> 'PREPARE' and in apply_handle_commit_prepared(), remote-lsn
> ('0/1589318') is end position of 'COMMIT_PREPARED', while local-lsn in
> both cases is end-lsn of 'PREPARE'. Details at [1].
>
> Shouldn't we use 'XactLastCommitEnd' in apply_handle_commit_prepared()
> which is the end position of last COMMIT_PREPARED? It is assigned in
> the below flow:
> apply_handle_commit_prepared-->CommitTransactionCommand...->RecordTransactionCommit?
>

I also think so. Additionally, I feel a test case (or some description
of the bug that can arise) should be provided for issue-1.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2024-08-07 10:02:52 Re: pgsql: Introduce hash_search_with_hash_value() function
Previous Message Pavel Stehule 2024-08-07 10:00:14 Re: proposal: schema variables