Re: Problem with logical replication

From: Euler Taveira <euler(dot)taveira(at)2ndquadrant(dot)com>
To: Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>
Cc: Dilip Kumar <dilipbalaut(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Problem with logical replication
Date: 2020-05-10 22:08:03
Message-ID: CAH503wAs7EH2aaMZpF2PuSgPFoM_r4OBN7ePqBsozb4_pm8czQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 20 Apr 2020 at 10:25, Masahiko Sawada <
masahiko(dot)sawada(at)2ndquadrant(dot)com> wrote:

> On Thu, 16 Apr 2020 at 17:48, Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
>
> I could reproduce this issue by the steps you shared. For the bug fix
> patch, I basically agree to remove that assertion from
> build_replindex_scan_key() but I think it's better to update the
> assertion instead of removal and update the following comment:
>
> IMO the assertion is using the wrong function because it should test a
replica
identity or primary key (GetRelationIdentityOrPK). RelationGetReplicaIndex
returns InvalidOid even though the table has a primary key.
GetRelationIdentityOrPK tries to obtain a replica identity and if it fails,
it
tries a primary key. That's exact what this assertion should use. We should
also notice that FindReplTupleInLocalRel uses GetRelationIdentityOrPK and
after
a code path like RelationFindReplTupleByIndex -> build_replindex_scan_key it
should also use the same function.

Since GetRelationIdentityOrPK is a fallback function that
uses RelationGetReplicaIndex and RelationGetPrimaryKeyIndex, I propose that
we
move this static function to execReplication.c.

I attached a patch with the described solution. I also included a test that
covers this scenario.

--
Euler Taveira http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-Fix-assert-failure-with-REPLICA-IDENTITY-FULL-in-the.patch text/x-patch 6.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2020-05-11 01:16:16 Re: Back-branch minor release notes are up for review
Previous Message Euler Taveira 2020-05-10 21:10:40 deferred primary key and logical replication