Invalid Assert while validating REPLICA IDENTITY? - Mailing list pgsql-hackers

From Dilip Kumar
Subject Invalid Assert while validating REPLICA IDENTITY?
Date
Msg-id CAFiTN-tmguaT1DXbCC+ZomZg-oZLmU6BPhr0po7akQSG6vNJrg@mail.gmail.com
Whole thread Raw
Responses Re: Invalid Assert while validating REPLICA IDENTITY?
List pgsql-hackers
While working on some other code I noticed that in
FindReplTupleInLocalRel() there is an assert [1] that seems to be
passing IndexRelation to GetRelationIdentityOrPK() whereas it should
be passing normal relation.

[1]
if (OidIsValid(localidxoid))
{
#ifdef USE_ASSERT_CHECKING
    Relation idxrel = index_open(localidxoid, AccessShareLock);

    /* Index must be PK, RI, or usable for REPLICA IDENTITY FULL tables */
    Assert(GetRelationIdentityOrPK(idxrel) == localidxoid ||
    IsIndexUsableForReplicaIdentityFull(BuildIndexInfo(idxrel),
    edata->targetRel->attrmap));
    index_close(idxrel, AccessShareLock);
#endif

In the above code, we are passing idxrel to GetRelationIdentityOrPK(),
whereas we should be passing localrel

Fix should be


@@ -2929,7 +2929,7 @@ FindReplTupleInLocalRel(ApplyExecutionData
*edata, Relation localrel,

                Relation        idxrel = index_open(localidxoid,
AccessShareLock);

                /* Index must be PK, RI, or usable for REPLICA
IDENTITY FULL tables */
-               Assert(GetRelationIdentityOrPK(idxrel) == localidxoid ||
+               Assert(GetRelationIdentityOrPK(localrel) == localidxoid ||

IsIndexUsableForReplicaIdentityFull(BuildIndexInfo(idxrel),

                            edata->targetRel->attrmap));

                index_close(idxrel, AccessShareLock);


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



pgsql-hackers by date:

Previous
From: reddy manjunath
Date:
Subject: Regarding canditate_restart_lsn in logical decoding.
Next
From: Amit Kapila
Date:
Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation