pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Etsuro Fujita <efujita@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: postgres_fdw: Fix incorrect handling of row movement for remote
Date: Wed, 24 Apr 2019 09:52:01 +0000
Message-ID: <E1hJEZN-0001aO-9F@gemulon.postgresql.org> (raw)

postgres_fdw: Fix incorrect handling of row movement for remote partitions.

Commit 3d956d9562 added support for update row movement in postgres_fdw.
This patch fixes the following issues introduced by that commit:

* When a remote partition chosen to insert routed rows into was also an
  UPDATE subplan target rel that would be updated later, the UPDATE that
  used a direct modification plan modified those routed rows incorrectly
  because those routed rows were visible to the later UPDATE command.
  The right fix for this would be to have some way in postgres_fdw in
  which the later UPDATE command ignores those routed rows, but it seems
  hard to do so with the current infrastructure.  For now throw an error
  in that case.

* When a remote partition chosen to insert routed rows into was also an
  UPDATE subplan target rel, fmstate created for the UPDATE that used a
  non-direct modification plan was mistakenly overridden by another
  fmstate created for inserting those routed rows into the partition.
  This caused 1) server crash when the partition would be updated later,
  and 2) resource leak when the partition had been already updated.  To
  avoid that, adjust the treatment of the fmstate for the inserting.  As
  for #1, since we would also have the incorrectness issue as mentioned
  above, error out in that case as well.

Update the docs to mention that postgres_fdw currently does not handle
the case where a remote partition chosen to insert a routed row into is
also an UPDATE subplan target rel that will be updated later.

Author: Amit Langote and Etsuro Fujita
Reviewed-by: Amit Langote
Backpatch-through: 11 where row movement in postgres_fdw was added
Discussion: https://postgr.es/m/21e7eaa4-0d4d-20c2-a1f7-c7e96f4ce440@lab.ntt.co.jp

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7a3d055349a98c919d1a4ea45a6a3e8e39391ab8

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 131 +++++++++++++++++++++++++
contrib/postgres_fdw/postgres_fdw.c            |  51 +++++++++-
contrib/postgres_fdw/sql/postgres_fdw.sql      |  45 +++++++++
doc/src/sgml/postgres-fdw.sgml                 |   5 +
4 files changed, 231 insertions(+), 1 deletion(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1hJEZN-0001aO-9F@gemulon.postgresql.org>
Permalink:  ../E1hJEZN-0001aO-9F@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hJEZN-0001aO-9F@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: efujita@postgresql.org
  Subject: Re: pgsql: postgres_fdw: Fix incorrect handling of row movement for remote
  In-Reply-To: <E1hJEZN-0001aO-9F@gemulon.postgresql.org>
  References: <E1hJEZN-0001aO-9F@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox