Re: Fix for segfault in logical replication on master

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
Cc: osumi(dot)takamichi(at)fujitsu(dot)com, "akapila(at)postgresql(dot)org" <akapila(at)postgresql(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix for segfault in logical replication on master
Date: 2021-06-17 13:40:44
Message-ID: CAA4eK1JPhyuORBiR-TBQJAue5U=h0+NH55z6hFi3eE7J-gKmvQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 17, 2021 at 6:50 PM Mark Dilger
<mark(dot)dilger(at)enterprisedb(dot)com> wrote:
>
> > On Jun 17, 2021, at 3:39 AM, osumi(dot)takamichi(at)fujitsu(dot)com wrote:
> >
> > For the 1st check, isn't it better to use RelationIsValid() ?
>
> Yes, you are right.
>
> > Additionally, In what kind of actual scenario, did you think that
> > we come to the part to "log a complaint" ?
>
> The way that RelationGetIndexList assigns rd_replidindex to the Relation seems to lack sufficient locking. After scanning pg_index to find indexes associated with the relation, pg_index is closed and the access share lock released. I couldn't prove to myself that by the time we use the rd_replidindex field thus computed that it was safe to assume that the Oid stored there still refers to an index. The most likely problem would be that the index has since been dropped in a concurrent transaction, but it also seems just barely possible that the Oid has been reused and refers to something else, a table perhaps.
>

I think such a problem won't happen because we are using historic
snapshots in this context. We rely on that in a similar way in
reorderbuffer.c, see ReorderBufferProcessTXN.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ajin Cherian 2021-06-17 14:09:50 Re: [HACKERS] logical decoding of two-phase transactions
Previous Message Simon Riggs 2021-06-17 13:34:14 Re: locking [user] catalog tables vs 2pc vs logical rep