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 1kf6nG-0006vy-6v for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Nov 2020 19:37:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kf6nF-0005pF-5Y for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Nov 2020 19:37:33 +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 1kf6nE-0005p8-Qs for pgsql-hackers@lists.postgresql.org; Tue, 17 Nov 2020 19:37:32 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kf6nC-0005al-9A for pgsql-hackers@lists.postgresql.org; Tue, 17 Nov 2020 19:37:32 +0000 Received: from mail.postgrespro.ru (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id BDA7321C1C60; Tue, 17 Nov 2020 22:37:28 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1605641848; bh=fkViyo7ZbgXg22NEe3wm0bhEpaezokubH6kfasMxHyA=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=P+ajT2CGxOe/vm2o8Q3YWB8XZO2bCLkDY/rmjytXrzOdkZDWvjJBAo0sflUnlTz4N AAhOw+ia0+CUxMceQk00N4Hnw1gSMOS3ST4xdAxMlv8vW1T4aoBBgDIc28J2h0VwZs QhWfroFBNrPMux8kkTXbMR7hQprppDcVaCgzZjgA= MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_a2ace9f91a8b641766de4079df266f75" Content-Transfer-Encoding: 7bit Date: Tue, 17 Nov 2020 22:37:28 +0300 From: Alexey Kondratov To: Bharath Rupireddy Cc: pgsql-hackers@lists.postgresql.org, Bruce Momjian , Michael Paquier , Anastasia Lubennikova Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit In-Reply-To: <160467818521.7362.11186359886835925531.pgcf@coridan.postgresql.org> References: <160467818521.7362.11186359886835925531.pgcf@coridan.postgresql.org> User-Agent: Roundcube Webmail/1.4.0 Message-ID: <6df6525ca7a4b54a4a39f55e4dd6b3e9@postgrespro.ru> X-Sender: a.kondratov@postgrespro.ru List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=_a2ace9f91a8b641766de4079df266f75 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Hi, On 2020-11-06 18:56, Anastasia Lubennikova wrote: > Status update for a commitfest entry. > > This thread was inactive for a while and from the latest messages, I > see that the patch needs some further work. > So I move it to "Waiting on Author". > > The new status of this patch is: Waiting on Author I had a look on the initial patch and discussed options [1] to proceed with this issue. I agree with Bruce about idle_session_timeout, it would be a nice to have in-core feature on its own. However, this should be a cluster-wide option and it will start dropping all idle connection not only foreign ones. So it may be not an option for some cases, when the same foreign server is used for another load as well. Regarding the initial issue I prefer point #3, i.e. foreign server option. It has a couple of benefits IMO: 1) it may be set separately on per foreign server basis, 2) it will live only in the postgres_fdw contrib without any need to touch core. I would only supplement this postgres_fdw foreign server option with a GUC, e.g. postgres_fdw.keep_connections, so one could easily define such behavior for all foreign servers at once or override server-level option by setting this GUC on per session basis. Attached is a small POC patch, which implements this contrib-level postgres_fdw.keep_connections GUC. What do you think? [1] https://www.postgresql.org/message-id/CALj2ACUFNydy0uo0JL9A1isHQ9pFe1Fgqa_HVanfG6F8g21nSQ%40mail.gmail.com Regards -- Alexey Kondratov Postgres Professional https://www.postgrespro.com Russian Postgres Company --=_a2ace9f91a8b641766de4079df266f75 Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=pgfdw_keep_connections.diff Content-Disposition: attachment; filename=pgfdw_keep_connections.diff; size=2366 ZGlmZiAtLWdpdCBhL2NvbnRyaWIvcG9zdGdyZXNfZmR3L2Nvbm5lY3Rpb24uYyBiL2NvbnRyaWIv cG9zdGdyZXNfZmR3L2Nvbm5lY3Rpb24uYwppbmRleCBhYjMyMjYyODdkLi42NGYwZTk2NjM1IDEw MDY0NAotLS0gYS9jb250cmliL3Bvc3RncmVzX2Zkdy9jb25uZWN0aW9uLmMKKysrIGIvY29udHJp Yi9wb3N0Z3Jlc19mZHcvY29ubmVjdGlvbi5jCkBAIC0yOCw2ICsyOCw4IEBACiAjaW5jbHVkZSAi dXRpbHMvbWVtdXRpbHMuaCIKICNpbmNsdWRlICJ1dGlscy9zeXNjYWNoZS5oIgogCisjaW5jbHVk ZSAicG9zdGdyZXNfZmR3LmgiCisKIC8qCiAgKiBDb25uZWN0aW9uIGNhY2hlIGhhc2ggdGFibGUg ZW50cnkKICAqCkBAIC05NDgsNiArOTUwLDcgQEAgcGdmZHdfeGFjdF9jYWxsYmFjayhYYWN0RXZl bnQgZXZlbnQsIHZvaWQgKmFyZykKIAkJICovCiAJCWlmIChQUXN0YXR1cyhlbnRyeS0+Y29ubikg IT0gQ09OTkVDVElPTl9PSyB8fAogCQkJUFF0cmFuc2FjdGlvblN0YXR1cyhlbnRyeS0+Y29ubikg IT0gUFFUUkFOU19JRExFIHx8CisJCQkha2VlcF9jb25uZWN0aW9ucyB8fAogCQkJZW50cnktPmNo YW5naW5nX3hhY3Rfc3RhdGUpCiAJCXsKIAkJCWVsb2coREVCVUczLCAiZGlzY2FyZGluZyBjb25u ZWN0aW9uICVwIiwgZW50cnktPmNvbm4pOwpkaWZmIC0tZ2l0IGEvY29udHJpYi9wb3N0Z3Jlc19m ZHcvcG9zdGdyZXNfZmR3LmMgYi9jb250cmliL3Bvc3RncmVzX2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