pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit
Date: Sat, 30 Jan 2021 03:44:30 +0900
Message-ID: <00e03384-e49a-513a-2aef-d5b42a65b94a@oss.nttdata.com> (raw)
In-Reply-To: <CALj2ACX24Se9mwKDZ-y_SczSUbF-bVhrUYfWX3RWmGWREc6Apg@mail.gmail.com>
References: <CALj2ACVvrp5=AVp2PupEm+nAC8S4buqR3fJMmaCoc7ftT0aD2A@mail.gmail.com>
	<2688508.1611865371@sss.pgh.pa.us>
	<CALj2ACWhoQtyZdsCZNLDLOnRjCBcoscrc3H0qU4=7f23UZcF9g@mail.gmail.com>
	<2724627.1611886184@sss.pgh.pa.us>
	<fbfdf4e2-37fb-a3f1-f6a0-3f9bf089e356@oss.nttdata.com>
	<CALj2ACVL7PZO+gOj7Jrhshm79TjTpj_6CJDqtf34VgjQasX1DA@mail.gmail.com>
	<6e9c9d45-c612-639a-f741-7798013c0ae4@oss.nttdata.com>
	<CALj2ACW1jAJTi-SmBCStZ6+a1C3DeAc8-_Zuw1LYFzo8D33k2w@mail.gmail.com>
	<CALj2ACXhM_yTBXXTCA-whZ_oA1x3DuGxyKnsROjMh8YZLG9bJw@mail.gmail.com>
	<7fa16ff3-5b37-0617-7a27-22e839695ef5@oss.nttdata.com>
	<CALj2ACXQ9ke6deP1-f34vv7TOrLuXr6=nmbi5fgxA3N_Zs=pnQ@mail.gmail.com>
	<c0d078a7-1cfb-3621-6a44-d73ba1382bb2@oss.nttdata.com>
	<CALj2ACWpNKXJrrofn7uGZwg8+9BooC-4N_28VTRiU7d-pOHH9w@mail.gmail.com>
	<8a6d3620-11de-30c8-7647-375cf92f442a@oss.nttdata.com>
	<CALj2ACXjs-fXq3h=NrVN8nSLYzvA-SZpu=nPpv9cY1uPuoujMw@mail.gmail.com>
	<CALj2ACX24Se9mwKDZ-y_SczSUbF-bVhrUYfWX3RWmGWREc6Apg@mail.gmail.com>



On 2021/01/29 19:45, Bharath Rupireddy wrote:
> On Fri, Jan 29, 2021 at 1:24 PM Bharath Rupireddy
> <bharath.rupireddyforpostgres@gmail.com> wrote:
>>
>> On Fri, Jan 29, 2021 at 1:17 PM Fujii Masao <masao.fujii@oss.nttdata.com> wrote:
>>>>> But if the issue is only the inconsistency of test results,
>>>>> we can go with the option (2)? Even with (2), we can make the test
>>>>> stable by removing "valid" column and executing
>>>>> postgres_fdw_get_connections() within the transaction?
>>>>
>>>> Hmmm, and we should have the tests at the start of the file
>>>> postgres_fdw.sql before even we make any foreign server connections.
>>>
>>> We don't need to move the test if we always call postgres_fdw_disconnect_all() just before starting new transaction and calling postgres_fdw_get_connections() as follows?
>>>
>>> SELECT 1 FROM postgres_fdw_disconnect_all();
>>> BEGIN;
>>> ...
>>> SELECT * FROM postgres_fdw_get_connections();
>>> ...
>>
>> Yes, that works, but we cannot show true/false for the
>> postgres_fdw_disconnect_all output.
>>
>> I will post the patch soon. Thanks a lot.
> 
> Attaching a patch that has following changes: 1) Now,
> postgres_fdw_get_connections will only return set of active
> connections server names not their valid state 2) The functions
> postgres_fdw_get_connections, postgres_fdw_disconnect and
> postgres_fdw_disconnect_all are now being tested within an explicit
> xact block, this way the tests are more stable even with clobber cache
> always builds.
> 
> I tested the patch here on my development system with
> -DCLOBBER_CACHE_ALWAYS configuration, the tests look consistent.
> 
> Please review the patch.

Thanks for the patch!

