Re: Segfault on logical replication to partitioned table with foreign children

2022-11-03 Thread Ilya Gladyshev
On Wed, 2022-11-02 at 12:37 -0400, Tom Lane wrote: > Since we're getting pretty close to the next set of back-branch > releases, > I went ahead and pushed a minimal fix along the lines suggested by > Shi Yu. > (I realized that there's a second ExecFindPartition call in worker.c > that > also needs

Re: Segfault on logical replication to partitioned table with foreign children

2022-11-02 Thread Tom Lane
Since we're getting pretty close to the next set of back-branch releases, I went ahead and pushed a minimal fix along the lines suggested by Shi Yu. (I realized that there's a second ExecFindPartition call in worker.c that also needs a check.) We still can at leisure think about refactoring

Re: Segfault on logical replication to partitioned table with foreign children

2022-11-01 Thread Tom Lane
Ilya Gladyshev writes: > [ v2-0001-check-relkind-of-subscription-target-recursively.patch ] Hmm. I like Shi yu's way better (formal patch attached). Checking at CREATE/ALTER SUBSCRIPTION is much more complicated, and it's really insufficient, because what if someone adds a new partition after

Re: Segfault on logical replication to partitioned table with foreign children

2022-10-31 Thread Ilya Gladyshev
On Mon, 2022-10-31 at 03:20 +, shiy.f...@fujitsu.com wrote: > On Sun, Oct 30, 2022 9:39 PM Tom Lane wrote: > > > > What I'm wondering about is whether we can refactor this code > > to avoid so many usually-useless catalog lookups.  Pulling the > > namespace name, in particular, is expensive

Re: Segfault on logical replication to partitioned table with foreign children

2022-10-31 Thread Ilya Gladyshev
On Sun, 2022-10-30 at 16:52 +0100, Alvaro Herrera wrote: > On 2022-Oct-28, ilya.v.gladys...@gmail.com wrote: > > > This will cause a segfault or raise an assert, because inserting > > into > > foreign tables via logical replication is not possible. The > > solution I > > propose is to add

Re: Segfault on logical replication to partitioned table with foreign children

2022-10-31 Thread ilya . v . gladyshev
On Sun, 2022-10-30 at 09:39 -0400, Tom Lane wrote: > Dilip Kumar writes: > > Yes, this looks like a bug and your fix seems correct to me.  It > > would > > be nice to add a test case for this scenario. > > A test case doesn't seem that exciting to me.  If we were trying to > make it actually

Re: Segfault on logical replication to partitioned table with foreign children

2022-10-31 Thread Dilip Kumar
On Sun, Oct 30, 2022 at 7:09 PM Tom Lane wrote: > > Dilip Kumar writes: > > Yes, this looks like a bug and your fix seems correct to me. It would > > be nice to add a test case for this scenario. > > A test case doesn't seem that exciting to me. If we were trying to > make it actually work,

RE: Segfault on logical replication to partitioned table with foreign children

2022-10-30 Thread shiy.f...@fujitsu.com
On Sun, Oct 30, 2022 9:39 PM Tom Lane wrote: > > What I'm wondering about is whether we can refactor this code > to avoid so many usually-useless catalog lookups. Pulling the > namespace name, in particular, is expensive and we generally > are not going to need the result. In the child-rel

Re: Segfault on logical replication to partitioned table with foreign children

2022-10-30 Thread Alvaro Herrera
On 2022-Oct-28, ilya.v.gladys...@gmail.com wrote: > This will cause a segfault or raise an assert, because inserting into > foreign tables via logical replication is not possible. The solution I > propose is to add recursive checks of relkind for children of a target, > if the target is a

Re: Segfault on logical replication to partitioned table with foreign children

2022-10-30 Thread Tom Lane
Dilip Kumar writes: > Yes, this looks like a bug and your fix seems correct to me. It would > be nice to add a test case for this scenario. A test case doesn't seem that exciting to me. If we were trying to make it actually work, then yeah, but throwing an error isn't that useful to test. The

Re: Segfault on logical replication to partitioned table with foreign children

2022-10-30 Thread Dilip Kumar
On Sat, Oct 29, 2022 at 1:01 AM wrote: > > Right now it is possible to add a partitioned table with foreign tables > as its children as a target of a subscription. It can lead to an assert > (or a segfault, if compiled without asserts) on a logical replication > worker when the worker attempts to