Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1O1P-0002nV-Gy for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jan 2021 06:28:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l1O1N-0003lm-Jv for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jan 2021 06:28:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1O1N-0003le-Bw for pgsql-hackers@lists.postgresql.org; Mon, 18 Jan 2021 06:28:13 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1O1H-00040D-0d for pgsql-hackers@lists.postgresql.org; Mon, 18 Jan 2021 06:28:12 +0000 Received: from hnk.local (p2388216-ipbf1027funabasi.chiba.ocn.ne.jp [118.6.6.216]) by oss.nttdata.com (Postfix) with ESMTPSA id D345862796; Mon, 18 Jan 2021 15:28:04 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit To: "Hou, Zhijie" , Bharath Rupireddy Cc: PostgreSQL Hackers , Zhihong Yu , Alexey Kondratov References: <82debcd7-b236-0fc5-5ff1-5e6b99c59d64@oss.nttdata.com> <55bd82c5-d133-6fbb-f1f4-e25c1509c96e@oss.nttdata.com> From: Fujii Masao Message-ID: <8ec46200-4e34-556c-f7cd-476255aa5419@oss.nttdata.com> Date: Mon, 18 Jan 2021 15:28:04 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2021/01/18 15:02, Hou, Zhijie wrote: >> We need to create the loopback3 with user mapping public, otherwise the >> test might become unstable as shown below. Note that loopback and >> loopback2 are not dropped in the test, so no problem with them. >> >> ALTER SERVER loopback OPTIONS (ADD use_remote_estimate 'off'); DROP >> SERVER loopback3 CASCADE; >> NOTICE: drop cascades to 2 other objects >> -DETAIL: drop cascades to user mapping for postgres on server loopback3 >> +DETAIL: drop cascades to user mapping for bharath on server loopback3 >> >> Attaching v2 patch for postgres_fdw_get_connections. Please have a look. > Hi > > I have a comment for the doc about postgres_fdw_get_connections. > > + postgres_fdw_get_connections(OUT server_name text, OUT valid boolean) returns setof record > + > + > + This function returns the foreign server names of all the open > + connections that postgres_fdw established from > + the local session to the foreign servers. It also returns whether > + each connection is valid or not. false is returned > + if the foreign server connection is used in the current local > + transaction but its foreign server or user mapping is changed or > + dropped, and then such invalid connection will be closed at > + the end of that transaction. true is returned > + otherwise. If there are no open connections, no record is returned. > + Example usage of the function: > > The doc seems does not memtion the case when the function returns NULL in server_name. > Users may be a little confused about why NULL was returned. Yes, so what about adding (Note that the returned server name of invalid connection is NULL if its server is dropped) into the following (just after "dropped")? + if the foreign server connection is used in the current local + transaction but its foreign server or user mapping is changed or + dropped Or better description? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION