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 1l6TOy-0006c0-0N for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Feb 2021 07:13:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l6TOw-0004aE-Uj for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Feb 2021 07:13:34 +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 1l6TOw-0004a7-No for pgsql-hackers@lists.postgresql.org; Mon, 01 Feb 2021 07:13:34 +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 1l6TOu-0001Kt-GD for pgsql-hackers@lists.postgresql.org; Mon, 01 Feb 2021 07:13:34 +0000 Received: from hnk.local (p2112118-ipbf2507funabasi.chiba.ocn.ne.jp [123.216.63.118]) by oss.nttdata.com (Postfix) with ESMTPSA id 1144C62728; Mon, 1 Feb 2021 16:13:28 +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: Zhihong Yu , Alexey Kondratov , "Hou, Zhijie" , PostgreSQL Hackers References: <646119f3-fd27-7fd7-5377-b72310af5d21@oss.nttdata.com> <62431587-ed3a-f333-51a9-967ccf2a78db@oss.nttdata.com> <1c643738-6e52-565d-0261-740d490b550e@oss.nttdata.com> <09b3f740-896d-7507-95e1-d2afd87daf2e@oss.nttdata.com> <64ee084b-1368-e044-debd-69cc156276c6@oss.nttdata.com> <39259f30-897c-ceaf-8a1e-78fe2db398cb@oss.nttdata.com> From: Fujii Masao Message-ID: <8ef4979b-85e7-c3f2-0653-f8f444f5dcff@oss.nttdata.com> Date: Mon, 1 Feb 2021 16:13:27 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 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/27 10:06, Bharath Rupireddy wrote: > On Tue, Jan 26, 2021 at 8:38 AM Bharath Rupireddy > wrote: >> I will post "keep_connections" GUC and "keep_connection" server level >> option patches later. > > Attaching v19 patch set for "keep_connections" GUC and > "keep_connection" server level option. Please review them further. These options are no longer necessary because we now support idle_session_timeout? If we want to disconnect the foreign server connections that sit on idle to prevent them from eating up the connection capacities in the foriegn servers, we can just set idle_session_timeout in those foreign servers. If we want to avoid the cluster-wide setting of idle_session_timeout, we can set that per role. One issue for this approach is that the connection entry remains even after idle_session_timeout happens. So postgres_fdw_get_connections() returns that connection even though it's actually closed by the timeout. Which is confusing. But which doesn't cause any actual problem, right? When the foreign table is accessed the next time, that connection entry is dropped, an error is detected, and then new connection will be remade. Sorry I've not read the past long discussion about this feature. If there is the consensus that these options are still necessary and useful even when we have idle_session_timeout, please correct me. ISTM that it's intuitive (at least for me) to add this kind of option into the foreign server. But I'm not sure if it's good idea to expose the option as GUC. Also if there is the consensus about this, please correct me. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION