On 2018-Jun-14, Amit Langote wrote:
> On 2018/06/09 3:41, Alvaro Herrera wrote:
> > BTW, while working on this, I was a bit disturbed by the
> > execReplication.c changes (namely: if the partitioning is not identical
> > on both sides, things are likely to blow up pretty badly), but that's a
> > separate topic.
>
> Hmm, yes. If the partition of a given name on subscription side doesn't
> have the same partition constraint as on the publication side,
> subscription worker simply fails, which is the right thing to do anyway.
>
> ERROR: new row for relation "p1" violates partition constraint
> DETAIL: Failing row contains (1, 1).
> LOG: background worker "logical replication worker" (PID 25739) exited
> with exit code 1
>
> Maybe, it's a user error to set up logical replication that way.
To me, the ideal would be that re-routing occurs if the partition
constraint fails. The fact that the partition constraint is now
separate from the rest of the tuple constraints makes this easy to
implement, I think.
> > I didn't see any tests of logical replication with
> > partitioned tables ... Is the current understanding that we don't
> > promise those things to work terribly well together?
>
> As far as the documentation is concerned, there is this note on
>
> 31.4. Restrictions (Chapter 31. Logical Replication)
> https://www.postgresql.org/docs/devel/static/logical-replication-restrictions.html
>
> Replication is only possible from base tables to base tables. That is,
> the tables on the publication and on the subscription side must be
> normal tables, not views, materialized views, partition root tables, or
> foreign tables. In the case of partitions, you can therefore replicate a
> partition hierarchy one-to-one, but you cannot currently replicate to a
> differently partitioned setup. Attempts to replicate tables other than
> base tables will result in an error.
Ah, okay, so this is already documented not to work. I guess it's a
reasonable addition for the next release.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services