Re: Table refer leak in logical replication

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "shiy(dot)fnst(at)fujitsu(dot)com" <shiy(dot)fnst(at)fujitsu(dot)com>
Subject: Re: Table refer leak in logical replication
Date: 2021-04-20 07:21:57
Message-ID: YH6BFQJS+D5TAto1@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Apr 20, 2021 at 02:48:35PM +0900, Amit Langote wrote:
> Manipulating the contents of es_opened_result_relations directly in
> worker.c is admittedly a "hack", which I am reluctant to have other
> places participating in. As originally designed, that list is to
> speed up ExecCloseResultRelations(), not as a place to access result
> relations from. The result relations targeted over the course of
> execution of a query (update/delete) or a (possibly multi-tuple in the
> future) replication apply operation will not be guaranteed to be added
> to the list in any particular order, so assuming where a result
> relation of interest can be found in the list is bound to be unstable.

I really hope that this code gets heavily reorganized before
considering more features or more manipulations of dependencies within
the relations used for any apply operations. From what I can
understand, I think that it would be really nicer and less bug prone
to have a logic like COPY FROM, where we'd rely on a set of
ExecInitResultRelation() with one final ExecCloseResultRelations(),
and as bonus it should be possible to not have to do any business with
ExecOpenIndices() or ExecCloseIndices() as part of worker.c. Anyway,
I also understand that we do with what we have now in this code, so I
am fine to live with this patch as of 14.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Junfeng Yang 2021-04-20 07:24:40 Partitioned table permission question
Previous Message Bharath Rupireddy 2021-04-20 06:55:25 Re: Performance degradation of REFRESH MATERIALIZED VIEW