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 1l1TwL-00016I-UQ for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jan 2021 12:47:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l1TwK-0008Dn-IO for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jan 2021 12:47:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1TwK-0008Dg-BB for pgsql-hackers@lists.postgresql.org; Mon, 18 Jan 2021 12:47:24 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1TwH-0001tx-I9 for pgsql-hackers@lists.postgresql.org; Mon, 18 Jan 2021 12:47:24 +0000 Received: from hnk.local (p2388216-ipbf1027funabasi.chiba.ocn.ne.jp [118.6.6.216]) by oss.nttdata.com (Postfix) with ESMTPSA id EB0396235B; Mon, 18 Jan 2021 21:47:15 +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: Bharath Rupireddy Cc: "Hou, Zhijie" , PostgreSQL Hackers , Zhihong Yu , Alexey Kondratov References: <82debcd7-b236-0fc5-5ff1-5e6b99c59d64@oss.nttdata.com> <55bd82c5-d133-6fbb-f1f4-e25c1509c96e@oss.nttdata.com> <8ec46200-4e34-556c-f7cd-476255aa5419@oss.nttdata.com> From: Fujii Masao Message-ID: <81e295dd-2abb-1e52-4172-94f3c8ca2807@oss.nttdata.com> Date: Mon, 18 Jan 2021 21:47:15 +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:37, Bharath Rupireddy wrote: > On Mon, Jan 18, 2021 at 11:58 AM Fujii Masao > wrote: >> >> >> >> 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? > > +1 to add it after "dropped (Note ........)", how about as follows > with slight changes? > > dropped (Note that server name of an invalid connection can be NULL if > the server is dropped), and then such ..... Yes, I like this one. One question is; "should" or "is" is better than "can" in this case because the server name of invalid connection is always NULL when its server is dropped? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION