[Postgres-xl-developers] Error while updating non-distribution key

Tomas Vondra tomas.vondra at 2ndquadrant.com
Mon Aug 28 06:20:00 PDT 2017



On 08/23/2017 02:39 PM, Pavan Deolasee wrote:
> Hello,
> 
> I am investigating a failure in update test case. Here is a small
> reproduction case:
> 
> create table range_parted (
>     a text,    
>     b int
> ) partition by range (a, b);
> create table part_a_1_a_10 partition of range_parted for values from
> ('a', 1) to ('a', 10); 
> create table part_b_10_b_20 partition of range_parted for values from
> ('b', 10) to ('b', 20); 
> 
> insert into part_a_1_a_10 values ('a', 1);
> insert into part_b_10_b_20 values ('b', 10); 
> 
> update range_parted set b = b - 1 where b = 10;
> 
> The update fails with an error:
> ERROR:  could not plan this distributed update
> DETAIL:  correlated UPDATE or updating distribution column currently not
> supported in Postgres-XL.
> 
> This is a bit weird because the table is distributed by hash(a) and
> hence there should not be any trouble updating the column b. Upon
> investigation it looks like that post PG 10 changes, we get a dummy
> AppendPath path, without any distribution information and
> adjust_path_distribution() then complains because the information does
> not match.
> 

Apologies for not responding earlier. I remember I investigated this
issue on the XL 9.6 branch (i.e. it's not post-XL10 issue), and my notes
from the analysis were:

* The UPDATE fails to distribute because of a new block of code in
relation_excluded_by_constraints (see plancat.c:1275)

* RLS injects FALSE constant into baserestrictinfo for the relation,
relation_excluded_by_constraints returns ‘true’, so that set_rel_size()
calls set_dummy_rel_pathlist() which injects dummy AppendPath with empty
distribution.

* That confuses the planner and makes the UPDATE to fail. Removing the
new block of code fixes the issue, but it might affect performance (?).
Perhaps we need to assign distribution to the dummy path, or handle it
in some other way?

* This only affects roles disabled by RLS, using a different role does
the planning correctly.

>
> The attached simple patch fixes it for me, along with couple of
> other regression diffs. It seems like a fairly simple patch, but TBH
> I am not entirely convinced that this is the best solution. So more
> eyeballs will be useful.
> 

I think the fix is correct, and likely better than what I initially
considered (removing the block from relation_excluded_by_constraints).

regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


More information about the Postgres-xl-developers mailing list