--- Return false as loopback2 connectin is closed already.
-SELECT postgres_fdw_disconnect('loopback2');
- postgres_fdw_disconnect
--------------------------
- f
-(1 row)
-
--- Return an error as there is no foreign server with given name.
-SELECT postgres_fdw_disconnect('unknownserver');
-ERROR:  server "unknownserver" does not exist

Why do we need to remove these? These seem to work fine even in
CLOBBER_CACHE_ALWAYS.

+			/*
+			 * It doesn't make sense to show this entry in the output with a
+			 * NULL server_name as it will be closed at the xact end.
+			 */
+			continue;

-1 with this change because I still think that it's more useful to list
all the open connections.

This makes me think that more discussion would be necessary before
changing the interface of postgres_fdw_get_connections(). On the other
hand, we should address the issue ASAP to make the buildfarm member fine.
So at first I'd like to push only the change of regression test.
Patch attached. I tested it both with CLOBBER_CACHE_ALWAYS set and unset,
and the results were stable.

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachments:

postgres_fdw.patch (text/plain, 19.9K) download diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out index 07e06e5bf7..b09dce63f5 100644 --- a/contrib/postgres_fdw/expected/postgres_fdw.out +++ b/contrib/postgres_fdw/expected/postgres_fdw.out @@ -17,10 +17,6 @@ DO $d$ OPTIONS (dbname '$$||current_database()||$$', port '$$||current_setting('port')||$$' )$$; - EXECUTE $$CREATE SERVER loopback4 FOREIGN DATA WRAPPER postgres_fdw - OPTIONS (dbname '$$||current_database()||$$', - port '$$||current_setting('port')||$$' - )$$; END; $d$; CREATE USER MAPPING FOR public SERVER testserver1 @@ -28,7 +24,6 @@ CREATE USER MAPPING FOR public SERVER testserver1 CREATE USER MAPPING FOR CURRENT_USER SERVER loopback; CREATE USER MAPPING FOR CURRENT_USER SERVER loopback2; CREATE USER MAPPING FOR public SERVER loopback3; -CREATE USER MAPPING FOR public SERVER loopback4; -- =================================================================== -- create objects used through FDW loopback server -- =================================================================== @@ -144,11 +139,6 @@ CREATE FOREIGN TABLE ft7 ( c2 int NOT NULL, c3 text ) SERVER loopback3 OPTIONS (schema_name 'S 1', table_name 'T 4'); -CREATE FOREIGN TABLE ft8 ( - c1 int NOT NULL, - c2 int NOT NULL, - c3 text -) SERVER loopback4 OPTIONS (schema_name 'S 1', table_name 'T 4'); -- =================================================================== -- tests for validator -- =================================================================== @@ -220,8 +210,7 @@ ALTER FOREIGN TABLE ft2 ALTER COLUMN c1 OPTIONS (column_name 'C 1'); public | ft5 | loopback | (schema_name 'S 1', table_name 'T 4') | public | ft6 | loopback2 | (schema_name 'S 1', table_name 'T 4') | public | ft7 | loopback3 | (schema_name 'S 1', table_name 'T 4') | - public | ft8 | loopback4 | (schema_name 'S 1', table_name 'T 4') | -(7 rows) +(6 rows) -- Test that alteration of server options causes reconnection -- Remote's errors might be non-English, so hide them to ensure stable results @@ -9066,15 +9055,21 @@ DROP PROCEDURE terminate_backend_and_wait(text); -- ============================================================================= -- test connection invalidation cases and postgres_fdw_get_connections function -- ============================================================================= +-- Let's ensure to close all the existing cached connections. +SELECT 1 FROM postgres_fdw_disconnect_all(); + ?column? +---------- + 1 +(1 row) + +-- No cached connections, so no records should be output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; + server_name +------------- +(0 rows) + -- This test case is for closing the connection in pgfdw_xact_callback BEGIN; --- List all the existing cached connections. Only loopback2 should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; - server_name | valid --------------+------- - loopback2 | t -(1 row) - -- Connection xact depth becomes 1 i.e. the connection is in midst of the xact. SELECT 1 FROM ft1 LIMIT 1; ?column? @@ -9088,19 +9083,18 @@ SELECT 1 FROM ft7 LIMIT 1; 1 (1 row) --- List all the existing cached connections. loopback and loopback3 --- also should be output as valid connections. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; - server_name | valid --------------+------- - loopback | t - loopback2 | t - loopback3 | t -(3 rows) +-- List all the existing cached connections. loopback and loopback3 should be +-- output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; + server_name +------------- + loopback + loopback3 +(2 rows) --- Connection is not closed at the end of the alter statement in --- pgfdw_inval_callback. That's because the connection is in midst of this --- xact, it is just marked as invalid. +-- Connections are not closed at the end of the alter and drop statements. +-- That's because the connections are in midst of this xact, +-- they are just marked as invalid in pgfdw_inval_callback. ALTER SERVER loopback OPTIONS (ADD use_remote_estimate 'off'); DROP SERVER loopback3 CASCADE; NOTICE: drop cascades to 2 other objects @@ -9113,31 +9107,22 @@ SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; server_name | valid -------------+------- loopback | f - loopback2 | t | f -(3 rows) +(2 rows) --- The invalid connection gets closed in pgfdw_xact_callback during commit. +-- The invalid connections get closed in pgfdw_xact_callback during commit. COMMIT; --- List all the existing cached connections. loopback and loopback3 --- should not be output because they should be closed at the end of --- the above transaction. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; - server_name | valid --------------+------- - loopback2 | t -(1 row) +-- All cached connections were closed while committing above xact, so no +-- records should be output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; + server_name +------------- +(0 rows) -- ======================================================================= -- test postgres_fdw_disconnect and postgres_fdw_disconnect_all functions -- ======================================================================= --- Return true as all cached connections are closed. -SELECT postgres_fdw_disconnect_all(); - postgres_fdw_disconnect_all ------------------------------ - t -(1 row) - +BEGIN; -- Ensure to cache loopback connection. SELECT 1 FROM ft1 LIMIT 1; ?column? @@ -9145,7 +9130,6 @@ SELECT 1 FROM ft1 LIMIT 1; 1 (1 row) -BEGIN; -- Ensure to cache loopback2 connection. SELECT 1 FROM ft6 LIMIT 1; ?column? @@ -9155,66 +9139,31 @@ SELECT 1 FROM ft6 LIMIT 1; -- List all the existing cached connections. loopback and loopback2 should be -- output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; - server_name | valid --------------+------- - loopback | t - loopback2 | t +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; + server_name +------------- + loopback + loopback2 (2 rows) --- Issue a warning and return false as loopback2 connection is still in use and +-- Issue a warning and return false as loopback connection is still in use and -- can not be closed. -SELECT postgres_fdw_disconnect('loopback2'); -WARNING: cannot close connection for server "loopback2" because it is still in use +SELECT postgres_fdw_disconnect('loopback'); +WARNING: cannot close connection for server "loopback" because it is still in use postgres_fdw_disconnect ------------------------- f (1 row) --- Close loopback connection, return true and issue a warning as loopback2 --- connection is still in use and can not be closed. -SELECT postgres_fdw_disconnect_all(); -WARNING: cannot close connection for server "loopback2" because it is still in use - postgres_fdw_disconnect_all ------------------------------ - t -(1 row) +-- List all the existing cached connections. loopback and loopback2 should be +-- output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; + server_name +------------- + loopback + loopback2 +(2 rows) --- List all the existing cached connections. loopback2 should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; - server_name | valid --------------+------- - loopback2 | t -(1 row) - --- Ensure to cache loopback connection. -SELECT 1 FROM ft1 LIMIT 1; - ?column? ----------- - 1 -(1 row) - --- Ensure to cache loopback4 connection. -SELECT 1 FROM ft8 LIMIT 1; - ?column? ----------- - 1 -(1 row) - --- List all the existing cached connections. loopback, loopback2, loopback4 --- should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; - server_name | valid --------------+------- - loopback | t - loopback2 | t - loopback4 | t -(3 rows) - -DROP SERVER loopback4 CASCADE; -NOTICE: drop cascades to 2 other objects -DETAIL: drop cascades to user mapping for public on server loopback4 -drop cascades to foreign table ft8 -- Return false as connections are still in use, warnings are issued. -- But disable warnings temporarily because the order of them is not stable. SET client_min_messages = 'ERROR'; @@ -9226,21 +9175,19 @@ SELECT postgres_fdw_disconnect_all(); RESET client_min_messages; COMMIT; --- Close loopback2 connection and return true. -SELECT postgres_fdw_disconnect('loopback2'); - postgres_fdw_disconnect -------------------------- - t +-- Ensure that loopback2 connection is closed. +SELECT 1 FROM postgres_fdw_disconnect('loopback2'); + ?column? +---------- + 1 (1 row) --- List all the existing cached connections. loopback should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; - server_name | valid --------------+------- - loopback | t -(1 row) +SELECT server_name FROM postgres_fdw_get_connections() WHERE server_name = 'loopback2'; + server_name +------------- +(0 rows) --- Return false as loopback2 connectin is closed already. +-- Return false as loopback2 connection is closed already. SELECT postgres_fdw_disconnect('loopback2'); postgres_fdw_disconnect ------------------------- @@ -9250,18 +9197,17 @@ SELECT postgres_fdw_disconnect('loopback2'); -- Return an error as there is no foreign server with given name. SELECT postgres_fdw_disconnect('unknownserver'); ERROR: server "unknownserver" does not exist --- Close loopback connection and return true. -SELECT postgres_fdw_disconnect_all(); - postgres_fdw_disconnect_all ------------------------------ - t +-- Let's ensure to close all the existing cached connections. +SELECT 1 FROM postgres_fdw_disconnect_all(); + ?column? +---------- + 1 (1 row) --- List all the existing cached connections. No connection exists, so NULL --- should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; - server_name | valid --------------+------- +-- No cached connections, so no records should be output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; + server_name +------------- (0 rows) -- ============================================================================= @@ -9271,6 +9217,7 @@ CREATE ROLE regress_multi_conn_user1 SUPERUSER; CREATE ROLE regress_multi_conn_user2 SUPERUSER; CREATE USER MAPPING FOR regress_multi_conn_user1 SERVER loopback; CREATE USER MAPPING FOR regress_multi_conn_user2 SERVER loopback; +BEGIN; -- Will cache loopback connection with user mapping for regress_multi_conn_user1 SET ROLE regress_multi_conn_user1; SELECT 1 FROM ft1 LIMIT 1; @@ -9290,25 +9237,25 @@ SELECT 1 FROM ft1 LIMIT 1; RESET ROLE; -- Should output two connections for loopback server -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; - server_name | valid --------------+------- - loopback | t - loopback | t +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; + server_name +------------- + loopback + loopback (2 rows) --- Close loopback connections and return true. -SELECT postgres_fdw_disconnect('loopback'); - postgres_fdw_disconnect -------------------------- - t +COMMIT; +-- Let's ensure to close all the existing cached connections. +SELECT 1 FROM postgres_fdw_disconnect_all(); + ?column? +---------- + 1 (1 row) --- List all the existing cached connections. No connection exists, so NULL --- should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; - server_name | valid --------------+------- +-- No cached connections, so no records should be output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; + server_name +------------- (0 rows) -- Clean up diff --git a/contrib/postgres_fdw/sql/postgres_fdw.sql b/contrib/postgres_fdw/sql/postgres_fdw.sql index 647192cf6a..319c15d635 100644 --- a/contrib/postgres_fdw/sql/postgres_fdw.sql +++ b/contrib/postgres_fdw/sql/postgres_fdw.sql @@ -19,10 +19,6 @@ DO $d$ OPTIONS (dbname '$$||current_database()||$$', port '$$||current_setting('port')||$$' )$$; - EXECUTE $$CREATE SERVER loopback4 FOREIGN DATA WRAPPER postgres_fdw - OPTIONS (dbname '$$||current_database()||$$', - port '$$||current_setting('port')||$$' - )$$; END; $d$; @@ -31,7 +27,6 @@ CREATE USER MAPPING FOR public SERVER testserver1 CREATE USER MAPPING FOR CURRENT_USER SERVER loopback; CREATE USER MAPPING FOR CURRENT_USER SERVER loopback2; CREATE USER MAPPING FOR public SERVER loopback3; -CREATE USER MAPPING FOR public SERVER loopback4; -- =================================================================== -- create objects used through FDW loopback server @@ -158,12 +153,6 @@ CREATE FOREIGN TABLE ft7 ( c3 text ) SERVER loopback3 OPTIONS (schema_name 'S 1', table_name 'T 4'); -CREATE FOREIGN TABLE ft8 ( - c1 int NOT NULL, - c2 int NOT NULL, - c3 text -) SERVER loopback4 OPTIONS (schema_name 'S 1', table_name 'T 4'); - -- =================================================================== -- tests for validator -- =================================================================== @@ -2723,80 +2712,67 @@ DROP PROCEDURE terminate_backend_and_wait(text); -- ============================================================================= -- test connection invalidation cases and postgres_fdw_get_connections function -- ============================================================================= +-- Let's ensure to close all the existing cached connections. +SELECT 1 FROM postgres_fdw_disconnect_all(); +-- No cached connections, so no records should be output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; -- This test case is for closing the connection in pgfdw_xact_callback BEGIN; --- List all the existing cached connections. Only loopback2 should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; -- Connection xact depth becomes 1 i.e. the connection is in midst of the xact. SELECT 1 FROM ft1 LIMIT 1; SELECT 1 FROM ft7 LIMIT 1; --- List all the existing cached connections. loopback and loopback3 --- also should be output as valid connections. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; --- Connection is not closed at the end of the alter statement in --- pgfdw_inval_callback. That's because the connection is in midst of this --- xact, it is just marked as invalid. +-- List all the existing cached connections. loopback and loopback3 should be +-- output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; +-- Connections are not closed at the end of the alter and drop statements. +-- That's because the connections are in midst of this xact, +-- they are just marked as invalid in pgfdw_inval_callback. ALTER SERVER loopback OPTIONS (ADD use_remote_estimate 'off'); DROP SERVER loopback3 CASCADE; -- List all the existing cached connections. loopback and loopback3 -- should be output as invalid connections. Also the server name for -- loopback3 should be NULL because the server was dropped. SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; --- The invalid connection gets closed in pgfdw_xact_callback during commit. +-- The invalid connections get closed in pgfdw_xact_callback during commit. COMMIT; --- List all the existing cached connections. loopback and loopback3 --- should not be output because they should be closed at the end of --- the above transaction. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; +-- All cached connections were closed while committing above xact, so no +-- records should be output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; -- ======================================================================= -- test postgres_fdw_disconnect and postgres_fdw_disconnect_all functions -- ======================================================================= --- Return true as all cached connections are closed. -SELECT postgres_fdw_disconnect_all(); +BEGIN; -- Ensure to cache loopback connection. SELECT 1 FROM ft1 LIMIT 1; -BEGIN; -- Ensure to cache loopback2 connection. SELECT 1 FROM ft6 LIMIT 1; -- List all the existing cached connections. loopback and loopback2 should be -- output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; --- Issue a warning and return false as loopback2 connection is still in use and +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; +-- Issue a warning and return false as loopback connection is still in use and -- can not be closed. -SELECT postgres_fdw_disconnect('loopback2'); --- Close loopback connection, return true and issue a warning as loopback2 --- connection is still in use and can not be closed. -SELECT postgres_fdw_disconnect_all(); --- List all the existing cached connections. loopback2 should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; --- Ensure to cache loopback connection. -SELECT 1 FROM ft1 LIMIT 1; --- Ensure to cache loopback4 connection. -SELECT 1 FROM ft8 LIMIT 1; --- List all the existing cached connections. loopback, loopback2, loopback4 --- should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; -DROP SERVER loopback4 CASCADE; +SELECT postgres_fdw_disconnect('loopback'); +-- List all the existing cached connections. loopback and loopback2 should be +-- output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; -- Return false as connections are still in use, warnings are issued. -- But disable warnings temporarily because the order of them is not stable. SET client_min_messages = 'ERROR'; SELECT postgres_fdw_disconnect_all(); RESET client_min_messages; COMMIT; --- Close loopback2 connection and return true. -SELECT postgres_fdw_disconnect('loopback2'); --- List all the existing cached connections. loopback should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; --- Return false as loopback2 connectin is closed already. +-- Ensure that loopback2 connection is closed. +SELECT 1 FROM postgres_fdw_disconnect('loopback2'); +SELECT server_name FROM postgres_fdw_get_connections() WHERE server_name = 'loopback2'; +-- Return false as loopback2 connection is closed already. SELECT postgres_fdw_disconnect('loopback2'); -- Return an error as there is no foreign server with given name. SELECT postgres_fdw_disconnect('unknownserver'); --- Close loopback connection and return true. -SELECT postgres_fdw_disconnect_all(); --- List all the existing cached connections. No connection exists, so NULL --- should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; +-- Let's ensure to close all the existing cached connections. +SELECT 1 FROM postgres_fdw_disconnect_all(); +-- No cached connections, so no records should be output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; -- ============================================================================= -- test case for having multiple cached connections for a foreign server @@ -2806,6 +2782,7 @@ CREATE ROLE regress_multi_conn_user2 SUPERUSER; CREATE USER MAPPING FOR regress_multi_conn_user1 SERVER loopback; CREATE USER MAPPING FOR regress_multi_conn_user2 SERVER loopback; +BEGIN; -- Will cache loopback connection with user mapping for regress_multi_conn_user1 SET ROLE regress_multi_conn_user1; SELECT 1 FROM ft1 LIMIT 1; @@ -2817,14 +2794,12 @@ SELECT 1 FROM ft1 LIMIT 1; RESET ROLE; -- Should output two connections for loopback server -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; - --- Close loopback connections and return true. -SELECT postgres_fdw_disconnect('loopback'); - --- List all the existing cached connections. No connection exists, so NULL --- should be output. -SELECT * FROM postgres_fdw_get_connections() ORDER BY 1; +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; +COMMIT; +-- Let's ensure to close all the existing cached connections. +SELECT 1 FROM postgres_fdw_disconnect_all(); +-- No cached connections, so no records should be output. +SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1; -- Clean up DROP USER MAPPING FOR regress_multi_conn_user1 SERVER loopback;

view thread (175+ messages)  latest in thread

Message-ID: <00e03384-e49a-513a-2aef-d5b42a65b94a@oss.nttdata.com>
Permalink:  ../00e03384-e49a-513a-2aef-d5b42a65b94a@oss.nttdata.com/
Also on:    postgresql.org/message-id/00e03384-e49a-513a-2aef-d5b42a65b94a@oss.nttdata.com

 ·  · 

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-hackers@postgresql.org
  Cc: masao.fujii@oss.nttdata.com, bharath.rupireddyforpostgres@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit
  In-Reply-To: <00e03384-e49a-513a-2aef-d5b42a65b94a@oss.nttdata.com>
  References: <CALj2ACVvrp5=AVp2PupEm+nAC8S4buqR3fJMmaCoc7ftT0aD2A@mail.gmail.com> <CALj2ACWhoQtyZdsCZNLDLOnRjCBcoscrc3H0qU4=7f23UZcF9g@mail.gmail.com> <2724627.1611886184@sss.pgh.pa.us> <fbfdf4e2-37fb-a3f1-f6a0-3f9bf089e356@oss.nttdata.com> <CALj2ACVL7PZO+gOj7Jrhshm79TjTpj_6CJDqtf34VgjQasX1DA@mail.gmail.com> <6e9c9d45-c612-639a-f741-7798013c0ae4@oss.nttdata.com> <CALj2ACW1jAJTi-SmBCStZ6+a1C3DeAc8-_Zuw1LYFzo8D33k2w@mail.gmail.com> <CALj2ACXhM_yTBXXTCA-whZ_oA1x3DuGxyKnsROjMh8YZLG9bJw@mail.gmail.com> <7fa16ff3-5b37-0617-7a27-22e839695ef5@oss.nttdata.com> <CALj2ACXQ9ke6deP1-f34vv7TOrLuXr6=nmbi5fgxA3N_Zs=pnQ@mail.gmail.com> <c0d078a7-1cfb-3621-6a44-d73ba1382bb2@oss.nttdata.com> <CALj2ACWpNKXJrrofn7uGZwg8+9BooC-4N_28VTRiU7d-pOHH9w@mail.gmail.com> <8a6d3620-11de-30c8-7647-375cf92f442a@oss.nttdata.com> <CALj2ACXjs-fXq3h=NrVN8nSLYzvA-SZpu=nPpv9cY1uPuoujMw@mail.gmail.com> <CALj2ACX24Se9mwKDZ-y_SczSUbF-bVhrUYfWX3RWmGWREc6Apg@mail.gmail.com> <00e03384-e49a-513a-2aef-d5b42a65b94a@oss.nttdata.com>

* 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