pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: postgres_fdw: Fix connection leak.
Date: Mon, 28 Dec 2020 11:03:47 +0000
Message-ID: <E1ktqJX-0008Tx-Ux@gemulon.postgresql.org> (raw)

postgres_fdw: Fix connection leak.

In postgres_fdw, the cached connections to foreign servers will not be
closed until the local session exits if the user mappings or foreign servers
that those connections depend on are dropped. Those connections can be
leaked.

To fix that connection leak issue, after a change to a pg_foreign_server
or pg_user_mapping catalog entry, this commit makes postgres_fdw close
the connections depending on that entry immediately if current
transaction has not used those connections yet. Otherwise, mark those
connections as invalid and then close them at the end of current transaction,
since they cannot be closed in the midst of the transaction using them.
Closed connections will be remade at the next opportunity if necessary.

Back-patch to all supported branches.

Author: Bharath Rupireddy
Reviewed-by: Zhihong Yu, Zhijie Hou, Fujii Masao
Discussion: https://postgr.es/m/CALj2ACVNcGH_6qLY-4_tXz8JLvA+4yeBThRfxMz7Oxbk1aHcpQ@mail.gmail.com

Branch
------
REL_12_STABLE

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

Modified Files
--------------
contrib/postgres_fdw/connection.c              | 33 ++++++++++++++++++++------
contrib/postgres_fdw/expected/postgres_fdw.out | 18 ++++++++++++++
contrib/postgres_fdw/sql/postgres_fdw.sql      | 14 +++++++++++
3 files changed, 58 insertions(+), 7 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1ktqJX-0008Tx-Ux@gemulon.postgresql.org>
Permalink:  ../E1ktqJX-0008Tx-Ux@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ktqJX-0008Tx-Ux@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: fujii@postgresql.org
  Subject: Re: pgsql: postgres_fdw: Fix connection leak.
  In-Reply-To: <E1ktqJX-0008Tx-Ux@gemulon.postgresql.org>
  References: <E1ktqJX-0008Tx-Ux@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