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: Inherit the local transaction's access/deferrable
Date: Sun, 01 Jun 2025 08:34:49 +0000
Message-ID: <E1uLe9X-000zsY-2g@gemulon.postgresql.org> (raw)

postgres_fdw: Inherit the local transaction's access/deferrable modes.

Previously, postgres_fdw always 1) opened a remote transaction in READ
WRITE mode even when the local transaction was READ ONLY, causing a READ
ONLY transaction using it that references a foreign table mapped to a
remote view executing a volatile function to write in the remote side,
and 2) opened the remote transaction in NOT DEFERRABLE mode even when
the local transaction was DEFERRABLE, causing a SERIALIZABLE READ ONLY
DEFERRABLE transaction using it to abort due to a serialization failure
in the remote side.

To avoid these, modify postgres_fdw to open a remote transaction in the
same access/deferrable modes as the local transaction.  This commit also
modifies it to open a remote subtransaction in the same access mode as
the local subtransaction.

Although these issues exist since the introduction of postgres_fdw,
there have been no reports from the field.  So it seems fine to just fix
them in master only.

Author: Etsuro Fujita <etsuro.fujita@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAPmGK16n_hcUUWuOdmeUS%2Bw4Q6dZvTEDHb%3DOP%3D5JBzo-M3QmpQ%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e5a3c9d9b5ce535151d3a7e3173e8d27d2d8cd58

Modified Files
--------------
contrib/postgres_fdw/connection.c              |  99 ++++++++++++++++--
contrib/postgres_fdw/expected/postgres_fdw.out | 134 +++++++++++++++++++++++++
contrib/postgres_fdw/sql/postgres_fdw.sql      |  78 ++++++++++++++
doc/src/sgml/postgres-fdw.sgml                 |  15 +++
src/backend/access/transam/xact.c              |  28 ++++++
src/include/access/xact.h                      |   1 +
6 files changed, 347 insertions(+), 8 deletions(-)



view thread (13+ messages)  latest in thread

Message-ID: <E1uLe9X-000zsY-2g@gemulon.postgresql.org>
Permalink:  ../E1uLe9X-000zsY-2g@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uLe9X-000zsY-2g@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: efujita@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: postgres_fdw: Inherit the local transaction's access/deferrable
  In-Reply-To: <E1uLe9X-000zsY-2g@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