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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ilya Gladyshev <ilya(dot)v(dot)gladyshev(at)gmail(dot)com>
Cc: "shiy(dot)fnst(at)fujitsu(dot)com" <shiy(dot)fnst(at)fujitsu(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Segfault on logical replication to partitioned table with foreign children
Date: 2022-11-01 19:10:14
Message-ID: 1361869.1667329814@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ilya Gladyshev <ilya(dot)v(dot)gladyshev(at)gmail(dot)com> 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
setting up the subscription?

I get the argument about it being a useful check for simple mistakes,
but I don't entirely buy that argument, because I think there are
potential use-cases that it'd disallow needlessly. Imagine a
partitioned table that receives replication updates, but only into
the "current" partition; older partitions are basically static.
Now suppose you'd like to offload some of that old seldom-used data
to another server, and make those partitions into foreign tables
so you can still access it at need. Such a setup will work perfectly
fine today, but this patch would break it.

So I think what we want is to check when we identify the partition.
Maybe Shi yu missed a place or two to check, but I verified that the
attached stops the crash.

There'd still be value in refactoring to avoid premature lookup
of the namespace name, but that's just micro-optimization.

regards, tom lane

Attachment Content-Type Size
v3-0001-check-target-partition-relkind.patch text/x-diff 911 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2022-11-01 20:30:50 Re: Check return value of pclose() correctly
Previous Message Dagfinn Ilmari Mannsåker 2022-11-01 18:55:43 Re: perl 5.36, C99, -Wdeclaration-after-statement -Wshadow=compatible-local