pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sergey Tatarintsev <s.tatarintsev@postgrespro.ru>
To: vignesh C <vignesh21@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: create subscription with (origin = none, copy_data = on)
Date: Sat, 18 Jan 2025 15:59:17 +0700
Message-ID: <8e06e68c-db9d-4fdf-82ae-0ac0861d5e18@postgrespro.ru> (raw)
In-Reply-To: <CALDaNm0x=Lf8iz4WqR9U2474jzT0VmwTBeXB5LjBa7T3UPX-zg@mail.gmail.com>
References: <5eda6a9c-63cf-404d-8a49-8dcb116a29f3@postgrespro.ru>
	<CALDaNm35cXbQ-zsvp3gpWPvyksQ1AE5Ucaqj2WvduQaofkL3Rg@mail.gmail.com>
	<CALDaNm0x=Lf8iz4WqR9U2474jzT0VmwTBeXB5LjBa7T3UPX-zg@mail.gmail.com>


18.01.2025 12:01, vignesh C пишет:
> On Fri, 17 Jan 2025 at 21:30, vignesh C<vignesh21@gmail.com> wrote:
>> On Fri, 17 Jan 2025 at 14:00, Sergey Tatarintsev
>> <s.tatarintsev@postgrespro.ru> wrote:
>>> Hi, hackers!
>>>
>>> I am looking at subscription creation command:
>>>
>>> CREATE SUBSCRIPTION sub CONNECTION '...' PUBLICATION pub WITH (origin =
>>> none, copy_data = on);
>>>
>>> For now we log a warning if the publisher has subscribed to the same
>>> table from some other publisher.
>>> However, in case of publication with publish_via_partition_root option,
>>> we will not raise such warinigs
>>> because SQL command in check_publications_origin() checks only directly
>>> published tables.
>> Yes, I agree that we are checking only the directly published tables
>> which is why there is no warning in this case. I'm working on a fix to
>> change the check_publications_origin to check accordingly.
> Attached patch has the fix for this issue which includes the partition
> tables also for the publication now and throws a warning
> appropriately.
>
> Regards,
> Vignesh

Thanks for patch!

I think we must take into account whole inheritance tree of partitioned 
table.

For example:

node_A:
CREATE TABLE t(id int);
CREATE PUBLICATION pub_b FOR TABLE t;

node_A:
CREATE TABLE t(id int) PARTITION BY RANGE(id);
CREATE TABLE part PARTITION OF t FOR VALUES FROM (0) TO (10) PARTITION 
BY RANGE(id);
CREATE TABLE subpart PARTITION OF part FOR VALUES FROM (0) TO (5);
CREATE SUBSCRIPTION sub_c CONNECTION '$node_B_connstr' PUBLICATION pub_b;
CREATE PUBLICATION pub_t FOR TABLE t WITH (publish_via_partition_root);
CREATE PUBLICATION pub_part FOR TABLE part WITH 
(publish_via_partition_root);

node_C:
-- this command will raise a warning CREATE SUBSCRIPTION sub_t 
CONNECTION '$node_A_connstr' PUBLICATION pub_t WITH (origin = none, 
copy_data = on);
DROP SUBSCRIPTION IF EXISTS sub_t;
-- here we got silence, but "part" is in tree of upper level replicated 
table
CREATE SUBSCRIPTION sub_part CONNECTION '$node_A_connstr' PUBLICATION 
pub_part WITH (origin = none, copy_data = on);
DROP SUBSCRIPTION IF EXISTS sub_part;

I think that for each partition/partitioned table in the publication we 
can use something like

select relid from pg_partition_tree('part'::regclass)
union
select relid from pg_partition_ancestors('part'::regclass);

In this case  we don't care about  publish_via_partition_root option, 
because we already check all inheritance tree, and there is no need to 
change pg_class

What are you thinking about it?

view thread (24+ messages)  latest in thread

Message-ID: <8e06e68c-db9d-4fdf-82ae-0ac0861d5e18@postgrespro.ru>
Permalink:  ../8e06e68c-db9d-4fdf-82ae-0ac0861d5e18@postgrespro.ru/
Also on:    postgresql.org/message-id/8e06e68c-db9d-4fdf-82ae-0ac0861d5e18@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: s.tatarintsev@postgrespro.ru, vignesh21@gmail.com
  Subject: Re: create subscription with (origin = none, copy_data = on)
  In-Reply-To: <8e06e68c-db9d-4fdf-82ae-0ac0861d5e18@postgrespro.ru>
  References: <5eda6a9c-63cf-404d-8a49-8dcb116a29f3@postgrespro.ru> <CALDaNm35cXbQ-zsvp3gpWPvyksQ1AE5Ucaqj2WvduQaofkL3Rg@mail.gmail.com> <CALDaNm0x=Lf8iz4WqR9U2474jzT0VmwTBeXB5LjBa7T3UPX-zg@mail.gmail.com> <8e06e68c-db9d-4fdf-82ae-0ac0861d5e18@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox