Re: [Logical Replication] TRAP: FailedAssertion("rel->rd_rel->relreplident == REPLICA_IDENTITY_DEFAULT || rel->rd_rel->relreplident == REPLICA_IDENTITY_FULL || rel->rd_rel->relreplident == REPLICA_IDENTITY_INDEX"

Dilip Kumar <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.general
Message-ID <CAFiTN-vUS_mYnwZ+gFRd9T-b9cTQhLoqjxQ7uKwR_tjpPEja8w@mail.gmail.com>
On Thu, Jan 9, 2020 at 12:50 PM Neha Sharma
<[email protected]> wrote:
>
> Hi Michael,
> Thanks for looking into the issue. Sorry by mistake I had mentioned the incorrect DML query,please use the query as mentioned below.
>
> On Thu, Jan 9, 2020 at 11:38 AM Michael Paquier <[email protected]> wrote:
>>
>> On Tue, Jan 07, 2020 at 05:38:49PM +0530, Neha Sharma wrote:
>> > I am getting a server crash on publication server on HEAD for the below
>> > test case.
>> >
>> > Test case:
>> > Publication server:
>> > create table test(a int);
>> > create publication test_pub for all tables;
>> > alter table test replica identity NOTHING ;
>> >
>> > Subscription server:
>> > create table test(a int);
>> > create subscription test_sub CONNECTION 'host=172.16.208.32 port=5432
>> > dbname=postgres user=centos' PUBLICATION test_pub WITH ( slot_name =
>> > test_slot_sub);
>> >
>> > Publication server:
>> > insert into test values(generate_series(1,5),'aa');
>
>  insert into test values(generate_series(1,5));
>>
>>
>> This would not work as your relation has only one column.  There are
>> some TAP tests for logical replication (none actually stressing
>> NOTHING as replica identity), which do not fail, and I cannot
>> reproduce the failure myself.

I am able to reproduce the failure,  I think the assert in the
'logicalrep_write_insert' is not correct.  IMHO even if the replica
identity is set to NOTHING we should be able to replicate INSERT?

This will fix the issue.

diff --git a/src/backend/replication/logical/proto.c
b/src/backend/replication/logical/proto.c
index dcf7c08..471461c 100644
--- a/src/backend/replication/logical/proto.c
+++ b/src/backend/replication/logical/proto.c
@@ -145,7 +145,8 @@ logicalrep_write_insert(StringInfo out, Relation
rel, HeapTuple newtuple)

        Assert(rel->rd_rel->relreplident == REPLICA_IDENTITY_DEFAULT ||
                   rel->rd_rel->relreplident == REPLICA_IDENTITY_FULL ||
-                  rel->rd_rel->relreplident == REPLICA_IDENTITY_INDEX);
+                  rel->rd_rel->relreplident == REPLICA_IDENTITY_INDEX ||
+                  rel->rd_rel->relreplident == REPLICA_IDENTITY_NOTHING);

        /* use Oid as relation identifier */
        pq_sendint32(out, RelationGetRelid(rel));

-- 
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.