Re: Needless additional partition check in INSERT?

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
Cc: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, Amit Khandekar <amitdkhan(dot)pg(at)gmail(dot)com>, 2q-peter(at)alvin(dot)alvh(dot)no-ip(dot)org, 2q-petr(at)alvin(dot)alvh(dot)no-ip(dot)org
Subject: Re: Needless additional partition check in INSERT?
Date: 2018-06-14 14:23:28
Message-ID: 20180614142328.u73j7niupgjjhxrm@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-06-14 14:40:11 Re: why partition pruning doesn't work?
Previous Message Alexander Korotkov 2018-06-14 14:13:14 Re: Locking B-tree leafs immediately in exclusive mode