Re: [BUG]Update Toast data failure in logical replication

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Ajin Cherian <itsajin(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Petr Jelinek <petr(dot)jelinek(at)enterprisedb(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>, "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [BUG]Update Toast data failure in logical replication
Date: 2021-09-08 06:28:17
Message-ID: CAFiTN-sjM6S0Yv=pt=XiNGpaMnPr=NQ2RV=DcnUzvGDkMtrJMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 8, 2021 at 11:26 AM Ajin Cherian <itsajin(at)gmail(dot)com> wrote:

> On Wed, Aug 11, 2021 at 10:45 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com>
> wrote:
>
> > Yeah we can avoid that by detecting any toasted replica identity key
> > in HeapDetermineModifiedColumns, check the attached patch.
> >
>
> I had a second look at this, and I just had a small doubt. Since the
> convention is that for UPDATES, the old tuple/key is written to
> WAL only if the one of the columns in the key has changed as part of
> the update, and we are breaking that convention with this patch by
> also including
> the old key if it is toasted and is stored in disk even if it is not
> changed.
> Why do we not include the detoasted key as part of the new tuple
> rather than the old tuple? Then we don't really break this convention.
>

The purpose of including the toasted old data is only for the replica
identity, but if you include it in the new tuple then it will affect the
general wal replay, basically, now you will have large detoasted data in
your new tuple which your are directly going to memcpy on the standby while
replaying so that will create corruption. So basically, you can not
include this in the new tuple without changing a lot of logic around replay
which is completely useless.

So let this tuple be for a specific purpose and that is replica identity in
our case.

> And one small typo in the patch:
>
> The header above ExtractReplicaIdentity()
>
> Before:
> * key_required should be false if caller knows that no replica identity
> * columns changed value and it doesn't has any external data.
> * It's always true in the DELETE case.
>
> After:
> * key_required should be false if caller knows that no replica identity
> * columns changed value and it doesn't have any external data.
> * It's always true in the DELETE case.
>

Okay, I will change this.

--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-09-08 06:33:47 Re: Gather performance analysis
Previous Message Kyotaro Horiguchi 2021-09-08 06:16:32 Re: .ready and .done files considered harmful