Re: adding partitioned tables to publications
amit <amitlangote09@gmail.com>
From: Amit Langote <amitlangote09@gmail.com>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Rafia Sabih <rafia.pghackers@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2019-11-08T04:27:46Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix RELCACHE_FORCE_RELEASE issue
- 12fb189bfeaf 13.0 landed
-
Allow publishing partition changes via ancestors
- 83fd4532a721 13.0 landed
-
Add logical replication support to replicate into partitioned tables
- f1ac27bfda6c 13.0 landed
-
Refactor code to look up local replication tuple
- d8653f468789 13.0 landed
-
Some refactoring of logical/worker.c
- 97ee604d9bce 13.0 landed
-
Prepare to support non-tables in publications
- c314c147c056 13.0 landed
-
Support adding partitioned tables to publication
- 17b9e7f9fe23 13.0 landed
Attachments
- 0001-Some-refactoring-of-publication-and-subscription-cod.patch (application/octet-stream) patch 0001
- 0002-Support-adding-partitioned-tables-to-publication.patch (application/octet-stream) patch 0002
Sorry about the delay. On Mon, Nov 4, 2019 at 8:00 PM Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote: > This patch seems excessively complicated to me. Why don't you just add > the actual partitioned table to pg_publication_rel and then expand the > partition hierarchy in pgoutput (get_rel_sync_entry() or > GetRelationPublications() or somewhere around there). Then you don't > need to do any work in table DDL to keep the list of published tables up > to date. I tend to agree that having to manage this at the DDL level would be bug-prone, not to mention pretty complicated code to implement it. I have tried to implement it the way you suggested. So every decoded change to a leaf partition will now be published not only via its own publication but also via publications of its ancestors if any. That irrespective of whether a row is directly inserted into the leaf partition or got routed to it via insert done on an ancestor. In this implementation, the only pg_publication_rel entry is the one corresponding to the partitioned table. On the subscription side, when creating pg_subscription_rel entries, for a publication containing a partitioned table, all of its partitions too must be fetched as being included in the publication. That is necessary, because the initial syncing copy and subsequently received changes must be applied to individual partitions. That could be changed in the future by publishing leaf partition changes as changes to the actually published partitioned table. That future implementation will also hopefully take care of the concern that Rafia mentioned on this thread that even with this patch, one must make sure that tables match one-to-one when they're in publish-subscribe relationship, which actually needs us to bake in low-level details like table's relkind in the protocol exchanges. Anyway, I've attached two patches -- 0001 is a refactoring patch. 0002 implements the feature. Thanks, Amit