Re: Data is copied twice when specifying both child and parent table in publication
Greg Nancarrow <gregn4422@gmail.com>
From: Greg Nancarrow <gregn4422@gmail.com>
To: Peter Smith <smithpb2250@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>,
Dilip Kumar <dilipbalaut@gmail.com>, Amit Langote <amitlangote09@gmail.com>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, "houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2021-10-21T05:57:48Z
Lists: pgsql-hackers
On Thu, Oct 21, 2021 at 2:56 PM Peter Smith <smithpb2250@gmail.com> wrote: > > I just wanted to bring to your attention an earlier thread [1] in > which I had already encountered/reported behaviour that is either > exactly the same or is closely related to what is being discussed in > this current thread. If it is different please take that into account > also. > > ------ > [1] https://www.postgresql.org/message-id/CAHut%2BPvJMRB-ZyC80we2kiUFv4cVjmA6jxXpEMhm1rmz%3D1ryeA%40mail.gmail.com > Thanks, I was able to reproduce that behavior, which is similar (but in that case the publish_via_partition_root flag is toggled with the partitioned table present in the publication, whereas in the case being discussed the presence of the partitioned table in the publication is toggled with publish_via_partition_root always true). What seems to happen internally when a partitioned table is published is that when publish_via_partition_root=true the subscriber to that publication is effectively subscribed to the parent partitioned table but not the child partitions. If publish_via_partition_root is changed to false and the subscriber refreshes, the partitioned table is unsubscribed and it subscribes to the partitions. This explains why data gets "re-copied" when this happens, because then it is subscribing to a "new" table and copy_data=true by default. Regards, Greg Nancarrow Fujitsu Australia
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