RE: Data is copied twice when specifying both child and parent table in publication
Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
From: "houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Amit Langote <amitlangote09@gmail.com>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, Dilip Kumar <dilipbalaut@gmail.com>, Greg Nancarrow <gregn4422@gmail.com>, vignesh C <vignesh21@gmail.com>
Date: 2022-03-10T02:17:32Z
Lists: pgsql-hackers
Hi, When reviewing some logical replication related features. I noticed another possible problem if the subscriber subscribes multiple publications which publish parent and child table. For example: ----pub create table t (a int, b int, c int) partition by range (a); create table t_1 partition of t for values from (1) to (10); create publication pub1 for table t with (PUBLISH_VIA_PARTITION_ROOT); create publication pub2 for table t_1 with (PUBLISH_VIA_PARTITION_ROOT); ----sub ---- prepare table t and t_1 CREATE SUBSCRIPTION sub CONNECTION 'port=10000 dbname=postgres' PUBLICATION pub1, pub2; select * from pg_subscription_rel ; srsubid | srrelid | srsubstate | srsublsn ---------+---------+------------+----------- 16391 | 16385(t) | r | 0/150D100 16391 | 16388(t_1) | r | 0/150D138 If subscribe two publications one of them publish parent table with (pubviaroot=true) and another publish child table. Both the parent table and child table will exist in pg_subscription_rel which also means we will do initial copy for both tables. But after initial copy, we only publish change with the schema of the parent table(t). It looks a bit inconsistent. Based on the document of PUBLISH_VIA_PARTITION_ROOT option. I think the expected behavior could be we only store the top most parent(table t) in pg_subscription_rel and do initial copy for it if pubviaroot is on. I haven't thought about how to fix this and will investigate this later. Best regards, Hou zj
Commits
-
Avoid syncing data twice for the 'publish_via_partition_root' option.
- 062a84442424 16.0 landed
-
Fix partition table's REPLICA IDENTITY checking on the subscriber.
- 52d5ea9adb01 14.5 cited
-
Prohibit combining publications with different column lists.
- fd0b9dcebda7 15.0 cited
-
Fix double publish of child table's data.
- 3f06c00cf6dc 13.6 landed
- 614b77d65a38 14.2 landed
- 5e97905a2c76 15.0 landed
-
Support adding partitioned tables to publication
- 17b9e7f9fe23 13.0 cited